comparison 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
comparison
equal deleted inserted replaced
9783:119d97db51f0 9784:f786dca09f79
920 print_usage (); 920 print_usage ();
921 921
922 return retval; 922 return retval;
923 } 923 }
924 924
925 DEFUN (nfields, args, ,
926 "-*- texinfo -*-\n\
927 @deftypefn {Built-in Function} {} nfields (@var{s})\n\
928 Return the number of fields of the structure @var{s}.\n\
929 @end deftypefn")
930 {
931 octave_value retval;
932
933 int nargin = args.length ();
934
935 if (nargin == 1 && args(0).is_map ())
936 {
937 retval = static_cast<double> (args(0).nfields ());
938 }
939 else
940 print_usage ();
941
942 return retval;
943 }
944
925 // Check that the dimensions of the input arguments are correct. 945 // Check that the dimensions of the input arguments are correct.
926 946
927 static bool 947 static bool
928 cell2struct_check_args (const dim_vector& c_dv, const dim_vector& f_dv, 948 cell2struct_check_args (const dim_vector& c_dv, const dim_vector& f_dv,
929 bool is_cell, int dim) 949 bool is_cell, int dim)