Hi everyone,
I am trying to read properties from cpf file, Simple data types like int work just fine but for std::vector<std::string> I get runtime error. Here is what I do:
PropertyBag from_file; std::string filename="config_file.cpf"; marsh::PropertyDemarshaller demarshaller(filename); demarshaller.deserialize(from_file); /// Read the properties from PropertyBag /// a_number Property< int > a_number_p; a_number_p = from_file.getProperty("aNumber"); a_number = a_number_p.get(); /// a_vector Property<std::vector<std::string> > a_vector_p; a_vector_p = from_file.getProperty("aVector"); a_vector = a_vector_p.get(); // this line produces the error
Error: deployer-gnulinux: /usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T* boost::intrusive_ptr<T>::operator->() const [with T = RTT::internal::AssignableDataSource<std::vector<std::basic_string<char> > >]: Assertion `px != 0' failed. Aborted (core dumped)
Any help and hint is much appreciated,
Bests, Mohamad
Reading data from cpf file for std::vector<std::string> doesn't
Hi everyone,
I have written some properties to cpf file , using the marshaller.
But when I try to read them back from file, I get runtime error. Simple
data types like int work just fine but for std::vector<std::string> I have
problem.
Here is what I do:
PropertyBag from_file;
a_vector_p = from_file.getProperty("aVector");
std::string filename="config_file.cpf";
marsh::PropertyDemarshaller demarshaller(filename);
demarshaller.deserialize(from_file);
/// Read the properties from PropertyBag
/// a_number
Property< int > a_number_p;
a_number_p = from_file.getProperty("aNumber");
a_number = a_number_p.get(); // this works
/// a_vector
Property<std::vector
a_vector = a_vector_p.get(); // this line produces the error
Error: deployer-gnulinux:
>]: Assertion `px != 0' failed. Aborted (core dumped)
/usr/include/boost/smart_ptr/intrusive_ptr.hpp:166: T*
boost::intrusive_ptr<T>::operator->() const [with T =
RTT::internal::AssignableDataSource<std::vector
Any help and hint is much appreciated,
Bests, Mohamad
Re: Reading data from cpf file for std::vector<std::string>
How have you formatted that property in your .cpf file?
For
std::vector<std::string>
you should use:Federico
Re: Reading data from cpf file for std::vector<std::string>
Hi Federico,
I have generated the cpf file with the marshaller, so the format should be correct. In case of std::vector<std::string>, the format is the same as you stated.
Bests, Mohamad
code with correct format
Sorry for the formatting, This is the code: