i just can't find a way to remove the version tracking from the boost xmlarchives.
我只是找不到从boost xmlarchives中删除版本跟踪的方法。
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 get ride of the class_id="0" tracking_level="0" version="1" stuff, because for in this case i just don't need it and want a simple clean config like file
我想得到class_id =“0”tracking_level =“0”version =“1”的东西,因为在这种情况下我只是不需要它并想要一个像文件一样的简单干净配置
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
我发现了boost :: serialization :: track_never,但无处可去使用它
3 个解决方案
#1
4
try to create iarchive with "no_header" option:
尝试使用“no_header”选项创建iarchive:
boost::archive::xml_iarchive ia(is, boost::archive::no_header);
#2
8
while too late for the original poster I'd like to share what I've found
对于原始海报来说太迟了,我想分享我发现的东西
BOOST_CLASS_IMPLEMENTATION(My_class, object_serializable)
does the trick.
诀窍。
#3
4
To remove the header of an xml archive file you can use
要删除可以使用的xml存档文件的标头
boost::archive::xml_iarchive ia(is, boost::archive::no_header);
To disable the attributes class_id, tracking_level and version from being displayed you'll have to use
要禁用显示属性class_id,tracking_level和版本,您必须使用
BOOST_CLASS_IMPLEMENTATION( <type>, boost::serialization::object_serializable )
BOOST_CLASS_TRACKING( <type>, boost::serialization::track_never )
for each type. Theses macros need to be called in this order. N.B. you cannot use
对于每种类型。需要按此顺序调用这些宏。注:你不能用
BOOST_CLASS_VERSION
with macros described above.
用上面描述的宏。
#1
4
try to create iarchive with "no_header" option:
尝试使用“no_header”选项创建iarchive:
boost::archive::xml_iarchive ia(is, boost::archive::no_header);
#2
8
while too late for the original poster I'd like to share what I've found
对于原始海报来说太迟了,我想分享我发现的东西
BOOST_CLASS_IMPLEMENTATION(My_class, object_serializable)
does the trick.
诀窍。
#3
4
To remove the header of an xml archive file you can use
要删除可以使用的xml存档文件的标头
boost::archive::xml_iarchive ia(is, boost::archive::no_header);
To disable the attributes class_id, tracking_level and version from being displayed you'll have to use
要禁用显示属性class_id,tracking_level和版本,您必须使用
BOOST_CLASS_IMPLEMENTATION( <type>, boost::serialization::object_serializable )
BOOST_CLASS_TRACKING( <type>, boost::serialization::track_never )
for each type. Theses macros need to be called in this order. N.B. you cannot use
对于每种类型。需要按此顺序调用这些宏。注:你不能用
BOOST_CLASS_VERSION
with macros described above.
用上面描述的宏。