Preprocessor defines for serialization function names

The following preprocessor defines have been added:

 - CEREAL_SERIALIZE_FUNCTION_NAME
 - CEREAL_SAVE_FUNCTION_NAME
 - CEREAL_LOAD_FUNCTION_NAME

These defines specifiy the name of the cereal serialization/deserialization
functions so that they can be customised by users. This is especially useful if
the user would like to have capitialized function names.
This commit is contained in:
Matt Clarkson 2014-03-17 14:53:20 +00:00
parent 5f3e9fb9f1
commit e7f7692d6a
30 changed files with 198 additions and 141 deletions

View File

@ -33,6 +33,7 @@
#include <iostream>
#include <cstdint>
#include <cereal/macros.hpp>
#include <cereal/details/helpers.hpp>
namespace cereal
@ -224,37 +225,37 @@ namespace cereal
public:
// ####### Standard Serialization ########################################
template<class Archive, class T> inline
static auto member_serialize(Archive & ar, T & t) -> decltype(t.serialize(ar))
{ t.serialize(ar); }
static auto member_serialize(Archive & ar, T & t) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar))
{ t.CEREAL_SERIALIZE_FUNCTION_NAME(ar); }
template<class Archive, class T> inline
static auto member_save(Archive & ar, T const & t) -> decltype(t.save(ar))
{ t.save(ar); }
static auto member_save(Archive & ar, T const & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
{ t.CEREAL_SAVE_FUNCTION_NAME(ar); }
template<class Archive, class T> inline
static auto member_save_non_const(Archive & ar, T & t) -> decltype(t.save(ar))
{ t.save(ar); }
static auto member_save_non_const(Archive & ar, T & t) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar))
{ t.CEREAL_SAVE_FUNCTION_NAME(ar); }
template<class Archive, class T> inline
static auto member_load(Archive & ar, T & t) -> decltype(t.load(ar))
{ t.load(ar); }
static auto member_load(Archive & ar, T & t) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar))
{ t.CEREAL_LOAD_FUNCTION_NAME(ar); }
// ####### Versioned Serialization #######################################
template<class Archive, class T> inline
static auto member_serialize(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.serialize(ar, version))
{ t.serialize(ar, version); }
static auto member_serialize(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version))
{ t.CEREAL_SERIALIZE_FUNCTION_NAME(ar, version); }
template<class Archive, class T> inline
static auto member_save(Archive & ar, T const & t, const std::uint32_t version ) -> decltype(t.save(ar, version))
{ t.save(ar, version); }
static auto member_save(Archive & ar, T const & t, const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
{ t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }
template<class Archive, class T> inline
static auto member_save_non_const(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.save(ar, version))
{ t.save(ar, version); }
static auto member_save_non_const(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_SAVE_FUNCTION_NAME(ar, version))
{ t.CEREAL_SAVE_FUNCTION_NAME(ar, version); }
template<class Archive, class T> inline
static auto member_load(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.load(ar, version))
{ t.load(ar, version); }
static auto member_load(Archive & ar, T & t, const std::uint32_t version ) -> decltype(t.CEREAL_LOAD_FUNCTION_NAME(ar, version))
{ t.CEREAL_LOAD_FUNCTION_NAME(ar, version); }
// ####### Other Functionality ##########################################
// for detecting inheritance from enable_shared_from_this

View File

@ -111,7 +111,7 @@ namespace cereal
//! Saving for POD types to binary
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
save(BinaryOutputArchive & ar, T const & t)
CEREAL_SAVE_FUNCTION_NAME(BinaryOutputArchive & ar, T const & t)
{
ar.saveBinary(std::addressof(t), sizeof(t));
}
@ -119,7 +119,7 @@ namespace cereal
//! Loading for POD types from binary
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
load(BinaryInputArchive & ar, T & t)
CEREAL_LOAD_FUNCTION_NAME(BinaryInputArchive & ar, T & t)
{
ar.loadBinary(std::addressof(t), sizeof(t));
}
@ -127,7 +127,7 @@ namespace cereal
//! Serializing NVP types to binary
template <class Archive, class T> inline
CEREAL_ARCHIVE_RESTRICT(BinaryInputArchive, BinaryOutputArchive)
serialize( Archive & ar, NameValuePair<T> & t )
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, NameValuePair<T> & t )
{
ar( t.value );
}
@ -135,21 +135,21 @@ namespace cereal
//! Serializing SizeTags to binary
template <class Archive, class T> inline
CEREAL_ARCHIVE_RESTRICT(BinaryInputArchive, BinaryOutputArchive)
serialize( Archive & ar, SizeTag<T> & t )
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, SizeTag<T> & t )
{
ar( t.size );
}
//! Saving binary data
template <class T> inline
void save(BinaryOutputArchive & ar, BinaryData<T> const & bd)
void CEREAL_SAVE_FUNCTION_NAME(BinaryOutputArchive & ar, BinaryData<T> const & bd)
{
ar.saveBinary( bd.data, static_cast<std::size_t>( bd.size ) );
}
//! Loading binary data
template <class T> inline
void load(BinaryInputArchive & ar, BinaryData<T> & bd)
void CEREAL_LOAD_FUNCTION_NAME(BinaryInputArchive & ar, BinaryData<T> & bd)
{
ar.loadBinary(bd.data, static_cast<std::size_t>(bd.size));
}

View File

@ -786,14 +786,14 @@ namespace cereal
//! Serializing NVP types to JSON
template <class T> inline
void save( JSONOutputArchive & ar, NameValuePair<T> const & t )
void CEREAL_SAVE_FUNCTION_NAME( JSONOutputArchive & ar, NameValuePair<T> const & t )
{
ar.setNextName( t.name );
ar( t.value );
}
template <class T> inline
void load( JSONInputArchive & ar, NameValuePair<T> & t )
void CEREAL_LOAD_FUNCTION_NAME( JSONInputArchive & ar, NameValuePair<T> & t )
{
ar.setNextName( t.name );
ar( t.value );
@ -802,7 +802,7 @@ namespace cereal
//! Saving for arithmetic to JSON
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
save(JSONOutputArchive & ar, T const & t)
CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, T const & t)
{
ar.saveValue( t );
}
@ -810,21 +810,21 @@ namespace cereal
//! Loading arithmetic from JSON
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
load(JSONInputArchive & ar, T & t)
CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, T & t)
{
ar.loadValue( t );
}
//! saving string to JSON
template<class CharT, class Traits, class Alloc> inline
void save(JSONOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
void CEREAL_SAVE_FUNCTION_NAME(JSONOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
{
ar.saveValue( str );
}
//! loading string from JSON
template<class CharT, class Traits, class Alloc> inline
void load(JSONInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
void CEREAL_LOAD_FUNCTION_NAME(JSONInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
{
ar.loadValue( str );
}
@ -832,14 +832,14 @@ namespace cereal
// ######################################################################
//! Saving SizeTags to JSON
template <class T> inline
void save( JSONOutputArchive &, SizeTag<T> const & )
void CEREAL_SAVE_FUNCTION_NAME( JSONOutputArchive &, SizeTag<T> const & )
{
// nothing to do here, we don't explicitly save the size
}
//! Loading SizeTags from JSON
template <class T> inline
void load( JSONInputArchive & ar, SizeTag<T> & st )
void CEREAL_LOAD_FUNCTION_NAME( JSONInputArchive & ar, SizeTag<T> & st )
{
ar.loadSize( st.size );
}

View File

@ -175,7 +175,7 @@ namespace cereal
//! Saving for POD types to portable binary
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
save(PortableBinaryOutputArchive & ar, T const & t)
CEREAL_SAVE_FUNCTION_NAME(PortableBinaryOutputArchive & ar, T const & t)
{
static_assert( !std::is_floating_point<T>::value ||
(std::is_floating_point<T>::value && std::numeric_limits<T>::is_iec559),
@ -186,7 +186,7 @@ namespace cereal
//! Loading for POD types from portable binary
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
load(PortableBinaryInputArchive & ar, T & t)
CEREAL_LOAD_FUNCTION_NAME(PortableBinaryInputArchive & ar, T & t)
{
static_assert( !std::is_floating_point<T>::value ||
(std::is_floating_point<T>::value && std::numeric_limits<T>::is_iec559),
@ -197,7 +197,7 @@ namespace cereal
//! Serializing NVP types to portable binary
template <class Archive, class T> inline
CEREAL_ARCHIVE_RESTRICT(PortableBinaryInputArchive, PortableBinaryOutputArchive)
serialize( Archive & ar, NameValuePair<T> & t )
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, NameValuePair<T> & t )
{
ar( t.value );
}
@ -205,14 +205,14 @@ namespace cereal
//! Serializing SizeTags to portable binary
template <class Archive, class T> inline
CEREAL_ARCHIVE_RESTRICT(PortableBinaryInputArchive, PortableBinaryOutputArchive)
serialize( Archive & ar, SizeTag<T> & t )
CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, SizeTag<T> & t )
{
ar( t.size );
}
//! Saving binary data to portable binary
template <class T> inline
void save(PortableBinaryOutputArchive & ar, BinaryData<T> const & bd)
void CEREAL_SAVE_FUNCTION_NAME(PortableBinaryOutputArchive & ar, BinaryData<T> const & bd)
{
typedef typename std::remove_pointer<T>::type TT;
static_assert( !std::is_floating_point<TT>::value ||
@ -224,7 +224,7 @@ namespace cereal
//! Loading binary data from portable binary
template <class T> inline
void load(PortableBinaryInputArchive & ar, BinaryData<T> & bd)
void CEREAL_LOAD_FUNCTION_NAME(PortableBinaryInputArchive & ar, BinaryData<T> & bd)
{
typedef typename std::remove_pointer<T>::type TT;
static_assert( !std::is_floating_point<TT>::value ||

View File

@ -755,7 +755,7 @@ namespace cereal
//! Saving NVP types to XML
template <class T> inline
void save( XMLOutputArchive & ar, NameValuePair<T> const & t )
void CEREAL_SAVE_FUNCTION_NAME( XMLOutputArchive & ar, NameValuePair<T> const & t )
{
ar.setNextName( t.name );
ar( t.value );
@ -763,7 +763,7 @@ namespace cereal
//! Loading NVP types from XML
template <class T> inline
void load( XMLInputArchive & ar, NameValuePair<T> & t )
void CEREAL_LOAD_FUNCTION_NAME( XMLInputArchive & ar, NameValuePair<T> & t )
{
ar.setNextName( t.name );
ar( t.value );
@ -772,12 +772,12 @@ namespace cereal
// ######################################################################
//! Saving SizeTags to XML
template <class T> inline
void save( XMLOutputArchive &, SizeTag<T> const & )
void CEREAL_SAVE_FUNCTION_NAME( XMLOutputArchive &, SizeTag<T> const & )
{ }
//! Loading SizeTags from XML
template <class T> inline
void load( XMLInputArchive & ar, SizeTag<T> & st )
void CEREAL_LOAD_FUNCTION_NAME( XMLInputArchive & ar, SizeTag<T> & st )
{
ar.loadSize( st.size );
}
@ -786,7 +786,7 @@ namespace cereal
//! Saving for POD types to xml
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
save(XMLOutputArchive & ar, T const & t)
CEREAL_SAVE_FUNCTION_NAME(XMLOutputArchive & ar, T const & t)
{
ar.saveValue( t );
}
@ -794,7 +794,7 @@ namespace cereal
//! Loading for POD types from xml
template<class T> inline
typename std::enable_if<std::is_arithmetic<T>::value, void>::type
load(XMLInputArchive & ar, T & t)
CEREAL_LOAD_FUNCTION_NAME(XMLInputArchive & ar, T & t)
{
ar.loadValue( t );
}
@ -802,14 +802,14 @@ namespace cereal
// ######################################################################
//! saving string to xml
template<class CharT, class Traits, class Alloc> inline
void save(XMLOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
void CEREAL_SAVE_FUNCTION_NAME(XMLOutputArchive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
{
ar.saveValue( str );
}
//! loading string from xml
template<class CharT, class Traits, class Alloc> inline
void load(XMLInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
void CEREAL_LOAD_FUNCTION_NAME(XMLInputArchive & ar, std::basic_string<CharT, Traits, Alloc> & str)
{
ar.loadValue( str );
}

View File

@ -39,6 +39,7 @@
#include <cstdint>
#include <functional>
#include <cereal/macros.hpp>
#include <cereal/details/traits.hpp>
#include <cereal/details/helpers.hpp>
#include <cereal/types/base_class.hpp>
@ -372,7 +373,7 @@ namespace cereal
ArchiveType &>::type
processImpl(T const & t)
{
serialize(*self, const_cast<T &>(t));
CEREAL_SERIALIZE_FUNCTION_NAME(*self, const_cast<T &>(t));
return *self;
}
@ -394,7 +395,7 @@ namespace cereal
ArchiveType &>::type
processImpl(T const & t)
{
save(*self, t);
CEREAL_SAVE_FUNCTION_NAME(*self, t);
return *self;
}
@ -463,7 +464,7 @@ namespace cereal
processImpl(T const & t)
{
registerClassVersion<T>( detail::Version<T>::version );
serialize(*self, const_cast<T &>(t), detail::Version<T>::version);
CEREAL_SERIALIZE_FUNCTION_NAME(*self, const_cast<T &>(t), detail::Version<T>::version);
return *self;
}
@ -487,7 +488,7 @@ namespace cereal
processImpl(T const & t)
{
registerClassVersion<T>( detail::Version<T>::version );
save(*self, t, detail::Version<T>::version);
CEREAL_SAVE_FUNCTION_NAME(*self, t, detail::Version<T>::version);
return *self;
}
@ -698,7 +699,7 @@ namespace cereal
ArchiveType &>::type
processImpl(T & t)
{
serialize(*self, t);
CEREAL_SERIALIZE_FUNCTION_NAME(*self, t);
return *self;
}
@ -720,7 +721,7 @@ namespace cereal
ArchiveType &>::type
processImpl(T & t)
{
load(*self, t);
CEREAL_LOAD_FUNCTION_NAME(*self, t);
return *self;
}
@ -799,7 +800,7 @@ namespace cereal
processImpl(T & t)
{
const auto version = loadClassVersion<T>();
serialize(*self, t, version);
CEREAL_SERIALIZE_FUNCTION_NAME(*self, t, version);
return *self;
}
@ -823,7 +824,7 @@ namespace cereal
processImpl(T & t)
{
const auto version = loadClassVersion<T>();
load(*self, t, version);
CEREAL_LOAD_FUNCTION_NAME(*self, t, version);
return *self;
}

View File

@ -37,6 +37,7 @@
#include <unordered_map>
#include <stdexcept>
#include <cereal/macros.hpp>
#include <cereal/details/static_object.hpp>
namespace cereal
@ -304,7 +305,7 @@ namespace cereal
//! Serialize the MapItem with the NVPs "key" and "value"
template <class Archive> inline
void serialize(Archive & archive)
void CEREAL_SERIALIZE_FUNCTION_NAME(Archive & archive)
{
archive( make_nvp<Archive>("key", key),
make_nvp<Archive>("value", value) );

View File

@ -37,6 +37,7 @@
#include <type_traits>
#include <typeindex>
#include <cereal/macros.hpp>
#include <cereal/access.hpp>
namespace cereal
@ -88,14 +89,14 @@ namespace cereal
//! Creates a test for whether a non const non-member function exists
/*! This creates a class derived from std::integral_constant that will be true if
the type has the proper non-member function for the given archive. */
#define CEREAL_MAKE_HAS_NON_MEMBER_TEST(name) \
#define CEREAL_MAKE_HAS_NON_MEMBER_TEST(name, func) \
namespace detail \
{ \
template <class T, class A> \
struct has_non_member_##name##_impl \
{ \
template <class TT, class AA> \
static auto test(int) -> decltype( name( std::declval<AA&>(), std::declval<TT&>() ), yes()); \
static auto test(int) -> decltype( func( std::declval<AA&>(), std::declval<TT&>() ), yes()); \
template <class, class> \
static no test( ... ); \
static const bool value = std::is_same<decltype( test<T, A>( 0 ) ), yes>::value; \
@ -135,14 +136,14 @@ namespace cereal
//! Creates a test for whether a non const non-member function exists with a version parameter
/*! This creates a class derived from std::integral_constant that will be true if
the type has the proper non-member function for the given archive. */
#define CEREAL_MAKE_HAS_NON_MEMBER_VERSIONED_TEST(name) \
#define CEREAL_MAKE_HAS_NON_MEMBER_VERSIONED_TEST(name, func) \
namespace detail \
{ \
template <class T, class A> \
struct has_non_member_versioned_##name##_impl \
{ \
template <class TT, class AA> \
static auto test(int) -> decltype( name( std::declval<AA&>(), std::declval<TT&>(), 0 ), yes()); \
static auto test(int) -> decltype( func( std::declval<AA&>(), std::declval<TT&>(), 0 ), yes()); \
template <class, class> \
static no test( ... ); \
static const bool value = std::is_same<decltype( test<T, A>( 0 ) ), yes>::value; \
@ -180,11 +181,11 @@ namespace cereal
// ######################################################################
// Non Member Serialize
CEREAL_MAKE_HAS_NON_MEMBER_TEST(serialize);
CEREAL_MAKE_HAS_NON_MEMBER_TEST(serialize, CEREAL_SERIALIZE_FUNCTION_NAME);
// ######################################################################
// Non Member Serialize (versioned)
CEREAL_MAKE_HAS_NON_MEMBER_VERSIONED_TEST(serialize);
CEREAL_MAKE_HAS_NON_MEMBER_VERSIONED_TEST(serialize, CEREAL_SERIALIZE_FUNCTION_NAME);
// ######################################################################
// Member Load
@ -196,11 +197,11 @@ namespace cereal
// ######################################################################
// Non Member Load
CEREAL_MAKE_HAS_NON_MEMBER_TEST(load);
CEREAL_MAKE_HAS_NON_MEMBER_TEST(load, CEREAL_LOAD_FUNCTION_NAME);
// ######################################################################
// Non Member Load (versioned)
CEREAL_MAKE_HAS_NON_MEMBER_VERSIONED_TEST(load);
CEREAL_MAKE_HAS_NON_MEMBER_VERSIONED_TEST(load, CEREAL_LOAD_FUNCTION_NAME);
// ######################################################################
// Member Save
@ -302,13 +303,13 @@ namespace cereal
struct has_non_member_save_impl
{
template <class TT, class AA>
static auto test(int) -> decltype( save( std::declval<AA&>(), std::declval<TT const &>() ), yes());
static auto test(int) -> decltype( CEREAL_SAVE_FUNCTION_NAME( std::declval<AA&>(), std::declval<TT const &>() ), yes());
template <class, class>
static no test(...);
static const bool value = std::is_same<decltype(test<T, A>(0)), yes>::value;
template <class TT, class AA>
static auto test2(int) -> decltype( save( std::declval<AA &>(), std::declval<typename std::remove_const<TT>::type&>() ), yes());
static auto test2(int) -> decltype( CEREAL_SAVE_FUNCTION_NAME( std::declval<AA &>(), std::declval<typename std::remove_const<TT>::type&>() ), yes());
template <class, class>
static no test2(...);
static const bool not_const_type = std::is_same<decltype(test2<T, A>(0)), yes>::value;
@ -332,13 +333,13 @@ namespace cereal
struct has_non_member_versioned_save_impl
{
template <class TT, class AA>
static auto test(int) -> decltype( save( std::declval<AA&>(), std::declval<TT const &>(), 0 ), yes());
static auto test(int) -> decltype( CEREAL_SAVE_FUNCTION_NAME( std::declval<AA&>(), std::declval<TT const &>(), 0 ), yes());
template <class, class>
static no test(...);
static const bool value = std::is_same<decltype(test<T, A>(0)), yes>::value;
template <class TT, class AA>
static auto test2(int) -> decltype( save( std::declval<AA &>(), std::declval<typename std::remove_const<TT>::type&>(), 0 ), yes());
static auto test2(int) -> decltype( CEREAL_SAVE_FUNCTION_NAME( std::declval<AA &>(), std::declval<typename std::remove_const<TT>::type&>(), 0 ), yes());
template <class, class>
static no test2(...);
static const bool not_const_type = std::is_same<decltype(test2<T, A>(0)), yes>::value;

53
include/cereal/macros.hpp Normal file
View File

@ -0,0 +1,53 @@
/*! \file macros.hpp
\brief Preprocessor macros that can customise the cereal library */
/*
Copyright (c) 2013, Randolph Voorhies, Shane Grant
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of cereal nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CEREAL_MACROS_HPP_
#define CEREAL_MACROS_HPP_
#ifndef CEREAL_SERIALIZE_FUNCTION_NAME
//! The serialization/deserialization function name to search for.
/*! You can define @c CEREAL_SERIALIZE_FUNCTION_NAME to be different assuming
you do so before this file is included. */
#define CEREAL_SERIALIZE_FUNCTION_NAME serialize
#endif // CEREAL_SERIALIZE_FUNCTION_NAME
#ifndef CEREAL_LOAD_FUNCTION_NAME
//! The deserialization function name to search for.
/*! You can define @c CEREAL_LOAD_FUNCTION_NAME to be different assuming you do so
before this file is included. */
#define CEREAL_LOAD_FUNCTION_NAME load
#endif // CEREAL_LOAD_FUNCTION_NAME
#ifndef CEREAL_SAVE_FUNCTION_NAME
//! The serialization function name to search for.
/*! You can define @c CEREAL_SAVE_FUNCTION_NAME to be different assuming you do so
before this file is included. */
#define CEREAL_SAVE_FUNCTION_NAME save
#endif // CEREAL_SAVE_FUNCTION_NAME
#endif // CEREAL_MACROS_HPP_

View File

@ -40,7 +40,7 @@ namespace cereal
template <class Archive, class T, size_t N> inline
typename std::enable_if<traits::is_output_serializable<BinaryData<T>, Archive>::value
&& std::is_arithmetic<T>::value, void>::type
save( Archive & ar, std::array<T, N> const & array )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array<T, N> const & array )
{
ar( binary_data( array.data(), sizeof(array) ) );
}
@ -50,7 +50,7 @@ namespace cereal
template <class Archive, class T, size_t N> inline
typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>::value
&& std::is_arithmetic<T>::value, void>::type
load( Archive & ar, std::array<T, N> & array )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array<T, N> & array )
{
ar( binary_data( array.data(), sizeof(array) ) );
}
@ -59,7 +59,7 @@ namespace cereal
template <class Archive, class T, size_t N> inline
typename std::enable_if<!traits::is_output_serializable<BinaryData<T>, Archive>::value
|| !std::is_arithmetic<T>::value, void>::type
save( Archive & ar, std::array<T, N> const & array )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array<T, N> const & array )
{
for( auto const & i : array )
ar( i );
@ -69,7 +69,7 @@ namespace cereal
template <class Archive, class T, size_t N> inline
typename std::enable_if<!traits::is_input_serializable<BinaryData<T>, Archive>::value
|| !std::is_arithmetic<T>::value, void>::type
load( Archive & ar, std::array<T, N> & array )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array<T, N> & array )
{
for( auto & i : array )
ar( i );

View File

@ -49,7 +49,7 @@ namespace cereal
//! Serializing (save) for std::bitset
template <class Archive, size_t N> inline
void save( Archive & ar, std::bitset<N> const & bits )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::bitset<N> const & bits )
{
try
{
@ -75,7 +75,7 @@ namespace cereal
//! Serializing (load) for std::bitset
template <class Archive, size_t N> inline
void load( Archive & ar, std::bitset<N> & bits )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::bitset<N> & bits )
{
bitset_detail::type t;
ar( _CEREAL_NVP("type", t) );

View File

@ -80,7 +80,7 @@ namespace cereal
//! Saving for boost::variant
template <class Archive, typename... VariantTypes> inline
void save( Archive & ar, boost::variant<VariantTypes...> const & variant )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, boost::variant<VariantTypes...> const & variant )
{
int32_t which = variant.which();
ar( _CEREAL_NVP("which", which) );
@ -90,7 +90,7 @@ namespace cereal
//! Loading for boost::variant
template <class Archive, typename... VariantTypes> inline
void load( Archive & ar, boost::variant<VariantTypes...> & variant )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, boost::variant<VariantTypes...> & variant )
{
typedef typename boost::variant<VariantTypes...>::types types;

View File

@ -36,14 +36,14 @@ namespace cereal
{
//! Saving std::chrono::duration
template <class Archive, class R, class P> inline
void save( Archive & ar, std::chrono::duration<R, P> const & dur )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::duration<R, P> const & dur )
{
ar( _CEREAL_NVP("count", dur.count()) );
}
//! Loading std::chrono::duration
template <class Archive, class R, class P> inline
void load( Archive & ar, std::chrono::duration<R, P> & dur )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::duration<R, P> & dur )
{
R count;
ar( _CEREAL_NVP("count", count) );
@ -53,14 +53,14 @@ namespace cereal
//! Saving std::chrono::time_point
template <class Archive, class C, class D> inline
void save( Archive & ar, std::chrono::time_point<C, D> const & dur )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::time_point<C, D> const & dur )
{
ar( _CEREAL_NVP("time_since_epoch", dur.time_since_epoch()) );
}
//! Loading std::chrono::time_point
template <class Archive, class C, class D> inline
void load( Archive & ar, std::chrono::time_point<C, D> & dur )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::time_point<C, D> & dur )
{
D elapsed;
ar( _CEREAL_NVP("time_since_epoch", elapsed) );

View File

@ -37,7 +37,7 @@ namespace cereal
//! Serialization for enum types
template<class Archive, class T> inline
typename std::enable_if<std::is_enum<T>::value, void>::type
serialize(Archive & ar, T & t)
CEREAL_SERIALIZE_FUNCTION_NAME(Archive & ar, T & t)
{
ar( reinterpret_cast<typename std::underlying_type<T>::type &>(t) );
}
@ -45,7 +45,7 @@ namespace cereal
//! Serialization for raw pointers
/*! This exists only to throw a static_assert to let users know we don't support raw pointers. */
template <class Archive, class T> inline
void serialize( Archive &, T * & )
void CEREAL_SERIALIZE_FUNCTION_NAME( Archive &, T * & )
{
static_assert(cereal::traits::detail::delay_static_assert<T>::value,
"Cereal does not support serializing raw pointers - please use a smart pointer");
@ -74,7 +74,7 @@ namespace cereal
//! Serialization for C style arrays
template <class Archive, class T> inline
typename std::enable_if<std::is_array<T>::value, void>::type
serialize(Archive & ar, T & array)
CEREAL_SERIALIZE_FUNCTION_NAME(Archive & ar, T & array)
{
common_detail::serializeArray( ar, array,
std::integral_constant<bool, traits::is_output_serializable<BinaryData<T>, Archive>::value &&

View File

@ -36,7 +36,7 @@ namespace cereal
{
//! Serializing (save) for std::complex
template <class Archive, class T> inline
void save( Archive & ar, std::complex<T> const & comp )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::complex<T> const & comp )
{
ar( _CEREAL_NVP("real", comp.real()),
_CEREAL_NVP("imag", comp.imag()) );
@ -44,7 +44,7 @@ namespace cereal
//! Serializing (load) for std::complex
template <class Archive, class T> inline
void load( Archive & ar, std::complex<T> & bits )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::complex<T> & bits )
{
T real, imag;
ar( _CEREAL_NVP("real", real),

View File

@ -37,7 +37,7 @@ namespace cereal
{
//! Saving for std::deque
template <class Archive, class T, class A> inline
void save( Archive & ar, std::deque<T, A> const & deque )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::deque<T, A> const & deque )
{
ar( make_size_tag( static_cast<size_type>(deque.size()) ) );
@ -47,7 +47,7 @@ namespace cereal
//! Loading for std::deque
template <class Archive, class T, class A> inline
void load( Archive & ar, std::deque<T, A> & deque )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::deque<T, A> & deque )
{
size_type size;
ar( make_size_tag( size ) );

View File

@ -37,7 +37,7 @@ namespace cereal
{
//! Saving for std::forward_list all other types
template <class Archive, class T, class A> inline
void save( Archive & ar, std::forward_list<T, A> const & forward_list )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::forward_list<T, A> const & forward_list )
{
// write the size - note that this is slow because we need to traverse
// the entire list. there are ways we could avoid this but this was chosen
@ -53,7 +53,7 @@ namespace cereal
//! Loading for std::forward_list all other types from
template <class Archive, class T, class A>
void load( Archive & ar, std::forward_list<T, A> & forward_list )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::forward_list<T, A> & forward_list )
{
size_type size;
ar( make_size_tag( size ) );

View File

@ -37,7 +37,7 @@ namespace cereal
{
//! Saving for std::list
template <class Archive, class T, class A> inline
void save( Archive & ar, std::list<T, A> const & list )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::list<T, A> const & list )
{
ar( make_size_tag( static_cast<size_type>(list.size()) ) );
@ -47,7 +47,7 @@ namespace cereal
//! Loading for std::list
template <class Archive, class T, class A> inline
void load( Archive & ar, std::list<T, A> & list )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::list<T, A> & list )
{
size_type size;
ar( make_size_tag( size ) );

View File

@ -76,14 +76,14 @@ namespace cereal
//! Saving for std::map
template <class Archive, class K, class T, class C, class A> inline
void save( Archive & ar, std::map<K, T, C, A> const & map )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::map<K, T, C, A> const & map )
{
map_detail::save( ar, map );
}
//! Loading for std::map
template <class Archive, class K, class T, class C, class A> inline
void load( Archive & ar, std::map<K, T, C, A> & map )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::map<K, T, C, A> & map )
{
map_detail::load( ar, map );
}
@ -91,7 +91,7 @@ namespace cereal
//! Saving for std::multimap
/*! @note serialization for this type is not guaranteed to preserve ordering */
template <class Archive, class K, class T, class C, class A> inline
void save( Archive & ar, std::multimap<K, T, C, A> const & multimap )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::multimap<K, T, C, A> const & multimap )
{
map_detail::save( ar, multimap );
}
@ -99,7 +99,7 @@ namespace cereal
//! Loading for std::multimap
/*! @note serialization for this type is not guaranteed to preserve ordering */
template <class Archive, class K, class T, class C, class A> inline
void load( Archive & ar, std::multimap<K, T, C, A> & multimap )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::multimap<K, T, C, A> & multimap )
{
map_detail::load( ar, multimap );
}

View File

@ -67,7 +67,7 @@ namespace cereal
construct( ptr )
{ }
inline void serialize( Archive & ar )
inline void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar )
{
::cereal::detail::Construct<T, Archive>::load_andor_construct( ar, construct );
}
@ -174,7 +174,7 @@ namespace cereal
//! Saving std::shared_ptr for non polymorphic types
template <class Archive, class T> inline
typename std::enable_if<!std::is_polymorphic<T>::value, void>::type
save( Archive & ar, std::shared_ptr<T> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::shared_ptr<T> const & ptr )
{
ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper( ptr )) );
}
@ -182,7 +182,7 @@ namespace cereal
//! Loading std::shared_ptr, case when no user load and construct for non polymorphic types
template <class Archive, class T> inline
typename std::enable_if<!std::is_polymorphic<T>::value, void>::type
load( Archive & ar, std::shared_ptr<T> & ptr )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::shared_ptr<T> & ptr )
{
ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper( ptr )) );
}
@ -190,7 +190,7 @@ namespace cereal
//! Saving std::weak_ptr for non polymorphic types
template <class Archive, class T> inline
typename std::enable_if<!std::is_polymorphic<T>::value, void>::type
save( Archive & ar, std::weak_ptr<T> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::weak_ptr<T> const & ptr )
{
auto const sptr = ptr.lock();
ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper( sptr )) );
@ -199,7 +199,7 @@ namespace cereal
//! Loading std::weak_ptr for non polymorphic types
template <class Archive, class T> inline
typename std::enable_if<!std::is_polymorphic<T>::value, void>::type
load( Archive & ar, std::weak_ptr<T> & ptr )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::weak_ptr<T> & ptr )
{
std::shared_ptr<T> sptr;
ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper( sptr )) );
@ -209,7 +209,7 @@ namespace cereal
//! Saving std::unique_ptr for non polymorphic types
template <class Archive, class T, class D> inline
typename std::enable_if<!std::is_polymorphic<T>::value, void>::type
save( Archive & ar, std::unique_ptr<T, D> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unique_ptr<T, D> const & ptr )
{
ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper( ptr )) );
}
@ -217,7 +217,7 @@ namespace cereal
//! Loading std::unique_ptr, case when user provides load_and_construct for non polymorphic types
template <class Archive, class T, class D> inline
typename std::enable_if<!std::is_polymorphic<T>::value, void>::type
load( Archive & ar, std::unique_ptr<T, D> & ptr )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unique_ptr<T, D> & ptr )
{
ar( _CEREAL_NVP("ptr_wrapper", memory_detail::make_ptr_wrapper( ptr )) );
}
@ -228,7 +228,7 @@ namespace cereal
//! Saving std::shared_ptr (wrapper implementation)
/*! @internal */
template <class Archive, class T> inline
void save( Archive & ar, memory_detail::PtrWrapper<std::shared_ptr<T> const &> const & wrapper )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, memory_detail::PtrWrapper<std::shared_ptr<T> const &> const & wrapper )
{
auto & ptr = wrapper.ptr;
@ -245,7 +245,7 @@ namespace cereal
/*! @internal */
template <class Archive, class T> inline
typename std::enable_if<traits::has_load_and_construct<T, Archive>::value, void>::type
load( Archive & ar, memory_detail::PtrWrapper<std::shared_ptr<T> &> & wrapper )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, memory_detail::PtrWrapper<std::shared_ptr<T> &> & wrapper )
{
auto & ptr = wrapper.ptr;
@ -292,7 +292,7 @@ namespace cereal
/*! @internal */
template <class Archive, class T> inline
typename std::enable_if<!traits::has_load_and_construct<T, Archive>::value, void>::type
load( Archive & ar, memory_detail::PtrWrapper<std::shared_ptr<T> &> & wrapper )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, memory_detail::PtrWrapper<std::shared_ptr<T> &> & wrapper )
{
auto & ptr = wrapper.ptr;
@ -313,7 +313,7 @@ namespace cereal
//! Saving std::unique_ptr (wrapper implementation)
/*! @internal */
template <class Archive, class T, class D> inline
void save( Archive & ar, memory_detail::PtrWrapper<std::unique_ptr<T, D> const &> const & wrapper )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, memory_detail::PtrWrapper<std::unique_ptr<T, D> const &> const & wrapper )
{
auto & ptr = wrapper.ptr;
@ -334,7 +334,7 @@ namespace cereal
/*! @internal */
template <class Archive, class T, class D> inline
typename std::enable_if<traits::has_load_and_construct<T, Archive>::value, void>::type
load( Archive & ar, memory_detail::PtrWrapper<std::unique_ptr<T, D> &> & wrapper )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, memory_detail::PtrWrapper<std::unique_ptr<T, D> &> & wrapper )
{
uint8_t isValid;
ar( _CEREAL_NVP("valid", isValid) );
@ -368,7 +368,7 @@ namespace cereal
/*! @internal */
template <class Archive, class T, class D> inline
typename std::enable_if<!traits::has_load_and_construct<T, Archive>::value, void>::type
load( Archive & ar, memory_detail::PtrWrapper<std::unique_ptr<T, D> &> & wrapper )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, memory_detail::PtrWrapper<std::unique_ptr<T, D> &> & wrapper )
{
uint8_t isValid;
ar( _CEREAL_NVP("valid", isValid) );

View File

@ -204,7 +204,7 @@ namespace cereal
//! Saving std::shared_ptr for polymorphic types, abstract
template <class Archive, class T> inline
typename std::enable_if<std::is_polymorphic<T>::value && std::is_abstract<T>::value, void>::type
save( Archive & ar, std::shared_ptr<T> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::shared_ptr<T> const & ptr )
{
if(!ptr)
{
@ -230,7 +230,7 @@ namespace cereal
//! Saving std::shared_ptr for polymorphic types, not abstract
template <class Archive, class T> inline
typename std::enable_if<std::is_polymorphic<T>::value && !std::is_abstract<T>::value, void>::type
save( Archive & ar, std::shared_ptr<T> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::shared_ptr<T> const & ptr )
{
if(!ptr)
{
@ -265,7 +265,7 @@ namespace cereal
//! Loading std::shared_ptr for polymorphic types
template <class Archive, class T> inline
typename std::enable_if<std::is_polymorphic<T>::value, void>::type
load( Archive & ar, std::shared_ptr<T> & ptr )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::shared_ptr<T> & ptr )
{
std::uint32_t nameid;
ar( _CEREAL_NVP("polymorphic_id", nameid) );
@ -283,7 +283,7 @@ namespace cereal
//! Saving std::weak_ptr for polymorphic types
template <class Archive, class T> inline
typename std::enable_if<std::is_polymorphic<T>::value, void>::type
save( Archive & ar, std::weak_ptr<T> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::weak_ptr<T> const & ptr )
{
auto const sptr = ptr.lock();
ar( _CEREAL_NVP("locked_ptr", sptr) );
@ -292,7 +292,7 @@ namespace cereal
//! Loading std::weak_ptr for polymorphic types
template <class Archive, class T> inline
typename std::enable_if<std::is_polymorphic<T>::value, void>::type
load( Archive & ar, std::weak_ptr<T> & ptr )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::weak_ptr<T> & ptr )
{
std::shared_ptr<T> sptr;
ar( _CEREAL_NVP("locked_ptr", sptr) );
@ -302,7 +302,7 @@ namespace cereal
//! Saving std::unique_ptr for polymorphic types that are abstract
template <class Archive, class T, class D> inline
typename std::enable_if<std::is_polymorphic<T>::value && std::is_abstract<T>::value, void>::type
save( Archive & ar, std::unique_ptr<T, D> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unique_ptr<T, D> const & ptr )
{
if(!ptr)
{
@ -328,7 +328,7 @@ namespace cereal
//! Saving std::unique_ptr for polymorphic types, not abstract
template <class Archive, class T, class D> inline
typename std::enable_if<std::is_polymorphic<T>::value && !std::is_abstract<T>::value, void>::type
save( Archive & ar, std::unique_ptr<T, D> const & ptr )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unique_ptr<T, D> const & ptr )
{
if(!ptr)
{
@ -363,7 +363,7 @@ namespace cereal
//! Loading std::unique_ptr, case when user provides load_and_construct for polymorphic types
template <class Archive, class T, class D> inline
typename std::enable_if<std::is_polymorphic<T>::value, void>::type
load( Archive & ar, std::unique_ptr<T, D> & ptr )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unique_ptr<T, D> & ptr )
{
std::uint32_t nameid;
ar( _CEREAL_NVP("polymorphic_id", nameid) );

View File

@ -91,14 +91,14 @@ namespace cereal
//! Saving for std::queue
template <class Archive, class T, class C> inline
void save( Archive & ar, std::queue<T, C> const & queue )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::queue<T, C> const & queue )
{
ar( _CEREAL_NVP("container", queue_detail::container( queue )) );
}
//! Loading for std::queue
template <class Archive, class T, class C> inline
void load( Archive & ar, std::queue<T, C> & queue )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::queue<T, C> & queue )
{
C container;
ar( _CEREAL_NVP("container", container) );
@ -107,7 +107,7 @@ namespace cereal
//! Saving for std::priority_queue
template <class Archive, class T, class C, class Comp> inline
void save( Archive & ar, std::priority_queue<T, C, Comp> const & priority_queue )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::priority_queue<T, C, Comp> const & priority_queue )
{
ar( _CEREAL_NVP("comparator", queue_detail::comparator( priority_queue )) );
ar( _CEREAL_NVP("container", queue_detail::container( priority_queue )) );
@ -115,7 +115,7 @@ namespace cereal
//! Loading for std::priority_queue
template <class Archive, class T, class C, class Comp> inline
void load( Archive & ar, std::priority_queue<T, C, Comp> & priority_queue )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::priority_queue<T, C, Comp> & priority_queue )
{
Comp comparator;
ar( _CEREAL_NVP("comparator", comparator) );

View File

@ -73,28 +73,28 @@ namespace cereal
//! Saving for std::set
template <class Archive, class K, class C, class A> inline
void save( Archive & ar, std::set<K, C, A> const & set )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::set<K, C, A> const & set )
{
set_detail::save( ar, set );
}
//! Loading for std::set
template <class Archive, class K, class C, class A> inline
void load( Archive & ar, std::set<K, C, A> & set )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::set<K, C, A> & set )
{
set_detail::load( ar, set );
}
//! Saving for std::multiset
template <class Archive, class K, class C, class A> inline
void save( Archive & ar, std::multiset<K, C, A> const & multiset )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::multiset<K, C, A> const & multiset )
{
set_detail::save( ar, multiset );
}
//! Loading for std::multiset
template <class Archive, class K, class C, class A> inline
void load( Archive & ar, std::multiset<K, C, A> & multiset )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::multiset<K, C, A> & multiset )
{
set_detail::load( ar, multiset );
}

View File

@ -58,14 +58,14 @@ namespace cereal
//! Saving for std::stack
template <class Archive, class T, class C> inline
void save( Archive & ar, std::stack<T, C> const & stack )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::stack<T, C> const & stack )
{
ar( _CEREAL_NVP("container", stack_detail::container( stack )) );
}
//! Loading for std::stack
template <class Archive, class T, class C> inline
void load( Archive & ar, std::stack<T, C> & stack )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::stack<T, C> & stack )
{
C container;
ar( _CEREAL_NVP("container", container) );

View File

@ -38,7 +38,7 @@ namespace cereal
//! Serialization for basic_string types, if binary data is supported
template<class Archive, class CharT, class Traits, class Alloc> inline
typename std::enable_if<traits::is_output_serializable<BinaryData<CharT>, Archive>::value, void>::type
save(Archive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
CEREAL_SAVE_FUNCTION_NAME(Archive & ar, std::basic_string<CharT, Traits, Alloc> const & str)
{
// Save number of chars + the data
ar( make_size_tag( static_cast<size_type>(str.size()) ) );
@ -48,7 +48,7 @@ namespace cereal
//! Serialization for basic_string types, if binary data is supported
template<class Archive, class CharT, class Traits, class Alloc> inline
typename std::enable_if<traits::is_input_serializable<BinaryData<CharT>, Archive>::value, void>::type
load(Archive & ar, std::basic_string<CharT, Traits, Alloc> & str)
CEREAL_LOAD_FUNCTION_NAME(Archive & ar, std::basic_string<CharT, Traits, Alloc> & str)
{
size_type size;
ar( make_size_tag( size ) );

View File

@ -63,7 +63,7 @@ namespace cereal
//! Serializing for std::tuple
template <class Archive, class ... Types> inline
void serialize( Archive & ar, std::tuple<Types...> & tuple )
void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, std::tuple<Types...> & tuple )
{
tuple_detail::serialize<std::tuple_size<std::tuple<Types...>>::value>::template apply( ar, tuple );
}

View File

@ -70,28 +70,28 @@ namespace cereal
//! Saving for std::unordered_map
template <class Archive, class K, class T, class H, class KE, class A> inline
void save( Archive & ar, std::unordered_map<K, T, H, KE, A> const & unordered_map )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_map<K, T, H, KE, A> const & unordered_map )
{
unordered_map_detail::save( ar, unordered_map );
}
//! Loading for std::unordered_map
template <class Archive, class K, class T, class H, class KE, class A> inline
void load( Archive & ar, std::unordered_map<K, T, H, KE, A> & unordered_map )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_map<K, T, H, KE, A> & unordered_map )
{
unordered_map_detail::load( ar, unordered_map );
}
//! Saving for std::unordered_multimap
template <class Archive, class K, class T, class H, class KE, class A> inline
void save( Archive & ar, std::unordered_multimap<K, T, H, KE, A> const & unordered_multimap )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_multimap<K, T, H, KE, A> const & unordered_multimap )
{
unordered_map_detail::save( ar, unordered_multimap );
}
//! Loading for std::unordered_multimap
template <class Archive, class K, class T, class H, class KE, class A> inline
void load( Archive & ar, std::unordered_multimap<K, T, H, KE, A> & unordered_multimap )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_multimap<K, T, H, KE, A> & unordered_multimap )
{
unordered_map_detail::load( ar, unordered_multimap );
}

View File

@ -69,28 +69,28 @@ namespace cereal
//! Saving for std::unordered_set
template <class Archive, class K, class H, class KE, class A> inline
void save( Archive & ar, std::unordered_set<K, H, KE, A> const & unordered_set )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_set<K, H, KE, A> const & unordered_set )
{
unordered_set_detail::save( ar, unordered_set );
}
//! Loading for std::unordered_set
template <class Archive, class K, class H, class KE, class A> inline
void load( Archive & ar, std::unordered_set<K, H, KE, A> & unordered_set )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_set<K, H, KE, A> & unordered_set )
{
unordered_set_detail::load( ar, unordered_set );
}
//! Saving for std::unordered_multiset
template <class Archive, class K, class H, class KE, class A> inline
void save( Archive & ar, std::unordered_multiset<K, H, KE, A> const & unordered_multiset )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_multiset<K, H, KE, A> const & unordered_multiset )
{
unordered_set_detail::save( ar, unordered_multiset );
}
//! Loading for std::unordered_multiset
template <class Archive, class K, class H, class KE, class A> inline
void load( Archive & ar, std::unordered_multiset<K, H, KE, A> & unordered_multiset )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_multiset<K, H, KE, A> & unordered_multiset )
{
unordered_set_detail::load( ar, unordered_multiset );
}

View File

@ -37,7 +37,7 @@ namespace cereal
{
//! Serializing for std::pair
template <class Archive, class T1, class T2> inline
void serialize( Archive & ar, std::pair<T1, T2> & pair )
void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, std::pair<T1, T2> & pair )
{
ar( _CEREAL_NVP("first", pair.first),
_CEREAL_NVP("second", pair.second) );

View File

@ -39,7 +39,7 @@ namespace cereal
template <class Archive, class T, class A> inline
typename std::enable_if<traits::is_output_serializable<BinaryData<T>, Archive>::value
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, void>::type
save( Archive & ar, std::vector<T, A> const & vector )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector<T, A> const & vector )
{
ar( make_size_tag( static_cast<size_type>(vector.size()) ) ); // number of elements
ar( binary_data( vector.data(), vector.size() * sizeof(T) ) );
@ -49,7 +49,7 @@ namespace cereal
template <class Archive, class T, class A> inline
typename std::enable_if<traits::is_input_serializable<BinaryData<T>, Archive>::value
&& std::is_arithmetic<T>::value && !std::is_same<T, bool>::value, void>::type
load( Archive & ar, std::vector<T, A> & vector )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector<T, A> & vector )
{
size_type vectorSize;
ar( make_size_tag( vectorSize ) );
@ -62,7 +62,7 @@ namespace cereal
template <class Archive, class T, class A> inline
typename std::enable_if<!traits::is_output_serializable<BinaryData<T>, Archive>::value
|| !std::is_arithmetic<T>::value, void>::type
save( Archive & ar, std::vector<T, A> const & vector )
CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector<T, A> const & vector )
{
ar( make_size_tag( static_cast<size_type>(vector.size()) ) ); // number of elements
for( auto it = vector.begin(), end = vector.end(); it != end; ++it )
@ -73,7 +73,7 @@ namespace cereal
template <class Archive, class T, class A> inline
typename std::enable_if<!traits::is_input_serializable<BinaryData<T>, Archive>::value
|| !std::is_arithmetic<T>::value, void>::type
load( Archive & ar, std::vector<T, A> & vector )
CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector<T, A> & vector )
{
size_type size;
ar( make_size_tag( size ) );
@ -85,7 +85,7 @@ namespace cereal
//! Serialization for bool vector types
template <class Archive, class A> inline
void save( Archive & ar, std::vector<bool, A> const & vector )
void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector<bool, A> const & vector )
{
ar( make_size_tag( static_cast<size_type>(vector.size()) ) ); // number of elements
for( auto it = vector.begin(), end = vector.end(); it != end; ++it )
@ -94,7 +94,7 @@ namespace cereal
//! Serialization for bool vector types
template <class Archive, class A> inline
void load( Archive & ar, std::vector<bool, A> & vector )
void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector<bool, A> & vector )
{
size_type size;
ar( make_size_tag( size ) );