43#include <agrum/config.h>
52 is.read(
reinterpret_cast< char*
>(&size),
sizeof(size));
53 if (!is)
throw std::runtime_error(
"GumBinaryIO: failed to read vector size");
54 constexpr uint64_t kMaxVecSize = uint64_t(256) << 20;
55 if (size > kMaxVecSize)
56 throw std::runtime_error(
"GumBinaryIO: vector size exceeds 256 MB limit");
57 std::vector< uint8_t > vec(size);
58 is.read(
reinterpret_cast< char*
>(vec.data()),
static_cast< std::streamsize
>(size));
59 if (!is)
throw std::runtime_error(
"GumBinaryIO: failed to read vector data");
63 INLINE
void _writeVector_(std::ostream& os,
const std::vector< uint8_t >& vec) {
64 uint64_t size = vec.size();
65 os.write(
reinterpret_cast< const char*
>(&size),
sizeof(size));
66 os.write(
reinterpret_cast< const char*
>(vec.data()), size);
Shared binary I/O helpers for GUM (jgum/bgum) serialization.
aGrUM's inline/outline selection
gum is the global namespace for all aGrUM entities
void _writeVector_(std::ostream &os, const std::vector< uint8_t > &vec)
Writes a length-prefixed byte vector to a binary stream (bgum format).
std::vector< uint8_t > _readVector_(std::istream &is)
Reads a length-prefixed byte vector from a binary stream (bgum format).