Serialization Question

I'm looking into recording some data collected by one of my programs into rotating files. Something like so: ofstream ofs; boost::archive::text_oarchive oa(ofs) size_t rotate = 0; for(;;) { foo_t foo = get_some_foo(); if (!rotate) { ofs.open(some_clever_new_filename); // attach oa again? rotate = 1000; } oa << foo; if (!--rotate) { ofs.close(); // detach oa? } } Do I need to do anything to detach or re-attach the oarchive? Paul

Paul Dugas wrote:
I'm looking into recording some data collected by one of my programs into rotating files. Something like so:
ofstream ofs; boost::archive::text_oarchive oa(ofs) size_t rotate = 0; for(;;) { foo_t foo = get_some_foo(); if (!rotate) { ofs.open(some_clever_new_filename); // attach oa again? rotate = 1000; } oa << foo; if (!--rotate) { ofs.close(); // detach oa? } }
Do I need to do anything to detach or re-attach the oarchive?
Paul
can't re-use the same archive in tis case. Robert Ramey

On Tue, Jun 8, 2010 at 7:18 PM, Robert Ramey
Paul Dugas wrote:
I'm looking into recording some data collected by one of my programs into rotating files. Something like so:
ofstream ofs; boost::archive::text_oarchive oa(ofs) size_t rotate = 0; for(;;) { foo_t foo = get_some_foo(); if (!rotate) { ofs.open(some_clever_new_filename); // attach oa again? rotate = 1000; } oa << foo; if (!--rotate) { ofs.close(); // detach oa? } }
Do I need to do anything to detach or re-attach the oarchive?
Paul
can't re-use the same archive in tis case.
Robert Ramey
I'm looking through the code trying to find the ctor and dtor for the archives and can't find anything substantial yet; all empty dtors so far. Is the archive "light" enough to create/destroy with each iteration? Or do I need to new/delete it to keep it through the loop iterations? Paul
participants (2)
-
Paul Dugas
-
Robert Ramey