Mercurial > hg > octave-nkf
changeset 20794: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 | ba2b07c13913 |
children | eef93a493ce3 |
files | libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-base.h libinterp/octave-value/ov-cell.h libinterp/octave-value/ov.cc libinterp/octave-value/ov.h |
diffstat | 5 files changed, 42 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-base.cc +++ b/libinterp/octave-value/ov-base.cc @@ -537,6 +537,33 @@ return retval; } +Cell +octave_base_value::cell_value (const char *fmt, va_list args) const +{ + // Note that this method does not need to be particularly efficient + // since it is already an error to end up here. + + // FIXME: do we want both the wrong-type-argument error and any custom + // error message, or just the custom error message, or should that + // behavior be optional in some way? + + try + { + std::string tn = type_name (); + + error ("wrong type argument '%s'\n", tn.c_str ()); + } + catch (const octave_execution_exception&) + { + if (fmt) + verror (fmt, args); + + throw; + } + + return Cell (); +} + Matrix octave_base_value::matrix_value (bool) const {
--- a/libinterp/octave-value/ov-base.h +++ b/libinterp/octave-value/ov-base.h @@ -481,6 +481,8 @@ virtual Cell cell_value (void) const; + virtual Cell cell_value (const char *fmt, va_list args) const; + virtual Matrix matrix_value (bool = false) const; virtual FloatMatrix float_matrix_value (bool = false) const;
--- a/libinterp/octave-value/ov-cell.h +++ b/libinterp/octave-value/ov-cell.h @@ -135,6 +135,8 @@ Cell cell_value (void) const { return matrix; } + Cell cell_value (const char *, va_list) const { return matrix; } + octave_value_list list_value (void) const; octave_value convert_to_str_internal (bool pad, bool, char type) const
--- a/libinterp/octave-value/ov.cc +++ b/libinterp/octave-value/ov.cc @@ -1550,6 +1550,15 @@ return rep->cell_value (); } +Cell +octave_value::cell_value (const char *fmt, ...) const +{ + va_list args; + va_start (args,fmt); + return rep->cell_value (fmt, args); + va_end (args); +} + // Define the idx_type_value function here instead of in ov.h to avoid // needing definitions for the SIZEOF_X macros in ov.h.