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_) {}
142 using Type =
typename std::conditional<std::is_array<typename std::remove_reference<T>::type>::value,
143 typename std::remove_cv<T>::type,
144 typename std::conditional<std::is_lvalue_reference<T>::value,
146 typename std::decay<T>::type>::type>::type;
149 static_assert( !std::is_base_of<detail::NameValuePairCore, T>::value,
150 "Cannot pair a name to a NameValuePair" );
172 template<
class Archive,
class T>
inline 174 std::enable_if<std::is_same<Archive, ::cereal::BinaryInputArchive>::value ||
175 std::is_same<Archive, ::cereal::BinaryOutputArchive>::value,
179 return std::forward<T>(value);
185 template<
class Archive,
class T>
inline 187 std::enable_if<!std::is_same<Archive, ::cereal::BinaryInputArchive>::value &&
188 !std::is_same<Archive, ::cereal::BinaryOutputArchive>::value,
192 return {name, std::forward<T>(value)};
199 #define CEREAL_NVP_(name, value) ::cereal::make_nvp<Archive>(name, value) 213 using PT =
typename std::conditional<std::is_const<typename std::remove_pointer<T>::type>::value,
217 BinaryData( T && d, uint64_t s ) : data(
std::forward<T>(d)), size(s) {}
239 virtual void rtti() {}
251 virtual void rtti() {}
259 static const int32_t msb_32bit = 0x80000000;
260 static const int32_t msb2_32bit = 0x40000000;
278 using Type =
typename std::conditional<std::is_lvalue_reference<T>::value,
280 typename std::decay<T>::type>::type;
285 SizeTag( T && sz ) : size(std::forward<T>(sz)) {}
311 template <
class Key,
class Value>
314 using KeyType =
typename std::conditional<
315 std::is_lvalue_reference<Key>::value,
317 typename std::decay<Key>::type>::type;
319 using ValueType =
typename std::conditional<
320 std::is_lvalue_reference<Value>::value,
322 typename std::decay<Value>::type>::type;
326 MapItem( Key && key_, Value && value_ ) : key(
std::forward<Key>(key_)), value(
std::forward<Value>(value_)) {}
334 template <
class Archive>
inline 337 archive( make_nvp<Archive>(
"key", key),
338 make_nvp<Archive>(
"value", value) );
345 template <
class KeyType,
class ValueType>
inline 348 return {std::forward<KeyType>(key), std::forward<ValueType>(value)};
356 namespace{
struct version_binding_tag {}; }
362 template <
class T,
class BindingTag = version_binding_tag>
struct Version 364 static const std::uint32_t version = 0;
372 std::unordered_map<std::size_t, std::uint32_t> mapping;
374 std::uint32_t find( std::size_t hash, std::uint32_t version )
376 const auto result = mapping.emplace( hash, version );
377 return result.first->second;
383 #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:190
PT data
pointer to beginning of data
Definition: helpers.hpp:219
Definition: helpers.hpp:255
A wrapper around size metadata.
Definition: helpers.hpp:273
Traits struct for NVPs.
Definition: helpers.hpp:70
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:346
A wrapper around a key and value for serializing data into maps.
Definition: helpers.hpp:312
Version information class.
Definition: helpers.hpp:362
typename std::conditional< std::is_const< typename std::remove_pointer< T >::type >::value, const void *, void * >::type PT
Definition: helpers.hpp:215
#define CEREAL_SIZE_TYPE
Determines the data type used for size_type.
Definition: macros.hpp:70
NameValuePair(char const *n, T &&v)
Constructs a new NameValuePair.
Definition: helpers.hpp:163
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:177
For holding name value pairs.
Definition: helpers.hpp:137
Definition: polymorphic_impl.hpp:649
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:335
#define CEREAL_NOEXCEPT
Defines the CEREAL_NOEXCEPT macro to use instead of noexcept.
Definition: macros.hpp:130
A wrapper around data that can be serialized in a binary fashion.
Definition: helpers.hpp:209
Definition: helpers.hpp:230
CEREAL_SIZE_TYPE size_type
The size type used by cereal.
Definition: helpers.hpp:61
uint64_t size
size in bytes
Definition: helpers.hpp:220
Holds all registered version information.
Definition: helpers.hpp:370
MapItem(Key &&key_, Value &&value_)
Construct a MapItem from a key and a value.
Definition: helpers.hpp:326
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