TR: [Serialisation] error with xml_iarchive
Hello, I just recently began using the boost library, I want to write and read string to serialized objects with the function 'xml_oarchive' and 'xml_iarchive'. When I execute this code (with visual c++.net v. 7.1) : std::ofstream ofs("C:\\Save.xml"); const wchar_t * ptr; ptr=m_strEdit.GetBuffer(); assert(ofs.good()); boost::archive::xml_oarchive oa(ofs); oa.save(ptr); wchar_t str[512]; std::ifstream ifs("C:\\Save.xml"); boost::archive::xml_iarchive ia(ifs,0); ia.load(str); ifs.close(); the programm failed : Thanks and regards, Bruno POINAS ActiCM S.A. 122, rue du Rocher de Lorzier - Centr'Alp - 38430 - MOIRANS
I wouldn't expect this work. Try std::ofstream ofs("C:\\Save.xml"); const wchar_t * ptr; ptr=m_strEdit.GetBuffer(); assert(ofs.good()); boost::archive::xml_oarchive oa(ofs); oa.save(ptr); wchar_t *nptr; // note change here !!! std::ifstream ifs("C:\\Save.xml"); boost::archive::xml_iarchive ia(ifs,0); ia.load(nptr); ifs.close(); For an explanation of why this works (assuming it actually does) and why your original can't, read the documentation regarding the serialization of pointers. Robert Ramey "Bruno Poinas" <bpoinas@acticm.com> wrote in message news:D0D608FD34E14C4BA93A30AC162651E11F38F6@SERVEUR2003.acticm.com... Hello, I just recently began using the boost library, I want to write and read string to serialized objects with the function 'xml_oarchive' and 'xml_iarchive'. When I execute this code (with visual c++.net v. 7.1) : std::ofstream ofs("C:\\Save.xml"); const wchar_t * ptr; ptr=m_strEdit.GetBuffer(); assert(ofs.good()); boost::archive::xml_oarchive oa(ofs); oa.save(ptr); wchar_t str[512]; std::ifstream ifs("C:\\Save.xml"); boost::archive::xml_iarchive ia(ifs,0); ia.load(str); ifs.close(); the programm failed : Thanks and regards, Bruno POINAS ActiCM S.A. 122, rue du Rocher de Lorzier - Centr'Alp - 38430 - MOIRANS _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Bruno Poinas
-
Robert Ramey