diff libinterp/octave-value/ov-cell.cc @ 20700:68e3a747ca02

rename octave_value value extractors that accept error message args * ov.h, ov.cc (octave_value::xcell_value, octave_value::xstring_value, octave_value::xcellstr_value): Rename functions that accept error message args. Handle error directly. Only forward to functions that don't attempt type conversion. Change all uses. * ov-base.h, ov-base.cc (octave_base_value::xstring_value): Don't do type conversion. (octave_base_value::cell_value, octave_base_value::cellstr_value): Delete versions that accept error message args. * ov-str-mat.h, ov-str-mat.cc (octave_char_matrix_str::string_value, octave_char_matrix_str::cell_value): Delete.
author John W. Eaton <jwe@octave.org>
date Fri, 13 Nov 2015 14:10:26 -0500
parents b0b37f0d7e6d
children 571508c1ed06
line wrap: on
line diff
--- a/libinterp/octave-value/ov-cell.cc	Thu Nov 12 19:27:25 2015 -0800
+++ b/libinterp/octave-value/ov-cell.cc	Fri Nov 13 14:10:26 2015 -0500
@@ -480,7 +480,10 @@
 {
   octave_value retval;
 
-  Array<std::string> tmp = cellstr_value ("sort: only cell arrays of character strings may be sorted");
+  if (! is_cellstr ())
+    error ("sort: only cell arrays of character strings may be sorted");
+
+  Array<std::string> tmp = cellstr_value ();
 
   tmp = tmp.sort (dim, mode);
 
@@ -496,7 +499,10 @@
 {
   octave_value retval;
 
-  Array<std::string> tmp = cellstr_value ("sort: only cell arrays of character strings may be sorted");
+  if (! is_cellstr ())
+    error ("sort: only cell arrays of character strings may be sorted");
+
+  Array<std::string> tmp = cellstr_value ();
 
   tmp = tmp.sort (sidx, dim, mode);
 
@@ -511,7 +517,10 @@
 {
   sortmode retval = UNSORTED;
 
-  Array<std::string> tmp = cellstr_value ("issorted: A is not a cell array of strings");
+  if (! is_cellstr ())
+    error ("issorted: A is not a cell array of strings");
+
+  Array<std::string> tmp = cellstr_value ();
 
   retval = tmp.is_sorted (mode);
 
@@ -524,7 +533,10 @@
 {
   Array<octave_idx_type> retval;
 
-  Array<std::string> tmp = cellstr_value ("sortrows: only cell arrays of character strings may be sorted");
+  if (! is_cellstr ())
+    error ("sortrows: only cell arrays of character strings may be sorted");
+
+  Array<std::string> tmp = cellstr_value ();
 
   retval = tmp.sort_rows_idx (mode);
 
@@ -536,7 +548,10 @@
 {
   sortmode retval = UNSORTED;
 
-  Array<std::string> tmp = cellstr_value ("issorted: A is not a cell array of strings");
+  if (! is_cellstr ())
+    error ("issorted: A is not a cell array of strings");
+
+  Array<std::string> tmp = cellstr_value ();
 
   retval = tmp.is_sorted_rows (mode);
 
@@ -636,49 +651,6 @@
   return retval;
 }
 
-Array<std::string>
-octave_cell::cellstr_value (const char *fmt, ...) const
-{
-  Array<std::string> retval;
-  va_list args;
-  retval = cellstr_value (fmt, args);
-  va_end (args);
-  return retval;
-}
-
-Array<std::string>
-octave_cell::cellstr_value (const char *fmt, va_list args) const
-{
-  Array<std::string> retval;
-
-  if (! fmt)
-    return cellstr_value ();
-
-  bool conversion_error = false;
-
-  if (is_cellstr ())
-    {
-      try
-        {
-          if (cellstr_cache->is_empty ())
-            *cellstr_cache = matrix.cellstr_value ();
-
-          retval = *cellstr_cache;
-        }
-      catch (const octave_execution_exception&)
-        {
-          conversion_error = true;
-        }
-    }
-  else
-    conversion_error = true;
-
-  if (conversion_error)
-    verror (fmt, args);
-
-  return retval;
-}
-
 bool
 octave_cell::print_as_scalar (void) const
 {