Mercurial > hg > octave-nkf
changeset 2420:449f35baba49
[project @ 1996-10-16 18:46:25 by jwe]
author | jwe |
---|---|
date | Wed, 16 Oct 1996 18:46:26 +0000 |
parents | 015cbef2b75f |
children | d64502c62840 |
files | src/ChangeLog src/data.cc src/ov-base.cc src/ov-base.h src/ov-struct.cc src/ov-struct.h src/ov.h |
diffstat | 7 files changed, 22 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ Wed Oct 16 12:00:11 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + * ov.h (octave_value::struct_elt_val): New optional arg, silent. + * ov-base.h, ov-base.cc, ov-struct.h, ov-struct.cc: Likewise, but + for the derived classes the arg is required. + + * data.cc (Fstruct_contains): Require arguments to be struct and + string, respectively. Call octave_value::struct_elt_val with + silent flag set. + * pt-mat.cc (tm_row_const::tm_row_const_rep::eval_error, tm_row_const::tm_row_const_rep::eval_warning): New functions. (tm_row_const::tm_row_const (const tree_matrix_row&): Use them to
--- a/src/data.cc +++ b/src/data.cc @@ -783,7 +783,8 @@ DEFUN (struct_contains, args, , "struct_contains (S, NAME)\n\ \n\ -return nonzero if S is a structure with element NAME") +Return nonzero if S is a structure with element NAME.\n\ +S must be a structure and NAME must be a string.") { octave_value_list retval; @@ -792,12 +793,15 @@ if (nargin == 2) { retval = 0.0; + if (args(0).is_map () && args(1).is_string ()) { string s = args(1).string_value (); - octave_value tmp = args(0).struct_elt_val (s); + octave_value tmp = args(0).struct_elt_val (s, true); retval = (double) tmp.is_defined (); } + else + print_usage ("struct_contains"); } else print_usage ("struct_contains");
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -63,7 +63,7 @@ } octave_value -octave_base_value::struct_elt_val (const string&) const +octave_base_value::struct_elt_val (const string&, bool) const { string nm = type_name (); error ("can't perform structure reference operations for %s type",
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -77,7 +77,7 @@ idx_vector index_vector (void) const; - octave_value struct_elt_val (const string& nm) const; + octave_value struct_elt_val (const string& nm, bool silent) const; octave_value& struct_elt_ref (const string& nm);
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -40,7 +40,7 @@ octave_value -octave_struct::struct_elt_val (const string& nm) const +octave_struct::struct_elt_val (const string& nm, bool silent) const { octave_value retval; @@ -48,7 +48,7 @@ if (idx) retval = map.contents (idx); - else + else if (! silent) error ("structure has no member `%s'", nm.c_str ()); return retval;
--- a/src/ov-struct.h +++ b/src/ov-struct.h @@ -71,7 +71,7 @@ void operator delete (void *p, size_t size); #endif - octave_value struct_elt_val (const string& nm) const; + octave_value struct_elt_val (const string& nm, bool silent) const; octave_value& struct_elt_ref (const string& nm);
--- a/src/ov.h +++ b/src/ov.h @@ -189,8 +189,9 @@ virtual idx_vector index_vector (void) const { return rep->index_vector (); } - virtual octave_value struct_elt_val (const string& nm) const - { return rep->struct_elt_val (nm); } + virtual octave_value + struct_elt_val (const string& nm, bool silent = false) const + { return rep->struct_elt_val (nm, silent); } virtual octave_value& struct_elt_ref (const string& nm) { return rep->struct_elt_ref (nm); }