comparison libinterp/octave-value/ov-base.cc @ 20618:e5986cba4ca8

new octave_value::cell_value method with optional error message * ov.h, ov.cc (octave_value::cell_value): New method. * ov-base.h, ov-base.cc (octave_base_value::cell_value): New default method. * ov-cell.h, ov-cell.cc (octave_cell::cell_value): New method.
author John W. Eaton <jwe@octave.org>
date Fri, 09 Oct 2015 14:41:49 -0400
parents 40ed9b46a800
children
comparison
equal deleted inserted replaced
20617:ba2b07c13913 20618:e5986cba4ca8
533 octave_base_value::cell_value () const 533 octave_base_value::cell_value () const
534 { 534 {
535 Cell retval; 535 Cell retval;
536 gripe_wrong_type_arg ("octave_base_value::cell_value()", type_name ()); 536 gripe_wrong_type_arg ("octave_base_value::cell_value()", type_name ());
537 return retval; 537 return retval;
538 }
539
540 Cell
541 octave_base_value::cell_value (const char *fmt, va_list args) const
542 {
543 // Note that this method does not need to be particularly efficient
544 // since it is already an error to end up here.
545
546 // FIXME: do we want both the wrong-type-argument error and any custom
547 // error message, or just the custom error message, or should that
548 // behavior be optional in some way?
549
550 try
551 {
552 std::string tn = type_name ();
553
554 error ("wrong type argument '%s'\n", tn.c_str ());
555 }
556 catch (const octave_execution_exception&)
557 {
558 if (fmt)
559 verror (fmt, args);
560
561 throw;
562 }
563
564 return Cell ();
538 } 565 }
539 566
540 Matrix 567 Matrix
541 octave_base_value::matrix_value (bool) const 568 octave_base_value::matrix_value (bool) const
542 { 569 {