|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_IO_SERIALIZER_H_
2 #define GENESIS_UTILS_IO_SERIALIZER_H_
84 inline operator bool()
const
94 inline bool eof()
const
137 char* buffer =
new char[n];
138 std::fill(buffer, buffer+n,
'\0');
164 size_t len = v.length();
175 outstream.write(
reinterpret_cast<char const*
>( &v ),
sizeof(v));
214 #endif // include guard
Serializer(std::ostream &outstream)
Provides some valuable additions to STD.
void put_plain(const T v)
Write plain data to the stream, by casting it to a char array.
Serializer(std::string const &filename)
void file_output_stream(std::string const &file_name, std::ofstream &out_stream, std::ios_base::openmode mode=std::ios_base::out, bool create_dirs=true)
Helper function to obtain an output stream to a file.
void put_raw(char const *data, size_t n)
Write raw data, provided as a char array of length n, to the stream.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
void put_raw_string(const std::string &v)
Write raw data, provided as a string, to the stream, without writing its length.
void put_string(const std::string &v)
Write a string, preceded by its length, to the stream. Use get_string() to read it.
void put_null(const size_t n)
Write n zero bytes (\0) to the stream.
void put_int(const T v)
Write an integer number to the stream.
void put_float(const T v)
Write a floating point number to the stream.