[serialization] of nested stl containers
I have the following code: #include <list> #include <utility> #include <vector> #include <string> #include <fstream> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/access.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/base_object.hpp> using namespace std; int main() { list< pair<string, string> > stlStr; pair<string, string> par1("aaa", "bbb"); stlStr.push_back(make_pair("key", par1)); std::ofstream ofs("filename"); { boost::archive::text_oarchive serial(ofs); serial << stlStr; } std::ifstream ifs("filename"); boost::archive::text_iarchive serial2(ifs); list<pair<string, string> > lst; serial2 >> lst; return 0; } that throw the following compilation error: error: 'class std::list<std::pair<std::basic_string<char>, std::basic_string<char> > >' has no member named 'serialize'. I'd like to know if I have to manually implement the serialization of this nested list. Because for example I haven't problems with maps that have inside a pair : map<string, pair<string, string> >. Thanks !
There is an error in the code above: the code is this: int main() { list< pair<string, string> > stlStr; pair<string, string> par1("aaa", "bbb"); stlStr.push_back(par1); std::ofstream ofs("filename"); { boost::archive::text_oarchive serial(ofs); serial << stlStr; } std::ifstream ifs("filename"); boost::archive::text_iarchive serial2(ifs); list<pair<string, string> > lst; serial2 >> lst; return 0; } On Wed, Mar 26, 2014 at 3:44 PM, Pablo Madoery <madoerypablo@gmail.com>wrote:
I have the following code:
#include <list> #include <utility> #include <vector> #include <string> #include <fstream> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/access.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/base_object.hpp>
using namespace std;
int main() {
list< pair<string, string> > stlStr; pair<string, string> par1("aaa", "bbb"); stlStr.push_back(make_pair("key", par1));
std::ofstream ofs("filename"); { boost::archive::text_oarchive serial(ofs); serial << stlStr; }
std::ifstream ifs("filename"); boost::archive::text_iarchive serial2(ifs); list<pair<string, string> > lst; serial2 >> lst;
return 0; }
that throw the following compilation error: error: 'class std::list<std::pair<std::basic_string<char>, std::basic_string<char> > >' has no member named 'serialize'.
I'd like to know if I have to manually implement the serialization of this nested list. Because for example I haven't problems with maps that have inside a pair : map<string, pair<string, string> >.
Thanks !
AMDG On 03/26/2014 11:44 AM, Pablo Madoery wrote:
I have the following code:
<snip> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/access.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/base_object.hpp>
<snip>
that throw the following compilation error: error: 'class std::list<std::pair<std::basic_string<char>, std::basic_string<char> > >' has no member named 'serialize'.
I'd guess that you need a #include <boost/serialization/list.hpp> In Christ, Steven Watanabe
On 26/03/2014 19:44, Pablo Madoery wrote:
(...)
I'd like to know if I have to manually implement the serialization of this nested list. Because for example I haven't problems with maps that have inside a pair : map<string, pair<string, string> >.
Hi Pablo, You probably just need to #include <boost/serialization/list.hpp> Cheers, MAT.
yes ! that is the problem. I forget to include <boost/serialization/list.hpp>. Thank you ! On Thu, Mar 27, 2014 at 2:42 AM, Mathieu Champlon <m.champlon@free.fr>wrote:
On 26/03/2014 19:44, Pablo Madoery wrote:
(...)
I'd like to know if I have to manually implement the serialization of this nested list. Because for example I haven't problems with maps that have inside a pair : map<string, pair<string, string> >.
Hi Pablo,
You probably just need to #include <boost/serialization/list.hpp>
Cheers, MAT.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Mathieu Champlon
-
Pablo Madoery
-
Steven Watanabe