A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 (const std::string &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 ( const std::string &  filename)
inline

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

Serializer ( std::ostream &  outstream)
inline

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

~Serializer ( )
inline

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

Member Function Documentation

bool bad ( ) const
inline

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

void close ( )
inline

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

bool eof ( ) const
inline

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

bool fail ( ) const
inline

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

void flush ( )
inline

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

bool good ( ) const
inline

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

bool is_open ( ) const
inline

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

operator bool ( ) const
inline

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

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.

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.

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.

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.

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.

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.

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

std::ofstream outfile
protected

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

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: