[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
newbie question on using octave structures in external C++ functions
From: |
Jim H |
Subject: |
newbie question on using octave structures in external C++ functions |
Date: |
Mon, 24 Sep 2007 15:25:09 -0700 (PDT) |
Hi,
I would like to know how to determine the data type of a field in an octave
data structure passed to a c++ function. The manual and wiki provide some
good examples, but my problem is to pass in a structure and assign values to
c++ variables used by the external function. To assign those values, it
seems I need to know if the field is an integer, string, etc. Here's a
brief example where I could use some help.
#include <octave/oct.h>
#include <octave/ov-struct.h>
int aval;
DEFUN_DLD(shombs_defs,args, , "show mbs defaults")
{
int nargin = args.length ();
octave_value_list retval;
if (nargin != 2)
print_usage ();
else
{
Octave_map arg0 = args(0).map_value ();
std::string arg1 = args(1).string_value ();
for (Octave_map::iterator p0 = arg0.begin() ;
p0 != arg0.end(); p0++ ) {
// print keys and values
std::cout << " key =>" << arg0.key( p0 ) << std::endl;
octave_value( arg0.contents( p0 ) ).print( std::cout ,
false );
// how do I do the following?
if ( arg0.key(p0) IS "foo" AND arg0.contents(p0) IS
INTEGER ) {
aval = arg0.contents(p0);
}
...
Thanks in advance for hints on this, and if there is good place to read
about c++-callable methods that apply to structures, please direct me there.
Jim
--
View this message in context:
http://www.nabble.com/newbie-question-on-using-octave-structures-in-external-C%2B%2B-functions-tf4512192.html#a12869688
Sent from the Octave - General mailing list archive at Nabble.com.
- newbie question on using octave structures in external C++ functions,
Jim H <=