Page 1 of 1

New way of reading and writing .minf files

Posted: Thu Nov 17, 2005 1:55 pm
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

Posted: Fri Nov 18, 2005 10:52 am
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

Posted: Fri Nov 18, 2005 2:37 pm
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

Posted: Fri Nov 18, 2005 4:08 pm
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

Posted: Fri Nov 18, 2005 5:38 pm
by jdlemare
I am using setProperty and it's working fine

Thank you very much !

jd