Boost logo

Boost Users :

From: Anil Krishna (akrishna876_at_[hidden])
Date: 2006-08-04 18:13:15


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<int, testList> 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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net