diff src/ov-str-mat.cc @ 10729:172253d75d94

implement cellstr extractors for char matrices
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 24 Jun 2010 14:39:32 +0200
parents 394a83606f03
children a117dc8ea1b9
line wrap: on
line diff
--- a/src/ov-str-mat.cc	Thu Jun 24 12:42:38 2010 +0200
+++ b/src/ov-str-mat.cc	Thu Jun 24 14:39:32 2010 +0200
@@ -242,6 +242,25 @@
   return retval;
 }
 
+Array<std::string>
+octave_char_matrix_str::cellstr_value (void) const
+{
+  Array<std::string> retval;
+
+  if (matrix.ndims () == 2)
+    {
+      const charMatrix chm = matrix.matrix_value ();
+      octave_idx_type nr = chm.rows ();
+      retval.clear (nr, 1);
+      for (octave_idx_type i = 0; i < nr; i++)
+        retval.xelem(i) = chm.row_as_string (i);
+    }
+  else
+    error ("cellstr: cannot convert multidimensional arrays");
+
+  return retval;
+}
+
 void
 octave_char_matrix_str::print_raw (std::ostream& os, bool pr_as_read_syntax) const
 {