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
f62f8730
Commit
f62f8730
authored
Dec 15, 2020
by
Joseph Mirabel
Browse files
[Serialization] Add text archive + variadic base class in archive_tpl
parent
449e4a0a
Pipeline
#12784
passed with stage
in 4 minutes and 58 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
include/hpp/util/serialization.hh
View file @
f62f8730
...
...
@@ -21,8 +21,10 @@
#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>
#include
<boost/preprocessor/comma_if.hpp>
...
...
@@ -53,15 +55,18 @@
#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); \
}}
...
...
@@ -71,8 +76,9 @@
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::binary,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::xml,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::text,type& t); \
_HPP_SERIALIZATION_IMPLEMENT(,archive::binary,type& t); \
}}
namespace
hpp
{
...
...
@@ -190,8 +196,8 @@ protected:
}
};
template
<
typename
archive_base
>
class
archive_tpl
:
public
archive_base
,
public
archive_ptr_holder
template
<
typename
archive_base
,
typename
...
parent_classes
>
class
archive_tpl
:
public
archive_base
,
public
archive_ptr_holder
,
public
parent_classes
...
{
public:
inline
void
initialize
()
...
...
@@ -203,15 +209,18 @@ public:
};
template
<
typename
Archive
>
archive_
tpl
<
Archive
>
&
cast
(
Archive
&
ar
)
{
return
dynamic_cast
<
archive_
tpl
<
Archive
>
&>
(
ar
);
}
archive_
ptr_holder
&
cast
(
Archive
&
ar
)
{
return
dynamic_cast
<
archive_
ptr_holder
&>
(
ar
);
}
template
<
typename
Archive
>
archive_
tpl
<
Archive
>
*
cast
(
Archive
*
ar
)
{
return
dynamic_cast
<
archive_
tpl
<
Archive
>
*>
(
ar
);
}
archive_
ptr_holder
*
cast
(
Archive
*
ar
)
{
return
dynamic_cast
<
archive_
ptr_holder
*>
(
ar
);
}
typedef
archive_tpl
<
boost
::
archive
::
binary_iarchive
>
binary_iarchive
;
typedef
archive_tpl
<
boost
::
archive
::
binary_oarchive
>
binary_oarchive
;
typedef
archive_tpl
<
boost
::
archive
::
xml_iarchive
>
xml_iarchive
;
typedef
archive_tpl
<
boost
::
archive
::
xml_oarchive
>
xml_oarchive
;
typedef
archive_tpl
<
boost
::
archive
::
text_iarchive
>
text_iarchive
;
typedef
archive_tpl
<
boost
::
archive
::
text_oarchive
>
text_oarchive
;
}
// namespace util
}
// namespace hpp
...
...
tests/serialization-test.cc
View file @
f62f8730
...
...
@@ -119,6 +119,18 @@ int run_test_holder_inheritance()
return
TEST_SUCCEED
;
}
int
run_test_archive_parents
()
{
using
namespace
hpp
::
serialization
;
struct
P1
{};
struct
P2
{};
typedef
archive_tpl
<
boost
::
archive
::
xml_iarchive
,
P1
,
P2
>
type
;
std
::
stringstream
ss
;
type
t
(
ss
);
(
void
)
t
;
return
TEST_SUCCEED
;
}
int
run_test
()
{
if
(
run_test_tpl
<
Foo
>
()
==
TEST_FAILED
)
return
TEST_FAILED
;
...
...
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