Mercurial > octave-nkf
comparison libinterp/octave-value/ov-str-mat.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 |
comparison
equal
deleted
inserted
replaced
20610:a61f0d6beb71 | 20611:40ed9b46a800 |
---|---|
250 error ("invalid conversion of charNDArray to string"); | 250 error ("invalid conversion of charNDArray to string"); |
251 | 251 |
252 return retval; | 252 return retval; |
253 } | 253 } |
254 | 254 |
255 std::string | |
256 octave_char_matrix_str::string_value (const char *fmt, va_list args) const | |
257 { | |
258 std::string retval; | |
259 | |
260 if (! fmt) | |
261 return string_value (); | |
262 | |
263 bool conversion_error = false; | |
264 | |
265 if (matrix.ndims () == 2) | |
266 { | |
267 charMatrix chm (matrix); | |
268 | |
269 try | |
270 { | |
271 retval = chm.row_as_string (0); // FIXME? | |
272 } | |
273 catch (const octave_execution_exception&) | |
274 { | |
275 conversion_error = true; | |
276 } | |
277 } | |
278 else | |
279 conversion_error = true; | |
280 | |
281 if (conversion_error) | |
282 verror (fmt, args); | |
283 | |
284 return retval; | |
285 } | |
286 | |
255 Array<std::string> | 287 Array<std::string> |
256 octave_char_matrix_str::cellstr_value (void) const | 288 octave_char_matrix_str::cellstr_value (void) const |
257 { | 289 { |
258 Array<std::string> retval; | 290 Array<std::string> retval; |
259 | 291 |