New way of reading and writing .minf files

AIMS library and commands usage

Moderators: denghien, riviere

Post Reply
jdlemare
Posts: 3
Joined: Thu Nov 17, 2005 11:00 am

New way of reading and writing .minf files

Post by jdlemare »

Hello !

I have problems with Reading and Writing of .minf

When writing a header using a PythonHeader and filling a vector< Object > , I get the following error message:

terminate called after throwing an instance of 'std::invalid_argument'
what(): wrong type


I used to include #include <cartobase/attributed/pythonreader.h> to use the class PythonHeader and a vector< Object > which seems to be deprecated.

What is the new way to read and write .minf files ?




Thanks

JD
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi,
I don't understand exactly where the problem occurs. PythonHeader has changed internally and may be replaced by something else in the future, but right now it should work the way it did. How do you use it ? Which function or method does produce the exception ?
To put a vector<Object> in a header, just do:

Code: Select all

PythonHeader header;
vector<Object> vec;
vec.push_back( Object::value( 15.F ) ); // for instance
header.setProperty( "toto", vec );
You can use the header readMinf() and writeMinf() methods to read or save it.
Doesn't it work ?

Denis
jdlemare
Posts: 3
Joined: Thu Nov 17, 2005 11:00 am

Post by jdlemare »

I think the problem occured because, instead of

Code: Select all

header.setProperty( "toto", vec );
I was using the following instruction:

Code: Select all

header[ "toto" ] = vec
which was working fine before I changed my version of aims library

Actually, I am using this instruction:

Code: Select all

header.setAttribute( "toto", vec );
What is th edifference ?

thanks

jd
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Yes I see: the [] operator has been deprecated in the last version, and the setAttribute() method has been replaced by setProperty(). There are some compatibility macros in cartobase which can enable or disable the old API, but for new programs, please use setProperty().
Denis
jdlemare
Posts: 3
Joined: Thu Nov 17, 2005 11:00 am

Post by jdlemare »

I am using setProperty and it's working fine

Thank you very much !

jd
Post Reply