view examples/structdemo.cc @ 14354:55bb8c902a4d

maint: Remove deprecated functions from dev branch for next (3.8) release. * NEWS: Update list of deprecated functions which had duplicates and missing functions * deprecated/module.mk: Remove deprecated m-files from build system. * autocor.m, autocov.m, betai.m, cellidx.m, clg.m, cquad.m, dispatch.m, fstat.m, gammai.m, glpkmex.m, intwarning.m, is_duplicate_entry.m, is_global.m, krylovb.m, perror.m, replot.m, saveimage.m, strerror.m, values.m, weibcdf.m, weibinv.m, weibpdf.m, weibrnd.m: Remove deprecated functions from Mercurial.
author Rik <octave@nomad.inbox5.com>
date Thu, 09 Feb 2012 13:16:39 -0800
parents db1f49eaba6b
children be41c30bcb44
line wrap: on
line source

#include <octave/oct.h>
#include <octave/ov-struct.h>

DEFUN_DLD (structdemo, args, , "Struct demo.")
{
  int nargin = args.length ();
  octave_value retval;

  if (args.length () == 2)
    {
      octave_scalar_map arg0 = args(0).scalar_map_value ();

      if (! error_state)
        {
          std::string arg1 = args(1).string_value ();

          if (! error_state)
            {
              octave_value tmp = arg0.contents (arg1);

              if (tmp.is_defined ())
                {
                  octave_scalar_map st;

                  st.assign ("selected", tmp);

                  retval = octave_value (st);
                }
              else
                error ("sruct does not contain field named '%s'\n",
                       arg1.c_str ());
            }
          else
            error ("expecting character string as second argument");
        }
      else
        error ("expecting struct as first argument");
    }
  else
    print_usage ();

  return retval;
}