29 #ifndef CEREAL_ARCHIVES_BINARY_HPP_
30 #define CEREAL_ARCHIVES_BINARY_HPP_
65 auto const writtenSize =
static_cast<std::size_t
>( itsStream.rdbuf()->sputn( reinterpret_cast<const char*>( data ), size ) );
67 if(writtenSize != size)
68 throw Exception(
"Failed to write " + std::to_string(size) +
" bytes to output stream! Wrote " + std::to_string(writtenSize));
72 std::ostream & itsStream;
98 auto const readSize =
static_cast<std::size_t
>( itsStream.rdbuf()->sgetn( reinterpret_cast<char*>( data ), size ) );
101 throw Exception(
"Failed to read " + std::to_string(size) +
" bytes from input stream! Read " + std::to_string(readSize));
105 std::istream & itsStream;
112 template<
class T>
inline
113 typename std::enable_if<std::is_arithmetic<T>::value,
void>::type
116 ar.saveBinary(std::addressof(t),
sizeof(t));
120 template<
class T>
inline
121 typename std::enable_if<std::is_arithmetic<T>::value,
void>::type
124 ar.loadBinary(std::addressof(t),
sizeof(t));
128 template <
class Archive,
class T>
inline
136 template <
class Archive,
class T>
inline
144 template <
class T>
inline
147 ar.saveBinary( bd.data, static_cast<std::size_t>( bd.size ) );
151 template <
class T>
inline
154 ar.loadBinary(bd.data, static_cast<std::size_t>(bd.size));
165 #endif // CEREAL_ARCHIVES_BINARY_HPP_
#define CEREAL_SETUP_ARCHIVE_TRAITS(InputArchive, OutputArchive)
Sets up traits that relate an input archive to an output archive.
Definition: traits.hpp:169
#define CEREAL_SERIALIZE_FUNCTION_NAME
The serialization/deserialization function name to search for.
Definition: macros.hpp:51
Definition: access.hpp:39
#define CEREAL_REGISTER_ARCHIVE(Archive)
Registers a specific Archive type with cereal.
Definition: cereal.hpp:141
#define CEREAL_ARCHIVE_RESTRICT(INTYPE, OUTTYPE)
A macro to use to restrict which types of archives your function will work for.
Definition: traits.hpp:1260
Main cereal functionality.
#define CEREAL_LOAD_FUNCTION_NAME
The deserialization (load) function name to search for.
Definition: macros.hpp:58
void saveBinary(const void *data, std::size_t size)
Writes size bytes of data to the output stream.
Definition: binary.hpp:63
BinaryOutputArchive(std::ostream &stream)
Construct, outputting to the provided stream.
Definition: binary.hpp:57
The base output archive class.
Definition: cereal.hpp:234
#define CEREAL_SAVE_FUNCTION_NAME
The serialization (save) function name to search for.
Definition: macros.hpp:65
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