Mercurial > hg > octave-nkf
diff src/ov-struct.cc @ 9784:f786dca09f79
implement nfields
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 08 Nov 2009 21:25:46 +0100 |
parents | 8e5009334661 |
children | 1fac51c5f83f |
line wrap: on
line diff
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -922,6 +922,26 @@ return retval; } +DEFUN (nfields, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} nfields (@var{s})\n\ +Return the number of fields of the structure @var{s}.\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin == 1 && args(0).is_map ()) + { + retval = static_cast<double> (args(0).nfields ()); + } + else + print_usage (); + + return retval; +} + // Check that the dimensions of the input arguments are correct. static bool