Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Humanoid Path Planner
hpp-util
Commits
a6152ca5
Commit
a6152ca5
authored
May 18, 2020
by
Joseph Mirabel
Browse files
Fix compatibility with old boost version.
parent
deb7f602
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/hpp/util/serialization.hh
View file @
a6152ca5
...
...
@@ -19,14 +19,19 @@
#ifndef HPP_UTIL_SERIALIZATION_HH
#define HPP_UTIL_SERIALIZATION_HH
#include
<boost/version.hpp>
#include
<boost/archive/binary_oarchive.hpp>
#include
<boost/archive/text_oarchive.hpp>
#include
<boost/archive/xml_oarchive.hpp>
#include
<boost/archive/binary_iarchive.hpp>
#include
<boost/archive/text_iarchive.hpp>
#include
<boost/archive/xml_iarchive.hpp>
// Old version of boost do not support well serialization.
#if BOOST_VERSION >= 106500
#include
<boost/archive/polymorphic_oarchive.hpp>
#include
<boost/archive/polymorphic_iarchive.hpp>
#endif
#include
<boost/preprocessor/comma_if.hpp>
#include
<boost/preprocessor/facilities/is_empty.hpp>
...
...
@@ -48,8 +53,9 @@
const unsigned int ver); \
template void type serialize<archive##_oarchive>(archive##_oarchive& ar, \
arg BOOST_PP_COMMA_IF(BOOST_PP_NOT(BOOST_PP_IS_EMPTY(arg))) \
const unsigned int ver)
const unsigned int ver)
#if BOOST_VERSION >= 106500
#define HPP_SERIALIZATION_SPLIT_IMPLEMENT(type) \
_HPP_SERIALIZATION_SPLIT_IMPLEMENT(type::,boost::archive::polymorphic,); \
_HPP_SERIALIZATION_SPLIT_IMPLEMENT(type::,boost::archive::xml,); \
...
...
@@ -82,6 +88,38 @@
_HPP_SERIALIZATION_IMPLEMENT(,archive::binary,type& t); \
}}
#else // BOOST_VERSION >= 106500
#define HPP_SERIALIZATION_SPLIT_IMPLEMENT(type) \
_HPP_SERIALIZATION_SPLIT_IMPLEMENT(type::,boost::archive::xml,); \
_HPP_SERIALIZATION_SPLIT_IMPLEMENT(type::,boost::archive::text,); \
_HPP_SERIALIZATION_SPLIT_IMPLEMENT(type::,boost::archive::binary,)
#define HPP_SERIALIZATION_IMPLEMENT(type) \
_HPP_SERIALIZATION_IMPLEMENT(type::,boost::archive::xml,); \
_HPP_SERIALIZATION_IMPLEMENT(type::,boost::archive::text,); \
_HPP_SERIALIZATION_IMPLEMENT(type::,boost::archive::binary,)
#define HPP_SERIALIZATION_FREE_IMPLEMENT(type) \
namespace boost { namespace serialization { \
_HPP_SERIALIZATION_IMPLEMENT(,archive::xml,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::text,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::binary,type& t); \
}}
#define HPP_SERIALIZATION_SPLIT_FREE_IMPLEMENT(type) \
namespace boost { namespace serialization { \
template<class Archive> \
void serialize(Archive & ar, type& t, const unsigned int version) { \
split_free(ar, t, version); \
} \
_HPP_SERIALIZATION_IMPLEMENT(,archive::xml,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::text,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::binary,type& t); \
}}
#endif // BOOST_VERSION >= 106500
namespace
hpp
{
namespace
serialization
{
using
boost
::
serialization
::
make_nvp
;
...
...
tests/serialization-test.cc
View file @
a6152ca5
...
...
@@ -20,8 +20,8 @@
#include
"common.hh"
#include
"serialization.hh"
#include
<boost/archive/
polymorphic_
xml_iarchive.hpp>
#include
<boost/archive/
polymorphic_
xml_oarchive.hpp>
#include
<boost/archive/xml_iarchive.hpp>
#include
<boost/archive/xml_oarchive.hpp>
template
<
typename
T
>
int
run_test_tpl
()
...
...
@@ -29,12 +29,12 @@ int run_test_tpl ()
std
::
stringstream
ss
;
T
t
(
10
);
{
boost
::
archive
::
polymorphic_
xml_oarchive
oa
(
ss
);
boost
::
archive
::
xml_oarchive
oa
(
ss
);
oa
<<
boost
::
serialization
::
make_nvp
(
"t"
,
t
);
}
Foo
*
t_r
=
NULL
;
{
boost
::
archive
::
polymorphic_
xml_iarchive
ia
(
ss
);
boost
::
archive
::
xml_iarchive
ia
(
ss
);
ia
>>
boost
::
serialization
::
make_nvp
(
"t"
,
t_r
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment