|
Boost Users : |
Subject: Re: [Boost-users] [serialization] unwinding "stack" of objectduringloading
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-11-13 23:29:10
Igor R wrote:
>> Note that the the serialization library does throw exceptions on
>> failure.
>> These exceptions are documented in the manual. You should be able to
>> catch these exceptions in your own save/load functions. I can't say
>> to what extent one might be able to recover. Implementing this would
>> likely require more elaborat save/load functions.
>
>
> Yes, I know it throws exceptions that I can catch, but the question is
> how the library would behave in the following case.
> Consider the following xml small item:
> <item class_id="2" tracking_level="0" version="1">
> <px class_id="3" tracking_level="1" version="0" object_id="_0">
> <info_ class_id="8" tracking_level="0" version="0">
> <obj.token_>134959408</obj.token_>
> <obj.name_>somename</obj.name_>
> </info_>
> <connectionProps_ class_id="12" tracking_level="0" version="0">
> <obj.currPeer_>0</obj.currPeer_>
> <obj.encrypt_>0</obj.encrypt_>
> <obj.key_>12345</obj.key_>
> </connectionProps_>
> </px>
> </item>
>
> If reading <info_> sub-item throws in the middle, will the stream
> remain in a consistent state, i.e. will it skip until after </info>
Well it certainly won't do that. Basically, exceptions are thrown
only if there's no other option. I would expect the underlying
text stream to be in an undefined state.
> (or some outer closing tag)? If not, can I take some measures to force
> this?
you could try, but I wouldn't expect such measures to be reliable.
The real question is what kind of exception could occur which would
permit you to read more of the stream. if you can still read the stream
then it's likely to be a programming error - e.g. save/load don't match
and to my mind trying to recover from these situation either hides an
error or compounds the damage.
Robert Ramey
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
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