What is the output format of boost.serialization

I tried serializing the vector and map container and inferring their cout value. However, it’s hard for me to understand the meaning of improving performance. My code is as follows:

#include <iostream>
#include <boost/serialization/vector.hpp>   
#include <boost/serialization/map.hpp>  
#include <boost/assign.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <sstream>
#include <fstream>

using namespace std;

int main()
{
    vector<int> v = boost::assign::list_of(1)(3)(5);
    map<int, string> m = boost::assign::map_list_of(1,"one")(2,"two");

    std::stringstream ss;
    boost::archive::text_oarchive oa(ss);
    oa<<v<<m;   

    vector<int> v_;
    map<int,string> m_;
    boost::archive::text_iarchive ia(ss);
    ia>>v_>>m_;
    boost::archive::text_oarchive ib(cout);
    ib<<v_<<m_;
    return 0;
}

The result is as follows:

22 serialization::archive 9 3 0 1 3 5 0 0 2 0 0 0 1 3 one 2 3 two

What is the value of the numbers 9 3 0 to the value of 1 3 5 I compose? What about 0 0 2 0 0 0? Does “3” between “1” and “one” mean there are 3 characters?

+5
source share
3 answers

I'm not sure about some zeros on the map (maybe some version number or tracking levels), but for the rest:

22 (size of the archive)
serialization::archive (signature)
9 (archive version, 10 on boost 1.53)
3 (vector size)
0 (item version)
1 3 5 (vector items)
0 (map class tracking level ?)
0 (map class version ?)
2 (map size)
0 (item class tracking _level ?)
0 (item class version ?)
0 (item version)
1 (key) 3 (value length) one (value)
2 (key) 3 (value length) two (value)

, - Boost Boost Boost, .

+5

boost::archive::xml_oarchive ib(cout);
ib<< boost::serialization::make_nvp("v", v_) << boost::serialization::make_nvp("m", m_);   //    ib<<v_<<m_;
return 0;

, :

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="10">
<v>
    <count>3</count>
    <item_version>0</item_version>
    <item>1</item>
    <item>3</item>
    <item>5</item>
</v>
<m class_id="1" tracking_level="0" version="0">
    <count>2</count>
    <item_version>0</item_version>
    <item class_id="2" tracking_level="0" version="0">
        <first>1</first>
        <second>one</second>
    </item>
    <item>
        <first>2</first>
        <second>two</second>
    </item>
</m>
</boost_serialization>

, @zacinter , 0 2: 1) item_version ( std::pair, map) 2) tracking_level of std::pair 3) version of std::pair.

+3

22 is the length of the text "serialization :: archive". Each text that is archived has the amount that I count.

0
source

All Articles