changeset 28431:0ffae065ca03 stable

new cellstring constructor * Cell.h, Cell.cc (Cell::Cell): New overload that accepts a std::list<std::string> object.
author John W. Eaton <jwe@octave.org>
date Fri, 03 Apr 2020 21:59:15 -0400
parents 5bfa8e018704
children 71c34141cc2d
files libinterp/corefcn/Cell.cc libinterp/corefcn/Cell.h
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/Cell.cc	Mon Mar 30 15:14:10 2020 -0400
+++ b/libinterp/corefcn/Cell.cc	Fri Apr 03 21:59:15 2020 -0400
@@ -63,6 +63,23 @@
     }
 }
 
+Cell::Cell (const std::list<std::string>& sl)
+  : Array<octave_value> ()
+{
+  octave_idx_type n = sl.size ();
+
+  if (n > 0)
+    {
+      resize (dim_vector (n, 1));
+
+      octave_value *dst = fortran_vec ();
+      auto p = sl.begin ();
+
+      for (octave_idx_type i = 0; i < n; i++)
+        dst[i] = *p++;
+    }
+}
+
 Cell::Cell (const Array<std::string>& sa)
   : Array<octave_value> (sa.dims ())
 {
--- a/libinterp/corefcn/Cell.h	Mon Mar 30 15:14:10 2020 -0400
+++ b/libinterp/corefcn/Cell.h	Fri Apr 03 21:59:15 2020 -0400
@@ -28,6 +28,7 @@
 
 #include "octave-config.h"
 
+#include <list>
 #include <string>
 
 #include "Array.h"
@@ -90,6 +91,8 @@
       }
   }
 
+  Cell (const std::list<std::string>& sl);
+
   Cell (const Array<std::string>& sa);
 
   Cell (const dim_vector& dv, const string_vector& sv, bool trim = false);