dodo  0.0.1
A C++ library to create containerized Linux services
dodo::common::Puts Class Reference

Helper class to write strings in stream format, eg. More...

#include <puts.hpp>

Collaboration diagram for dodo::common::Puts:

Data Structures

struct  dec
 Put the stream in decimal mode. More...
 
struct  endl
 Mimics std::endl. More...
 
struct  fixed
 Put the stream in floating point fixed-format mode. More...
 
struct  hex
 Put the stream in hexadecimal mode. More...
 
struct  oct
 Put the stream in octal mode. More...
 
struct  scientific
 Put the stream in floating point scientific-format mode. More...
 
struct  setprecision
 Set the precision for floating point fixed format. More...
 
struct  setw
 Set the width of things to w characters. More...
 

Public Member Functions

 Puts ()
 Constructor inits to fixed format for double with precision 3. More...
 
 operator std::string () const
 Implicit Puts conversion to string for the compiler. More...
 
const Putsoperator<< (char c) const
 Append a char. More...
 
const Putsoperator<< (const char *s) const
 Append a C string. More...
 
const Putsoperator<< (const std::string &s) const
 Append a STL string. More...
 
const Putsoperator<< (dec) const
 Applies std::dec. More...
 
const Putsoperator<< (double d) const
 Append a double. More...
 
const Putsoperator<< (fixed) const
 Applies std::fixed. More...
 
const Putsoperator<< (float f) const
 Append a float. More...
 
const Putsoperator<< (hex) const
 Applies std::hex. More...
 
const Putsoperator<< (int i) const
 Append an integer. More...
 
const Putsoperator<< (long l) const
 Append a long. More...
 
const Putsoperator<< (long long l) const
 Append a long long. More...
 
const Putsoperator<< (oct) const
 Applies std::oct. More...
 
const Putsoperator<< (Puts::endl) const
 Appends std::endl. More...
 
const Putsoperator<< (scientific) const
 Applies std::scientific. More...
 
const Putsoperator<< (setprecision p) const
 Applies std::setprecision. More...
 
const Putsoperator<< (setw w) const
 Applies std::setw. More...
 
const Putsoperator<< (std::thread::id id) const
 Append a std::thread::id. More...
 
const Putsoperator<< (unsigned int i) const
 Append an unsigned integer. More...
 
const Putsoperator<< (unsigned long l) const
 Append an unsigned long. More...
 
const Putsoperator<< (unsigned long long l) const
 Append an unsigned long long. More...
 
const Putsoperator<< (void *p) const
 Append a void*. More...
 

Private Attributes

std::stringstream ss_
 Use a stringstream internally. More...
 

Detailed Description

Helper class to write strings in stream format, eg.

string s = common::Puts() << "integer: " << 3 << " double: " << common::Puts:setprecision(2) << 3.145;

which is very convenient in, for example, throwing exceptions, where the throw_Exception macro already inserts the "Puts() <<" in the expression, so one can write

throw Exception( "open failed with errorcode: " << errorcode );

Definition at line 46 of file puts.hpp.

Constructor & Destructor Documentation

◆ Puts()

dodo::common::Puts::Puts ( )
inline

Constructor inits to fixed format for double with precision 3.

Definition at line 123 of file puts.hpp.

References ss_.

Member Function Documentation

◆ operator std::string()

dodo::common::Puts::operator std::string ( ) const
inline

Implicit Puts conversion to string for the compiler.

Returns
The string build in stringstream ss_.

Definition at line 333 of file puts.hpp.

◆ operator<<() [1/21]

const Puts& dodo::common::Puts::operator<< ( char  c) const
inline

Append a char.

Parameters
cThe char
Returns
This Puts.

Definition at line 150 of file puts.hpp.

References ss_.

◆ operator<<() [2/21]

const Puts& dodo::common::Puts::operator<< ( const char *  s) const
inline

Append a C string.

Parameters
sThe const char*
Returns
This Puts.

Definition at line 140 of file puts.hpp.

References ss_.

◆ operator<<() [3/21]

const Puts& dodo::common::Puts::operator<< ( const std::string &  s) const
inline

Append a STL string.

Parameters
sThe string.
Returns
This Puts.

Definition at line 130 of file puts.hpp.

References ss_.

◆ operator<<() [4/21]

const Puts& dodo::common::Puts::operator<< ( dec  ) const
inline

Applies std::dec.

Returns
This Puts.

Definition at line 286 of file puts.hpp.

References ss_.

◆ operator<<() [5/21]

const Puts& dodo::common::Puts::operator<< ( double  d) const
inline

Append a double.

Parameters
dThe double to append.
Returns
This Puts.

Definition at line 230 of file puts.hpp.

References ss_.

◆ operator<<() [6/21]

const Puts& dodo::common::Puts::operator<< ( fixed  ) const
inline

Applies std::fixed.

Returns
This Puts.

Definition at line 268 of file puts.hpp.

References ss_.

◆ operator<<() [7/21]

const Puts& dodo::common::Puts::operator<< ( float  f) const
inline

Append a float.

Parameters
fThe float to append.
Returns
This Puts.

Definition at line 220 of file puts.hpp.

References ss_.

◆ operator<<() [8/21]

const Puts& dodo::common::Puts::operator<< ( hex  ) const
inline

Applies std::hex.

Returns
This Puts.

Definition at line 304 of file puts.hpp.

References ss_.

◆ operator<<() [9/21]

const Puts& dodo::common::Puts::operator<< ( int  i) const
inline

Append an integer.

Parameters
iThe int
Returns
This Puts.

Definition at line 160 of file puts.hpp.

References ss_.

◆ operator<<() [10/21]

const Puts& dodo::common::Puts::operator<< ( long  l) const
inline

Append a long.

Parameters
lThe long
Returns
This Puts.

Definition at line 170 of file puts.hpp.

References ss_.

◆ operator<<() [11/21]

const Puts& dodo::common::Puts::operator<< ( long long  l) const
inline

Append a long long.

Parameters
lThe long long
Returns
This Puts.

Definition at line 180 of file puts.hpp.

References ss_.

◆ operator<<() [12/21]

const Puts& dodo::common::Puts::operator<< ( oct  ) const
inline

Applies std::oct.

Returns
This Puts.

Definition at line 295 of file puts.hpp.

References ss_.

◆ operator<<() [13/21]

const Puts& dodo::common::Puts::operator<< ( Puts::endl  ) const
inline

Appends std::endl.

Returns
This Puts.

Definition at line 259 of file puts.hpp.

References ss_.

◆ operator<<() [14/21]

const Puts& dodo::common::Puts::operator<< ( scientific  ) const
inline

Applies std::scientific.

Returns
This Puts.

Definition at line 277 of file puts.hpp.

References ss_.

◆ operator<<() [15/21]

const Puts& dodo::common::Puts::operator<< ( setprecision  p) const
inline

Applies std::setprecision.

Parameters
pThe precision.
Returns
This Piuts.

Definition at line 324 of file puts.hpp.

References dodo::common::Puts::setprecision::p_, and ss_.

◆ operator<<() [16/21]

const Puts& dodo::common::Puts::operator<< ( setw  w) const
inline

Applies std::setw.

Parameters
wThe width.
Returns
This Piuts.

Definition at line 314 of file puts.hpp.

References ss_, and dodo::common::Puts::setw::w_.

◆ operator<<() [17/21]

const Puts& dodo::common::Puts::operator<< ( std::thread::id  id) const
inline

Append a std::thread::id.

Parameters
idThe std::thread::id to append.
Returns
This Puts.

Definition at line 250 of file puts.hpp.

References ss_.

◆ operator<<() [18/21]

const Puts& dodo::common::Puts::operator<< ( unsigned int  i) const
inline

Append an unsigned integer.

Parameters
iThe unsigned integer to append.
Returns
This Puts.

Definition at line 190 of file puts.hpp.

References ss_.

◆ operator<<() [19/21]

const Puts& dodo::common::Puts::operator<< ( unsigned long  l) const
inline

Append an unsigned long.

Parameters
lThe unsigned long to append.
Returns
This Puts.

Definition at line 200 of file puts.hpp.

References ss_.

◆ operator<<() [20/21]

const Puts& dodo::common::Puts::operator<< ( unsigned long long  l) const
inline

Append an unsigned long long.

Parameters
lThe unsigned long long to append.
Returns
This Puts.

Definition at line 210 of file puts.hpp.

References ss_.

◆ operator<<() [21/21]

const Puts& dodo::common::Puts::operator<< ( void *  p) const
inline

Append a void*.

Parameters
pThe void* to append.
Returns
This Puts.

Definition at line 240 of file puts.hpp.

References ss_.

Field Documentation

◆ ss_

std::stringstream dodo::common::Puts::ss_
mutableprivate

Use a stringstream internally.

Definition at line 333 of file puts.hpp.

Referenced by operator<<(), and Puts().


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