Sohail Somani | 1 Jun 05:24 2009
Picon

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

Robert Ramey wrote:
> Sohail Somani wrote:
>> Still interested in forward compatibility, if you are inclined to
>> elaborate a little.
> 
> Here we go.  Basically, backward compatibility is handled by code
> that looks like the following:
> 
> template<class Archive>
> void save(Archive &ar, const unsigned int version){
>     ar << original_stuff
>     ar << stuff_added_version_3;
>     ar << stuff_added_version_4;
> }
> 
> template<class Archive>
> void load(Archive &ar, const unsigned int version){
>     ar >> original_stuff;
>     if(version > 3)
>         ar >> stuff_added_version_3;
>     if(version > 4)
>         ar >> stuff_added_version_4;
>     ...
> }
> 
> So what we need to do is replace the save above with:
> 
> template<class Archive>
> void save(Archive &ar, const unsigned int version) const {
>     ar << original_stuff
(Continue reading)

Robert Ramey | 1 Jun 06:46 2009

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

Sohail Somani wrote:
> Robert Ramey wrote:
>> Sohail Somani wrote:
>>> Still interested in forward compatibility, if you are inclined to
>>> elaborate a little.
>>
>> Here we go.  Basically, backward compatibility is handled by code
>> that looks like the following:
>>
>> template<class Archive>
>> void save(Archive &ar, const unsigned int version){
>>     ar << original_stuff
>>     ar << stuff_added_version_3;
>>     ar << stuff_added_version_4;
>> }
>>
>> template<class Archive>
>> void load(Archive &ar, const unsigned int version){
>>     ar >> original_stuff;
>>     if(version > 3)
>>         ar >> stuff_added_version_3;
>>     if(version > 4)
>>         ar >> stuff_added_version_4;
>>     ...
>> }
>>
>> So what we need to do is replace the save above with:
>>
>> template<class Archive>
>> void save(Archive &ar, const unsigned int version) const {
(Continue reading)

Steven Watanabe | 1 Jun 05:54 2009
Picon

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

AMDG

Robert Ramey wrote:
> Sohail Somani wrote:
>   
>> Just typing out loud: Forward compatibility is the ability to load an
>> archive with a version of 4 into an application with a version of 3.
>>     
>
> To me forward compatability is he ability to create a version 3 archive
> with a version 4 program.  Hmmm - now that I read that, it doesn't
> look right. I guess that should be called "complete" backward
> compatibility.  I don't see how it is possible while writing version
> 3 progam to know what version 4 is going to save.
>   

It would be possible in special cases.  For example, the
version 4 archive could add information that the version
3 program knows to skip somehow.

In Christ,
Steven Watanabe
Sohail Somani | 1 Jun 06:25 2009
Picon

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

Steven Watanabe wrote:
> AMDG
> 
> Robert Ramey wrote:
>> Sohail Somani wrote:
>>  
>>> Just typing out loud: Forward compatibility is the ability to load an
>>> archive with a version of 4 into an application with a version of 3.
>>>     
>>
>> To me forward compatability is he ability to create a version 3 archive
>> with a version 4 program.  Hmmm - now that I read that, it doesn't
>> look right. I guess that should be called "complete" backward
>> compatibility.  I don't see how it is possible while writing version
>> 3 progam to know what version 4 is going to save.
>>   
> 
> It would be possible in special cases.  For example, the
> version 4 archive could add information that the version
> 3 program knows to skip somehow.

Right, so one totally naive way the library could do it would be to
inject a marker after every serialization call. This way, the version 3
application could simply search for the marker after every serialization
call in order to set up the next serialization call.

Basically, I am saying that version 4 of the app writes out:

foo 1 2 3 |END_MARKER| foo 4 5 6 |END_MARKER|

(Continue reading)

Robert Ramey | 1 Jun 07:58 2009

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

Sohail Somani wrote:
> Steven Watanabe wrote:
>> AMDG
>>
>> Robert Ramey wrote:
>>> Sohail Somani wrote:
>>>
>>>> Just typing out loud: Forward compatibility is the ability to load
>>>> an archive with a version of 4 into an application with a version
>>>> of 3.
>>>>
>>>
>>> To me forward compatability is he ability to create a version 3
>>> archive with a version 4 program.  Hmmm - now that I read that, it
>>> doesn't look right. I guess that should be called "complete"
>>> backward compatibility.  I don't see how it is possible while
>>> writing version 3 progam to know what version 4 is going to save.
>>>
>>
>> It would be possible in special cases.  For example, the
>> version 4 archive could add information that the version
>> 3 program knows to skip somehow.
>
> Right, so one totally naive way the library could do it would be to
> inject a marker after every serialization call. This way, the version
> 3 application could simply search for the marker after every
> serialization call in order to set up the next serialization call.
>
> Basically, I am saying that version 4 of the app writes out:
>
(Continue reading)

Sohail Somani | 1 Jun 07:28 2009
Picon

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

Robert Ramey wrote:
> Sohail Somani wrote:
>> Basically, I am saying that version 4 of the app writes out:
>>
>> foo 1 2 3 |END_MARKER| foo 4 5 6 |END_MARKER|
>>
>> And version 3, which can only read the first two ints, reads foo 1 2
>> and then resets the stream pointer (or whatever) to right after
>> |END_MARKER|.
>>
>> If that makes ANY sense, I will be happy.
> 
> You might be able to implement that for xml archives by
> deriving from xml_iarchive.

I never use xml archives but xml in general does have this property. I'd
like the solution to apply to all archives though.

--

-- 
Sohail Somani
http://uint32t.blogspot.com
Sohail Somani | 1 Jun 06:26 2009
Picon

Re: Boost Serialization + Forward compatibility [was Re: boost::serialization and PHP websites]

Robert Ramey wrote:
> Sohail Somani wrote:
>> Just typing out loud: Forward compatibility is the ability to load an
>> archive with a version of 4 into an application with a version of 3.
> 
> To me forward compatability is he ability to create a version 3 archive
> with a version 4 program.  Hmmm - now that I read that, it doesn't
> look right. I guess that should be called "complete" backward
> compatibility.  I don't see how it is possible while writing version
> 3 progam to know what version 4 is going to save.

See my reply to Steven W.

--

-- 
Sohail Somani
http://uint32t.blogspot.com

Gmane