comparison src/ov-class.cc @ 13694:441af0aa125a

char: when converting cell elements containing class objects, call overloaded char function if one exists * ov-class.cc, ov-class.h (octave_class::all_strings): New function.
author John W. Eaton <jwe@octave.org>
date Wed, 12 Oct 2011 21:28:30 -0400
parents 2a8dcb5b3a00
children 348857854c52
comparison
equal deleted inserted replaced
13693:cb52dd180d36 13694:441af0aa125a
994 } 994 }
995 995
996 return retval; 996 return retval;
997 } 997 }
998 998
999 string_vector
1000 octave_class::all_strings (bool pad) const
1001 {
1002 string_vector retval;
1003
1004 octave_value meth = symbol_table::find_method ("char", class_name ());
1005
1006 if (meth.is_defined ())
1007 {
1008 octave_value_list args;
1009 args(0) = octave_value (new octave_class (map, c_name));
1010
1011 octave_value_list tmp = feval (meth.function_value (), args, 1);
1012
1013 if (!error_state && tmp.length () >= 1)
1014 {
1015 if (tmp(0).is_string ())
1016 retval = tmp(0).all_strings (pad);
1017 else
1018 error ("cname/char method did not return a character string");
1019 }
1020 }
1021 else
1022 error ("no char method defined for class %s", class_name().c_str ());
1023
1024 return retval;
1025 }
1026
1027
999 void 1028 void
1000 octave_class::print (std::ostream& os, bool) const 1029 octave_class::print (std::ostream& os, bool) const
1001 { 1030 {
1002 print_raw (os); 1031 print_raw (os);
1003 } 1032 }