diff src/ov-str-mat.cc @ 2407:4f55dc039a7e

[project @ 1996-10-14 19:48:50 by jwe]
author jwe
date Mon, 14 Oct 1996 19:48:51 +0000
parents 2142216bf85a
children 31a279f31070
line wrap: on
line diff
--- a/src/ov-str-mat.cc
+++ b/src/ov-str-mat.cc
@@ -31,6 +31,7 @@
 #include "lo-ieee.h"
 #include "mx-base.h"
 
+#include "oct-obj.h"
 #include "ops.h"
 #include "ov-re-mat.h"
 #include "ov-str-mat.h"
@@ -56,6 +57,79 @@
 }
 
 octave_value
+octave_char_matrix_str::index (const octave_value_list& idx) const
+{
+  octave_value retval;
+
+  int len = idx.length ();
+
+  switch (len)
+    {
+    case 2:
+      {
+	idx_vector i = idx (0).index_vector ();
+	idx_vector j = idx (1).index_vector ();
+
+	retval = octave_value (charMatrix (matrix.index (i, j)), true);
+      }
+      break;
+
+    case 1:
+      {
+	idx_vector i = idx (0).index_vector ();
+
+	retval = octave_value (charMatrix (matrix.index (i)), true);
+      }
+      break;
+
+    default:
+      error ("invalid number of indices (%d) for matrix value", len);
+      break;
+    }
+
+  return retval;
+}
+
+extern void assign (Array2<char>&, const Array2<char>&);
+
+void
+octave_char_matrix_str::assign (const octave_value_list& idx,
+				const charMatrix& rhs)
+{
+  int len = idx.length ();
+
+  switch (len)
+    {
+    case 2:
+      {
+	idx_vector i = idx (0).index_vector ();
+	idx_vector j = idx (1).index_vector ();
+
+	matrix.set_index (i);
+	matrix.set_index (j);
+
+	::assign (matrix, rhs);
+      }
+      break;
+
+    case 1:
+      {
+	idx_vector i = idx (0).index_vector ();
+
+	matrix.set_index (i);
+
+	::assign (matrix, rhs);
+      }
+      break;
+
+    default:
+      error ("invalid number of indices (%d) for indexed matrix assignment",
+	     len);
+      break;
+    }
+}
+
+octave_value
 octave_char_matrix_str::all (void) const
 {
   octave_value retval;
@@ -118,9 +192,7 @@
 charMatrix
 octave_char_matrix_str::all_strings (void) const
 {
-  charMatrix retval;
-  error ("octave_char_matrix_str::all_strings(): not implemented");
-  return retval;
+  return matrix;
 }
 
 string