use a stringstream instead of a file stream.
#include <sstream> // or maybe #include <stringstream> - I forget.
Robert Ramey
"Anil Krishna" wrote in message news:d27926bf0608041513i6049b7cas247dd30d70d40601@mail.gmail.com...
Hi All,
Currently I am using the boost serialization library to serialize and the following structure:
typedef list<int> testList;
typedef testList::iterator lIter;
typedef map testMap;
typedef testMap::iterator tIter;
testMap _tMap;
template<class Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & _tMap;
}
int main()
{
test_map tm;
ofstream ofs("map_details.txt");
tm.fillMap();
//tm.display();
boost::archive::binary_oarchive oa(ofs);
oa << (const test_map)tm;
ofs.close();
test_map newTm;
ifstream ifs("map_details.txt", std::ios::binary);
boost::archive::binary_iarchive ia(ifs);
ia >> newTm;
ifs.close();
newTm.display();
}
In the above code, I am saving the map to a binary file and retrieving it from the file. Instead of that I would want to serialize the data into a char buffer and restore it from the buffer.
This is useful for message communication, where I would like to send the map as a message from one process to another using socket communications.
Can you any one let me know, how this can be done in boost?
Regards,
Anil
------------------------------------------------------------------------------
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users