|
Boost Users : |
Subject: Re: [Boost-users] [Serialization] Postpone saving
From: BlueAngel (lists_at_[hidden])
Date: 2010-07-18 11:01:02
Il 18/07/2010 17:45, Robert Ramey ha scritto:
> Mailing Lists Controller wrote:
>
>> Hi,
>> I'm working with the Serialization library and in detail with the xml
>> archives. In my code I have to serialize a lot of classes and I wish
>> to save in the xml file only when I've done with the serialization of
>> all clasess,
>>
> The best way to do this would be to use your own stream type.
> a) make a new filebuf which just saves all it's data until it closes.
> b) make a new stream type which uses your new file buf
> c) use your new stream type when you create a serialization archive
>
> Another way- not as good be perhaps simpler
> a) serialize to a stringstream
> b) when done, writhe the string stream to a file.
>
>
>> also I would like to have more control when the
>> Serialization saves the file (do it raise exceptions when it save
>> files? Which ones?).
>>
> See the documentaton for list of exceptions which might be invoked.
>
>
>> As far as I read from the tutorials when I use the operator<< in the
>> xml_archive it save directly to the files.
>>
> It actually writes to a stream, the stream writes to filebuf, filebuf writes
> to files.
>
>
>> In my test I've seen that
>> the archive have no problem to save many classes to the same archive
>> however as I've wrote I would like to have more control (at least to
>> know which errors appear during writing).
>>
>
>> Is it possible?
>>
> more than possible. It's easy. OK it does require careful study of
> C++ streams and how to use them - but that's useful anyway.
>
> Robert Ramey
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
Thank you for your reply.
I could have thought of it myself to use the stringbuffer... good idea.
By the way, I've sent you a mail about a missing header file in the
tutorial with the xml in the boost website but I received no reply.
If you look at the website there isn't the link for the demo_xml.hpp file.
Greetings
R.R.
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