30 #ifndef CEREAL_TYPES_BITSET_HPP_ 31 #define CEREAL_TYPES_BITSET_HPP_ 39 namespace bitset_detail
53 template <
class Archive,
size_t N,
54 traits::EnableIf<traits::is_output_serializable<BinaryData<std::uint32_t>, Archive>::value>
55 = traits::sfinae>
inline 58 ar(
CEREAL_NVP_(
"type", bitset_detail::type::bits) );
61 std::uint8_t chunk = 0;
62 std::uint8_t mask = 0x80;
65 for( std::size_t i = 0; i < N; ++i )
87 template <
class Archive,
size_t N,
88 traits::DisableIf<traits::is_output_serializable<BinaryData<std::uint32_t>, Archive>::value>
89 = traits::sfinae>
inline 94 auto const b = bits.to_ulong();
95 ar(
CEREAL_NVP_(
"type", bitset_detail::type::ulong) );
98 catch( std::overflow_error
const & )
102 auto const b = bits.to_ullong();
103 ar(
CEREAL_NVP_(
"type", bitset_detail::type::ullong) );
106 catch( std::overflow_error
const & )
108 ar(
CEREAL_NVP_(
"type", bitset_detail::type::string) );
115 template <
class Archive,
size_t N>
inline 123 case bitset_detail::type::ulong:
127 bits = std::bitset<N>( b );
130 case bitset_detail::type::ullong:
132 unsigned long long b;
134 bits = std::bitset<N>( b );
137 case bitset_detail::type::string:
141 bits = std::bitset<N>( b );
144 case bitset_detail::type::bits:
148 std::uint8_t chunk = 0;
149 std::uint8_t mask = 0;
155 for( std::size_t i = 0; i < N; ++i )
171 throw Exception(
"Invalid bitset data representation");
176 #endif // CEREAL_TYPES_BITSET_HPP_ #define CEREAL_NVP_(name, value)
Convenience for creating a templated NVP.
Definition: helpers.hpp:199
Definition: access.hpp:40
Main cereal functionality.
#define CEREAL_LOAD_FUNCTION_NAME
The deserialization (load) function name to search for.
Definition: macros.hpp:85
Support for types found in <string>
#define CEREAL_SAVE_FUNCTION_NAME
The serialization (save) function name to search for.
Definition: macros.hpp:92
An exception class thrown when things go wrong at runtime.
Definition: helpers.hpp:48
type
The type the bitset is encoded with.
Definition: bitset.hpp:43