Boost logo

Boost :

Subject: [boost] [serialization] Limited Forward Compatibility
From: Dmitry Shesterkin (dfb_at_[hidden])
Date: 2013-02-06 18:27:01


Hello,

We use xml serialization for saving and loading several types of metadata
and we have to support possibility of reading new versions of files with
old versions of soft. Boost::serialization is very good at backward
compatibility but does not provide anything with opposite problem.
So, This patch introduces new flag boost::archive::skip_unknown_tail_tags.
When this flag is set and basic_xml_iarchive is faced with unknown tags at
the end of element it will skip them (include nested).

E.g., the first version of some file was:
<Test class_id="0" tracking_level="0" version="0">
     <a>31</a>
     <t2 class_id="1" tracking_level="0" version="0">
         <a>11</a>
         <b>12</b>
     </t2>
     <b>32</b>
</Test>

After a while, the second version could be:
<Test class_id="0" tracking_level="0" version="0">
     <a>31</a>
     <t2 class_id="1" tracking_level="0" version="1">
         <a>11</a>
         <b>12</b>
         <c>13</c>
         <d>14</d>
         <t1 class_id="2" tracking_level="0" version="0">
             <a>1</a>
             <b>2</b>
         </t1>
     </t2>
     <b>32</b>
</Test>
Therefore, if the first version software set skip_unknown_tail_tags it can
read second version of file (if does not set then exception will be
thrown).

See patch in attachments for details.
Could it be useful, and should it be merged in trunk?

Thanks in advance,
Dmitry



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk