30 #ifndef CEREAL_DETAILS_HELPERS_HPP_ 31 #define CEREAL_DETAILS_HELPERS_HPP_ 33 #include <type_traits> 37 #include <unordered_map> 50 explicit Exception(
const std::string & what_ ) : std::runtime_error(what_) {}
51 explicit Exception(
const char * what_ ) : std::runtime_error(what_) {}
140 using Type =
typename std::conditional<std::is_array<typename std::remove_reference<T>::type>::value,
141 typename std::remove_cv<T>::type,
142 typename std::conditional<std::is_lvalue_reference<T>::value,
144 typename std::decay<T>::type>::type>::type;
147 static_assert( !std::is_base_of<detail::NameValuePairCore, T>::value,
148 "Cannot pair a name to a NameValuePair" );
170 template<
class Archive,
class T>
inline 172 std::enable_if<std::is_same<Archive, ::cereal::BinaryInputArchive>::value ||
173 std::is_same<Archive, ::cereal::BinaryOutputArchive>::value,
177 return std::forward<T>(value);
183 template<
class Archive,
class T>
inline 185 std::enable_if<!std::is_same<Archive, ::cereal::BinaryInputArchive>::value &&
186 !std::is_same<Archive, ::cereal::BinaryOutputArchive>::value,
190 return {name, std::forward<T>(value)};
197 #define CEREAL_NVP_(name, value) ::cereal::make_nvp<Archive>(name, value) 211 using PT =
typename std::conditional<std::is_const<typename std::remove_pointer<T>::type>::value,
215 BinaryData( T && d, uint64_t s ) : data(
std::forward<T>(d)), size(s) {}
237 virtual void rtti() {}
249 virtual void rtti() {}
257 static const int32_t msb_32bit = 0x80000000;
258 static const int32_t msb2_32bit = 0x40000000;
276 using Type =
typename std::conditional<std::is_lvalue_reference<T>::value,
278 typename std::decay<T>::type>::type;
283 SizeTag( T && sz ) : size(std::forward<T>(sz)) {}
309 template <
class Key,
class Value>
312 using KeyType =
typename std::conditional<
313 std::is_lvalue_reference<Key>::value,
315 typename std::decay<Key>::type>::type;
317 using ValueType =
typename std::conditional<
318 std::is_lvalue_reference<Value>::value,
320 typename std::decay<Value>::type>::type;
324 MapItem( Key && key_, Value && value_ ) : key(
std::forward<Key>(key_)), value(
std::forward<Value>(value_)) {}
332 template <
class Archive>
inline 335 archive( make_nvp<Archive>(
"key", key),
336 make_nvp<Archive>(
"value", value) );
343 template <
class KeyType,
class ValueType>
inline 346 return {std::forward<KeyType>(key), std::forward<ValueType>(value)};
354 namespace{
struct version_binding_tag {}; }
360 template <
class T,
class BindingTag = version_binding_tag>
struct Version 362 static const std::uint32_t version = 0;
370 std::unordered_map<std::size_t, std::uint32_t> mapping;
372 std::uint32_t find( std::size_t hash, std::uint32_t version )
374 const auto result = mapping.emplace( hash, version );
375 return result.first->second;
381 #endif // CEREAL_DETAILS_HELPERS_HPP_ std::enable_if<!std::is_same< Archive,::cereal::BinaryInputArchive >::value &&!std::is_same< Archive,::cereal::BinaryOutputArchive >::value, NameValuePair< T > >::type make_nvp(const char *name, T &&value)
A specialization of make_nvp<> that actually creates an nvp for non-binary archives.
Definition: helpers.hpp:188
PT data
pointer to beginning of data
Definition: helpers.hpp:217
Definition: helpers.hpp:253
A wrapper around size metadata.
Definition: helpers.hpp:271
Traits struct for NVPs.
Definition: helpers.hpp:68
MapItem< KeyType, ValueType > make_map_item(KeyType &&key, ValueType &&value)
Create a MapItem so that human readable archives will group keys and values together.
Definition: helpers.hpp:344
A wrapper around a key and value for serializing data into maps.
Definition: helpers.hpp:310
Version information class.
Definition: helpers.hpp:360
typename std::conditional< std::is_const< typename std::remove_pointer< T >::type >::value, const void *, void * >::type PT
Definition: helpers.hpp:213
NameValuePair(char const *n, T &&v)
Constructs a new NameValuePair.
Definition: helpers.hpp:161
uint64_t size_type
The size type used by cereal.
Definition: helpers.hpp:59
Definition: access.hpp:40
std::enable_if< std::is_same< Archive,::cereal::BinaryInputArchive >::value||std::is_same< Archive,::cereal::BinaryOutputArchive >::value, T && >::type make_nvp(const char *, T &&value)
A specialization of make_nvp<> that simply forwards the value for binary archives.
Definition: helpers.hpp:175
For holding name value pairs.
Definition: helpers.hpp:135
Definition: polymorphic_impl.hpp:573
Preprocessor macros that can customise the cereal library.
void CEREAL_SERIALIZE_FUNCTION_NAME(Archive &archive)
Serialize the MapItem with the NVPs "key" and "value".
Definition: helpers.hpp:333
#define CEREAL_NOEXCEPT
Defines the CEREAL_NOEXCEPT macro to use instead of noexcept.
Definition: macros.hpp:116
A wrapper around data that can be serialized in a binary fashion.
Definition: helpers.hpp:207
Definition: helpers.hpp:228
uint64_t size
size in bytes
Definition: helpers.hpp:218
Holds all registered version information.
Definition: helpers.hpp:368
MapItem(Key &&key_, Value &&value_)
Construct a MapItem from a key and a value.
Definition: helpers.hpp:324
Internal polymorphism static object support.
An exception class thrown when things go wrong at runtime.
Definition: helpers.hpp:48
An output archive designed to save data in a compact binary representation.
Definition: binary.hpp:51