Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] appending to an archive
From: Pfligersdorffer, Christian (Christian.Pfligersdorffer_at_[hidden])
Date: 2009-05-25 05:01:20

Hello Hurcan,

an archive writes a preamble when it's created and possibly an end-tag
when destroyed (xml). Your options are: either keep the archive (on the
heap) instead of creating/destroying it, or organize your stream into
multiple archives. We did it the latter way and it works fine.

I wonder why you would need boost serialization at all if all you do is
appending a string to a file. There are simpler ways to do that :-)

Good luck,

Christian Pfligersdorffer
Software Engineering
Hurcan wrote:
> I am trying to append one or more records to the existing
> archive file,  using something like this;
> void Logger::save(const std::string& fileName) {
>     assert(fileName != "logger.dmp");
>     bp::time_duration endRecordTime  = getCurrentTime();
>     ofs.flush();
>     path dst = complete(path(fileName, native));
>     path src = complete(path("logger.dmp", native));     remove(dst);
>     copy_file(src, dst);
>     ofstream saveFile(dst,std::ios::app);
>     ArchiveType archive(saveFile,boost::archive::no_header);
>     *mArchive << endRecordTime
> }
> although i specify no_header flag, it inserts a '0' as a
> preamble, how can i turn it off? have you guys ever needed to
> use serialization like this? what was your solution
> Thanks in advance
> Hurcan

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at