Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
thallium
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
thallium
Commits
bb0a5840
Commit
bb0a5840
authored
Jul 21, 2019
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added operator() in archives
parent
f6f46b4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
5 deletions
+49
-5
CHANGELOG
CHANGELOG
+8
-0
include/thallium/serialization/buffer_input_archive.hpp
include/thallium/serialization/buffer_input_archive.hpp
+22
-4
include/thallium/serialization/buffer_output_archive.hpp
include/thallium/serialization/buffer_output_archive.hpp
+19
-1
No files found.
CHANGELOG
0 → 100644
View file @
bb0a5840
# master
* Added copy() function in serialization archives. This function
acts like a read() for input archive, and like a write() for
output archives. This allows writing a single serialize() function
instead of load()/store() functions in many situations.
* Added operator() to input and output archives to enable a syntax
similar to that of the cereal library.
include/thallium/serialization/buffer_input_archive.hpp
View file @
bb0a5840
...
...
@@ -60,17 +60,35 @@ public:
/**
* Operator to get C++ objects of type T from the archive.
* The object should either be a basic type, or an STL container
* (in which case the appropriate
hgcxx/hg_stl/stl_* header should
*
be included for this function to be properly instanciated), or
* any object for which either a serialize member function or
* (in which case the appropriate
thallium/serialization/stl/ header
*
should be included for this function to be properly instanciated),
*
or
any object for which either a serialize member function or
* a load member function has been provided.
*/
template
<
typename
T
>
buffer_input_archive
&
operator
&
(
T
&&
obj
)
{
inline
buffer_input_archive
&
operator
&
(
T
&&
obj
)
{
read_impl
(
std
::
forward
<
T
>
(
obj
),
std
::
is_arithmetic
<
typename
std
::
decay
<
T
>::
type
>
());
return
*
this
;
}
/**
* @brief Parenthesis operator with one argument, equivalent to & operator.
*/
template
<
typename
T
>
inline
buffer_input_archive
&
operator
()(
T
&&
obj
)
{
return
(
*
this
)
&
std
::
forward
<
T
>
(
obj
);
}
/**
* @brief Parenthesis operator with multiple arguments.
* ar(x,y,z) is equivalent to ar & x & y & z.
*/
template
<
typename
T
,
typename
...
Targs
>
inline
buffer_input_archive
&
operator
()(
T
&&
obj
,
Targs
&&
...
others
)
{
(
*
this
)
&
std
::
forward
<
T
>
(
obj
);
return
(
*
this
)(
std
::
forward
<
Targs
>
(
others
)...);
}
/**
* Operator >> is equivalent to operator &.
* \see operator&
...
...
include/thallium/serialization/buffer_output_archive.hpp
View file @
bb0a5840
...
...
@@ -68,11 +68,29 @@ public:
* a load member function has been provided.
*/
template
<
typename
T
>
buffer_output_archive
&
operator
&
(
T
&&
obj
)
{
inline
buffer_output_archive
&
operator
&
(
T
&&
obj
)
{
write_impl
(
std
::
forward
<
T
>
(
obj
),
std
::
is_arithmetic
<
typename
std
::
decay
<
T
>::
type
>
());
return
*
this
;
}
/**
* @brief Parenthesis operator with one argument, equivalent to & operator.
*/
template
<
typename
T
>
inline
buffer_output_archive
&
operator
()(
T
&&
obj
)
{
return
(
*
this
)
&
std
::
forward
<
T
>
(
obj
);
}
/**
* @brief Parenthesis operator with multiple arguments.
* ar(x,y,z) is equivalent to ar & x & y & z.
*/
template
<
typename
T
,
typename
...
Targs
>
inline
buffer_output_archive
&
operator
()(
T
&&
obj
,
Targs
&&
...
others
)
{
(
*
this
)
&
std
::
forward
<
T
>
(
obj
);
return
(
*
this
)(
std
::
forward
<
Targs
>
(
others
)...);
}
/**
* Operator << is equivalent to operator &.
* \see operator&
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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