
Thank you so much for your example!
I would like to study it, but I cannot compile it actually.
I'm using gcc-4.5.2 on an Ubuntu Linux 64 bits with boost-1.42.0.
At line 127 (boost::archive::text_oarchive toa (toafile);), it gives me
the following error:
g++ -Wall -pedantic -g -O3 -DDEBUG -march=native -std=c++0x -o p1 p1.cxx
/tmp/cc5wHYcd.o: In function `text_oarchive':
/usr/include/boost/archive/text_oarchive.hpp:92: undefined reference to
`boost::archive::text_oarchive_implboost::archive::text_oarchive::text_oarchive_impl(std::basic_ostream
Hi Alessandro,
Attached is a sample program that illustrates how to (de)serialize your vector of lists of pointers to something !!! It should address your needs to start with Boost/Serialization. It runs on my Linux box with gcc 4.5. I hope it will work for you.
Also note that the use of plain pointers (MyObj *) in a container can be tricky unless you can make sure you run suitable memory deallocation code. Of course, it depends on your application but maybe investigating the used of shared pointer (boost::shared_ptr) could be of some interest for you.
Hope it'd help
regards
frc --
On 14/06/2011 10:02, Alessandro Candini wrote: Hi all. I have a program, simplified as follows:
|#include<vector> #include<list> #include<fstream>
using namespace std;
class MyObj { int val;
public: MyObj(int v){ val = v; }; ~MyObj(){}; };
int main (int argc,char *argv[]) { int i, j; vector< list
> layers; for(i=0; i<5; i++) { list
tmp; for(j=0; j<10; j++) tmp.push_back(new MyObj(j) );
layers.push_back(tmp); } return 0; }|
I need to serialize/deserialize the object "layers".
Can anyone give me an example on how to do this with boost serialization library?
Thanks in advance.
-- Alessandro Candini
MEEO S.r.l. Via Saragat 9 I-44122 Ferrara, Italy Tel: +39 0532 1861501 Fax: +39 0532 1861637 http://www.meeo.it
======================================== "ATTENZIONE:le informazioni contenute in questo messaggio sono da considerarsi confidenziali ed il loro utilizzoè riservato unicamente al destinatario sopra indicato. Chi dovesse ricevere questo messaggio per erroreè tenuto ad informare il mittente ed a rimuoverlo definitivamente da ogni supporto elettronico o cartaceo."
"WARNING:This message contains confidential and/or proprietary information which may be subject to privilege or immunity and which is intended for use of its addressee only. Should you receive this message in error, you are kindly requested to inform the sender and to definitively remove it from any paper or electronic format."
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Alessandro Candini MEEO S.r.l. Via Saragat 9 I-44122 Ferrara, Italy Tel: +39 0532 1861501 Fax: +39 0532 1861637 http://www.meeo.it ======================================== "ATTENZIONE:le informazioni contenute in questo messaggio sono da considerarsi confidenziali ed il loro utilizzo è riservato unicamente al destinatario sopra indicato. Chi dovesse ricevere questo messaggio per errore è tenuto ad informare il mittente ed a rimuoverlo definitivamente da ogni supporto elettronico o cartaceo." "WARNING:This message contains confidential and/or proprietary information which may be subject to privilege or immunity and which is intended for use of its addressee only. Should you receive this message in error, you are kindly requested to inform the sender and to definitively remove it from any paper or electronic format."