Boost logo

Boost Users :

Subject: [Boost-users] can serialize multi-class into a single Archive?
From: pengdw (david8300_at_[hidden])
Date: 2010-01-11 07:29:25


I want to serialize multiple class into a single file.

that's:

  class object {};

  ofstream ofs;
  ofs.open("data.txt");

  boost::archive::text_oarchive oa(ofs);

  while (get_next_object(object_t obj)) {
    oa << obj;
  }

It is ok when I use text_iarchive to read back these objects.

Now I want to append some objects to a Archive, I need to reopen the
data file "data.txt" with (ios_base::app | ios_base::out), and serialize
some object to the new-opend Archive.
then when I use text_iarchive to load, I got error messages.

I checked some manuals, and use boost::archive::no_header to skip the
archive headers like "22 serialization::archive" when appending objects.
but still I got error messages when loading.

can anyone tell me how to store and append objects to a single Archive,
and load correctly.

tks.


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