diff src/graphics.cc @ 7523:f2000f1971ab

new row_vector_property class
author John W. Eaton <jwe@octave.org>
date Mon, 25 Feb 2008 03:44:50 -0500
parents b1cfd33a364b
children 52d58b0463ed
line wrap: on
line diff
--- a/src/graphics.cc	Sun Feb 24 03:32:49 2008 -0500
+++ b/src/graphics.cc	Mon Feb 25 03:44:50 2008 -0500
@@ -491,6 +491,36 @@
   return xok;
 }
 
+bool
+row_vector_property::validate (const octave_value& v)
+{
+  bool xok = false;
+
+  // FIXME: should we always support []?
+  if (v.is_empty () && v.is_double_type ())
+    return true;
+
+  // check value type
+  if (type_constraints.size () > 0)
+    {
+      for (std::list<std::string>::const_iterator it = type_constraints.begin ();
+           ! xok && it != type_constraints.end (); ++it)
+        if ((*it) == v.type_name ())
+          xok = true;
+    }
+  else
+    xok = v.is_double_type ();
+
+  if (xok)
+    {
+      dim_vector vdims = v.dims ();
+
+      xok = vdims.length () != 2 || (vdims(0) != 1 && vdims(1) != 1);
+    }
+
+  return xok;
+}
+
 void
 handle_property::set (const octave_value& v)
 {