diff libinterp/octave-value/ov-str-mat.cc @ 17870:1d2e709bbbda

rework short_disp methods * ov.h (octave_value::short_disp): Pass std::ostream as argument instead of returning std::string. Change all uses. * ov-base.h (octave_base_value::short_disp): Likewise. Change all derived classes. * ov-base-scalar.cc (octave_base_scalar<ST>::short_disp): Strip leading whitepace from number. * ov-base-mat.cc (octave_base_matrix<MT>::short_disp): Strip leading whitepace from numbers.
author John W. Eaton <jwe@octave.org>
date Thu, 07 Nov 2013 00:52:48 -0500
parents 870f3e12e163
children b951a8351fd7
line wrap: on
line diff
--- a/libinterp/octave-value/ov-str-mat.cc
+++ b/libinterp/octave-value/ov-str-mat.cc
@@ -270,25 +270,20 @@
                          current_print_indent_level (), true);
 }
 
-std::string
-octave_char_matrix_str::short_disp (void) const
+void
+octave_char_matrix_str::short_disp (std::ostream& os) const
 {
-  std::string retval;
-
   if (matrix.ndims () == 2 && numel () > 0)
     {
-      retval = string_value ();
+      std::string tmp = string_value ();
 
       // FIXME: should this be configurable?
+      size_t max_len = 100;
 
-      if (retval.length () > 100)
-        retval = retval.substr (0, 100);
+      os << (tmp.length () > max_len) ? tmp.substr (0, 100) : tmp;
     }
-
-  return retval;
 }
 
-
 bool
 octave_char_matrix_str::save_ascii (std::ostream& os)
 {