Delete versions when increasing xml serialization

I just can't find a way to remove version tracking from xmlarchives accelerators.

Example

<Settings class_id="0" tracking_level="0" version="1">
 <px class_id="1" tracking_level="1" version="0" object_id="_0">
  <TestInt>3</TestInt>
  <Resolution class_id="2" tracking_level="0" version="0">
   <x>800</x>
   <y>600</y>
  </Resolution>
  <SomeStuff>0</SomeStuff>
 </px>
</Settings>

I want to enjoy class_id = "0" tracking_level = "0" version = "1" because in this case I just don’t need it and I want a simple clean config as a file

the code

void serialize(Archive & ar, const unsigned int version)
{
  ar & make_nvp("TestInt", TestInt);

  ar & make_nvp("Resolution", resolution);
  ar & make_nvp("SomeStuff", SomeStuff);
}

I found boost :: serialization :: track_never, but nowhere to use it

+4
source share
5 answers

try creating iarchive with the "no_header" option:

boost::archive::xml_iarchive ia(is, boost::archive::no_header);
+4
source

it’s too late for the original poster, I would like to share what I found

BOOST_CLASS_IMPLEMENTATION(My_class, object_serializable)

does the trick.

+8
source

xml,

boost::archive::xml_iarchive ia(is, boost::archive::no_header);

class_id, tracking_level ,

BOOST_CLASS_IMPLEMENTATION( <type>, boost::serialization::object_serializable )
BOOST_CLASS_TRACKING( <type>, boost::serialization::track_never )

. .

BOOST_CLASS_VERSION

, .

+5

( AFAIK), boost::archive::no_tracking, , , ( , XML):

    boost::archive::xml_oarchive oa{std::cout, boost::archive::no_header | boost::archive::no_tracking}; 

(http://boost.2283326.n4.nabble.com/serialization-removing-excess-XML-tags-td2582827.html)

(- ).

<my_carbon class_id="0" tracking_level="0" version="0">
    <number>6</number>
    <symbol>C</symbol>
    <AR_electronegativity class_id="1" tracking_level="0" version="0">
        <has_value>1</has_value>
        <value>2.50000000000000000e+00</value>
    </AR_electronegativity>
    <covalent_radius class_id="2" tracking_level="0" version="0">
        <has_value>1</has_value>
        <value class_id="3" tracking_level="0" version="0">
            <value>7.60000000000000009e-01</value>
        </value>
    </covalent_radius>
...
0

"".

"" , . , - , , , . "_" , _id, . . , , , , . , object_id = "_0". , , object_id. . . . , , . - . , .

, , . - . IIRC .

, . . , . "no_header" . .

... , - , , .

0

Source: https://habr.com/ru/post/1784823/


All Articles