1

In the example of Boost code of serialization bus schedule in its output file "demofile.txt" the first line is:

"22 serialization::archive 16 0 0 6 0 0 0 0 0 6 24 4"

what is this? Dll version number? Can we suppress this and store only the data itsself?

sehe
  • 374,641
  • 47
  • 450
  • 633
chans
  • 109
  • 1
  • 9

1 Answers1

1

That's not a Dll version. It's the archive header.

Suppress it by using archive flags it:

void save_schedule(const bus_schedule &s, const char * filename){
    // make an archive
    std::ofstream ofs(filename);
    boost::archive::text_oarchive oa(ofs, boost::archive::archive_flags::no_header);
    oa << s;
}

And remember to do the same on restoring, of course!

void restore_schedule(bus_schedule &s, const char * filename) {
    // open the archive
    std::ifstream ifs(filename);
    boost::archive::text_iarchive ia(ifs, boost::archive::archive_flags::no_header);

    // restore the schedule from the archive
    ia >> s;
}

See also

sehe
  • 374,641
  • 47
  • 450
  • 633