Mercurial > octave-nkf
comparison libinterp/octave-value/ov-base.cc @ 20611:40ed9b46a800
new octave_value::string_value method with optional error message
* ov.h (octave_value::string_vector): New method.
ov-base.cc, ov-base.h (octave_base_value::string_vector):
New default method.
ov-str-mat.cc, ov-str-mat.h (octave_char_matrix_str::string_value):
New method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 08 Oct 2015 16:43:22 -0400 |
parents | f90c8372b7ba |
children | e5986cba4ca8 |
comparison
equal
deleted
inserted
replaced
20610:a61f0d6beb71 | 20611:40ed9b46a800 |
---|---|
906 octave_value tmp = convert_to_str (force); | 906 octave_value tmp = convert_to_str (force); |
907 | 907 |
908 retval = tmp.string_value (); | 908 retval = tmp.string_value (); |
909 | 909 |
910 return retval; | 910 return retval; |
911 } | |
912 | |
913 std::string | |
914 octave_base_value::string_value (const char *fmt, va_list args) const | |
915 { | |
916 // Note that this method does not need to be particularly efficient | |
917 // since it is already an error to end up here. | |
918 | |
919 // FIXME: do we want both the wrong-type-argument error and any custom | |
920 // error message, or just the custom error message, or should that | |
921 // behavior be optional in some way? | |
922 | |
923 try | |
924 { | |
925 std::string tn = type_name (); | |
926 | |
927 error ("wrong type argument '%s'\n", tn.c_str ()); | |
928 } | |
929 catch (const octave_execution_exception&) | |
930 { | |
931 if (fmt) | |
932 verror (fmt, args); | |
933 | |
934 throw; | |
935 } | |
936 | |
937 return std::string (); | |
911 } | 938 } |
912 | 939 |
913 Array<std::string> | 940 Array<std::string> |
914 octave_base_value::cellstr_value (void) const | 941 octave_base_value::cellstr_value (void) const |
915 { | 942 { |