[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Placing structs in cell arrays
From: |
John W. Eaton |
Subject: |
Placing structs in cell arrays |
Date: |
Tue, 13 Feb 2007 17:59:53 -0500 |
On 12-Feb-2007, John Swensen wrote:
| I am having trouble placing a struct/Octave_map in a cell array in C++.
| Here is a snippet of my code.
|
| Matrix handleVec = args(0).matrix_value();
| Cell retval(num_handles);
| for( int i = 0 ; i < num_handles ; i++ )
| {
| handlePtr = handle::getHandle( (int)handleVec(i) );
| Octave_map retvalItem = handlePtr->generateStruct();
| octave_stdout << "BEFORE" << endl;
| retval(i) == octave_value(retvalItem);
| octave_stdout << "AFTER" << endl;
| }
I don't think I understand precisely what it is you are trying to do,
but if you are trying to return a cell array containing a structure as
one of its elements, then maybe the following example will help. It
works for me.
#include <octave/oct.h>
#include <octave/oct-map.h>
DEFUN_DLD (foobar, , , "")
{
octave_value retval;
Octave_map m;
m.assign ("a", 1.0);
m.assign ("b", 2.0);
m.assign ("c", 3.0);
Cell tmp (10, 1);
tmp(0) = m;
retval = tmp;
return retval;
}
jwe