A toolkit for working with phylogenetic data.
v0.24.0
Serializer Class Reference

#include <genesis/utils/io/serializer.hpp>

Detailed Description

Definition at line 57 of file utils/io/serializer.hpp.

Public Member Functions

 Serializer (std::string const &filename)
 
 Serializer (std::ostream &outstream)
 
 ~Serializer ()
 
bool bad () const
 
void close ()
 
bool eof () const
 
bool fail () const
 
void flush ()
 
bool good () const
 
bool is_open () const
 
 operator bool () const
 
template<typename T >
void put_float (const T v)
 Write a floating point number to the stream. More...
 
template<typename T >
void put_int (const T v)
 Write an integer number to the stream. More...
 
void put_null (const size_t n)
 Write n zero bytes (\0) to the stream. More...
 
template<typename T >
void put_plain (const T v)
 Write plain data to the stream, by casting it to a char array. More...
 
void put_raw (char const *data, size_t n)
 Write raw data, provided as a char array of length n, to the stream. More...
 
void put_raw_string (const std::string &v)
 Write raw data, provided as a string, to the stream, without writing its length. More...
 
void put_string (const std::string &v)
 Write a string, preceded by its length, to the stream. Use get_string() to read it. More...
 

Protected Attributes

std::ofstream outfile
 
std::ostream & outstream
 

Constructor & Destructor Documentation

◆ Serializer() [1/2]

Serializer ( std::string const &  filename)
inlineexplicit

Definition at line 65 of file utils/io/serializer.hpp.

◆ Serializer() [2/2]

Serializer ( std::ostream &  outstream)
inlineexplicit

Definition at line 71 of file utils/io/serializer.hpp.

◆ ~Serializer()

~Serializer ( )
inline

Definition at line 75 of file utils/io/serializer.hpp.

Member Function Documentation

◆ bad()

bool bad ( ) const
inline

Definition at line 104 of file utils/io/serializer.hpp.

◆ close()

void close ( )
inline

Definition at line 123 of file utils/io/serializer.hpp.

◆ eof()

bool eof ( ) const
inline

Definition at line 94 of file utils/io/serializer.hpp.

◆ fail()

bool fail ( ) const
inline

Definition at line 99 of file utils/io/serializer.hpp.

◆ flush()

void flush ( )
inline

Definition at line 118 of file utils/io/serializer.hpp.

◆ good()

bool good ( ) const
inline

Definition at line 89 of file utils/io/serializer.hpp.

◆ is_open()

bool is_open ( ) const
inline

Definition at line 113 of file utils/io/serializer.hpp.

◆ operator bool()

operator bool ( ) const
inline

Definition at line 84 of file utils/io/serializer.hpp.

◆ put_float()

void put_float ( const T  v)
inline

Write a floating point number to the stream.

Currently, this simply uses put_plain(), but future versions might change this behaviour and convert it to some machine-independent format.

Definition at line 197 of file utils/io/serializer.hpp.

◆ put_int()

void put_int ( const T  v)
inline

Write an integer number to the stream.

Currently, this simply uses put_plain(), but future versions might change this behaviour and use specific conversions (litte/big endianness, signed/unsigned) before writing.

Definition at line 185 of file utils/io/serializer.hpp.

◆ put_null()

void put_null ( const size_t  n)
inline

Write n zero bytes (\0) to the stream.

Definition at line 135 of file utils/io/serializer.hpp.

◆ put_plain()

void put_plain ( const T  v)
inline

Write plain data to the stream, by casting it to a char array.

Definition at line 173 of file utils/io/serializer.hpp.

◆ put_raw()

void put_raw ( char const *  data,
size_t  n 
)
inline

Write raw data, provided as a char array of length n, to the stream.

Definition at line 146 of file utils/io/serializer.hpp.

◆ put_raw_string()

void put_raw_string ( const std::string &  v)
inline

Write raw data, provided as a string, to the stream, without writing its length.

Definition at line 154 of file utils/io/serializer.hpp.

◆ put_string()

void put_string ( const std::string &  v)
inline

Write a string, preceded by its length, to the stream. Use get_string() to read it.

Definition at line 162 of file utils/io/serializer.hpp.

Member Data Documentation

◆ outfile

std::ofstream outfile
protected

Definition at line 207 of file utils/io/serializer.hpp.

◆ outstream

std::ostream& outstream
protected

Definition at line 208 of file utils/io/serializer.hpp.


The documentation for this class was generated from the following file: