29template <
typename T>
inline void writeToStream(std::ostream &stream,
const T &
value) {
30 stream.write(
reinterpret_cast<const char *
>(&
value),
sizeof(T));
41template <
typename T>
inline void writeToStream(std::ostream &stream,
const std::vector<T> &
value,
size_t nvals) {
42 stream.write(
reinterpret_cast<const char *
>(
value.data()), nvals *
sizeof(T));
57 : m_ofstrm(ofstrm), m_strLengthSize(static_cast<uint64_t>(sizeof(int32_t))) {
59 throw std::runtime_error(
"BinaryStreamWriter: Output stream is in a bad "
60 "state. Cannot continue.");
127 m_ofstrm.write(
const_cast<char *
>(
value.data()),
static_cast<size_t>(length));
double value
The value of the point.
Assists with writing a binary file by providing standard overloads for the ostream operators (<<) to ...
std::ostream & m_ofstrm
Reference to the stream being written to.
BinaryStreamWriter & write(const std::vector< int16_t > &value, const size_t nvals)
write an array of int16_t from the given vector.
BinaryStreamWriter(std::ostream &ofstrm)
Constructor taking the stream to write.
uint64_t m_strLengthSize
The default size in bytes of the type used to encode the length of a string in the file.
BinaryStreamWriter & operator<<(const int16_t &value)
write a int16_t to the stream