Evo C++ Library v0.5.1
Public Types | Public Member Functions | Public Attributes | List of all members
StreamFormatter< T > Struct Template Reference

#include <evo/iobase.h>

Detailed Description

template<class T>
struct evo::StreamFormatter< T >

Stream output formatter with state.

Examples

Example using File:

#include <evo/io.h>
using namespace evo;
int main() {
File file("file.txt", oWRITE_NEW);
// Use a temporary formatter to write line: 7B,1C8
File::Format(file) << fHEX << 123 << ',' << 456 << NL;
// Create a formatter and use to write line: 001,002
out << FmtSetInt(fDEC, 3) << 1 << ',' << 2 << NL;
return 0;
}

Example using Console (stdout):

#include <evo/io.h>
using namespace evo;
int main() {
Console& c = con();
// Use a temporary formatter to write line: 7B,1C8
Console::Format(c.out) << fHEX << 123 << ',' << 456 << NL;
// Create a formatter and use to write line: 001,002
out << FmtSetInt(fDEC, 3) << 1 << ',' << 2 << NL;
return 0;
}

For more examples see: Stream Formatting

Public Types

typedef T Out
 Associated output stream type, type returned by write_out() More...
 
typedef T::Size Size
 Data size type (ulong) More...
 
typedef StreamFormatter< T > This
 This type. More...
 

Public Member Functions

 StreamFormatter (Out &out)
 Constructor. More...
 
 StreamFormatter (const This &src)
 Copy constructor. More...
 
Thisoperator<< (FmtAlign align)
 Set field alignment type to use. More...
 
Thisoperator<< (FmtWidth width)
 Set field width to use. More...
 
Thisoperator<< (const FmtSetField &field)
 Set field attributes to use. More...
 
Thisoperator<< (Newline nl)
 Write an explicit newline and flush stream. More...
 
Thisoperator<< (NewlineDefault nl)
 Write default newline and flush stream. More...
 
Thisoperator<< (const NewlineValue &nl)
 Write newline value and flush stream. More...
 
Thisoperator<< (Flush)
 Flush buffer by writing to stream. More...
 
Thisoperator<< (const FmtSetNull &null)
 Set attributes for null values. More...
 
Thisoperator<< (bool val)
 Append a bool value. More...
 
Thisoperator<< (char ch)
 Append a character. More...
 
Thisoperator<< (const FmtChar &ch)
 Append a repeated character. More...
 
Thisoperator<< (const FmtString &str)
 Append a formatted string. More...
 
Thisoperator<< (const char *val)
 Append a terminated string. More...
 
template<class TSize >
Thisoperator<< (const ListBase< char, TSize > &str)
 Append a string. More...
 
Thisoperator<< (FmtBase base)
 Set base for formatting integers. More...
 
Thisoperator<< (FmtBasePrefix prefix)
 Set prefix for formatting integers. More...
 
Thisoperator<< (const FmtSetInt &fmt_int)
 Set integer formatting attributes. More...
 
Thisoperator<< (short num)
 Append a formatted signed integer. More...
 
Thisoperator<< (int num)
 Append a formatted signed integer. More...
 
Thisoperator<< (long num)
 Append a formatted signed integer. More...
 
Thisoperator<< (longl num)
 Append a formatted signed integer. More...
 
Thisoperator<< (ushort num)
 Append a formatted unsigned integer. More...
 
Thisoperator<< (uint num)
 Append a formatted unsigned integer. More...
 
Thisoperator<< (ulong num)
 Append a formatted unsigned integer. More...
 
Thisoperator<< (ulongl num)
 Append a formatted unsigned integer. More...
 
template<class U >
Thisoperator<< (const IntegerT< U > &num)
 Append a formatted integer class. More...
 
Thisoperator<< (FmtPrecision prec)
 Set floating point formatting precision. More...
 
Thisoperator<< (const FmtSetFloat &fmt_flt)
 Set floating point formatting attributes. More...
 
Thisoperator<< (float num)
 Append a formatting floating point number. More...
 
Thisoperator<< (double num)
 Append a formatting floating point number. More...
 
Thisoperator<< (ldouble num)
 Append a formatting floating point number. More...
 
template<class U >
Thisoperator<< (const FloatT< U > &num)
 Append a formatted integer class. More...
 
Thisoperator<< (const FmtPtr &fmtptr)
 Writer formatted pointer field to stream. More...
 
Thisoperator<< (const FmtDump &fmtdump)
 Write formatted data dump to stream. More...
 
Thisoperator= (const This &src)
 Assignment operator copies attributes. More...
 
Outwrite_out ()
 Get parent output string. More...
 

Public Attributes

FmtAttribs fmt
 Formatting attributes (state) More...
 
Outout
 Associated output stream. More...
 

Member Typedef Documentation

◆ Out

typedef T Out

Associated output stream type, type returned by write_out()

◆ Size

typedef T::Size Size

Data size type (ulong)

◆ This

typedef StreamFormatter<T> This

This type.

Constructor & Destructor Documentation

◆ StreamFormatter() [1/2]

StreamFormatter ( Out out)
inline

Constructor.

Parameters
outOutput stream to associate and format to

◆ StreamFormatter() [2/2]

StreamFormatter ( const This src)
inline

Copy constructor.

  • This will reference the same stream as src
Parameters
srcSource to copy

Member Function Documentation

◆ operator<<() [1/34]

This& operator<< ( FmtAlign  align)
inline

Set field alignment type to use.

Parameters
alignAlignment type
Returns
This

◆ operator<<() [2/34]

This& operator<< ( FmtWidth  width)
inline

Set field width to use.

Parameters
widthField width to use
Returns
This

◆ operator<<() [3/34]

This& operator<< ( const FmtSetField field)
inline

Set field attributes to use.

Parameters
fieldField attributes
Returns
This

◆ operator<<() [4/34]

This& operator<< ( Newline  nl)
inline

Write an explicit newline and flush stream.

  • Use NL for default newline value, where default is set by the stream
Parameters
nlNewline value to write, NL_SYS for system default
Returns
This

◆ operator<<() [5/34]

This& operator<< ( NewlineDefault  nl)
inline

Write default newline and flush stream.

Parameters
nlDefault newline value (NL), where default is set by the stream
Returns
This

◆ operator<<() [6/34]

This& operator<< ( const NewlineValue nl)
inline

Write newline value and flush stream.

Parameters
nlNewline value to use, use current stream default if null
Returns
This

◆ operator<<() [7/34]

This& operator<< ( Flush  )
inline

Flush buffer by writing to stream.

  • This calls flush()
  • This is useful when writing a console prompt, flush so the prompt is immediately visible
Returns
This

◆ operator<<() [8/34]

This& operator<< ( const FmtSetNull null)
inline

Set attributes for null values.

Parameters
nullNull attributes
Returns
This

◆ operator<<() [9/34]

This& operator<< ( bool  val)
inline

Append a bool value.

  • Bool value is formatted as either "true" or "false" (without quotes)
  • This calls writetext()
Parameters
valBool value to append
Returns
This

◆ operator<<() [10/34]

This& operator<< ( char  ch)
inline

Append a character.

Parameters
chCharacter to append
Returns
This

◆ operator<<() [11/34]

This& operator<< ( const FmtChar ch)
inline

Append a repeated character.

Parameters
chCharacter info to append
Returns
This

◆ operator<<() [12/34]

This& operator<< ( const FmtString str)
inline

Append a formatted string.

Parameters
strString info to append
Returns
This

◆ operator<<() [13/34]

This& operator<< ( const char *  val)
inline

Append a terminated string.

  • Field attributes apply
Parameters
valString pointer, must be terminated, NULL for null string
Returns
This

◆ operator<<() [14/34]

This& operator<< ( const ListBase< char, TSize > &  str)
inline

Append a string.

  • Field attributes apply
Parameters
strString value
Returns
This

◆ operator<<() [15/34]

This& operator<< ( FmtBase  base)
inline

Set base for formatting integers.

Parameters
baseBase to use, see FmtBase
Returns
This

◆ operator<<() [16/34]

This& operator<< ( FmtBasePrefix  prefix)
inline

Set prefix for formatting integers.

Parameters
prefixInteger prefix to use, see FmtBasePrefix
Returns
This

◆ operator<<() [17/34]

This& operator<< ( const FmtSetInt fmt_int)
inline

Set integer formatting attributes.

Parameters
fmt_intInteger formatting attributes
Returns
This

◆ operator<<() [18/34]

This& operator<< ( short  num)
inline

Append a formatted signed integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [19/34]

This& operator<< ( int  num)
inline

Append a formatted signed integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [20/34]

This& operator<< ( long  num)
inline

Append a formatted signed integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [21/34]

This& operator<< ( longl  num)
inline

Append a formatted signed integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [22/34]

This& operator<< ( ushort  num)
inline

Append a formatted unsigned integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [23/34]

This& operator<< ( uint  num)
inline

Append a formatted unsigned integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [24/34]

This& operator<< ( ulong  num)
inline

Append a formatted unsigned integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [25/34]

This& operator<< ( ulongl  num)
inline

Append a formatted unsigned integer.

  • Integer and field attributes apply
Parameters
numInteger to format
Returns
This

◆ operator<<() [26/34]

This& operator<< ( const IntegerT< U > &  num)
inline

Append a formatted integer class.

  • Integer, field, and null attributes apply
Template Parameters
TInteger POD type, deduced from arguments
Parameters
numInteger to format (Int, UInt, etc)
Returns
This

◆ operator<<() [27/34]

This& operator<< ( FmtPrecision  prec)
inline

Set floating point formatting precision.

Parameters
precPrecision value, see FmtPrecision
Returns
This

◆ operator<<() [28/34]

This& operator<< ( const FmtSetFloat fmt_flt)
inline

Set floating point formatting attributes.

Parameters
fmt_fltFloating point formatting attributes
Returns
This

◆ operator<<() [29/34]

This& operator<< ( float  num)
inline

Append a formatting floating point number.

  • Floating point and field attributes apply
Parameters
numNumber to format
Returns
This

◆ operator<<() [30/34]

This& operator<< ( double  num)
inline

Append a formatting floating point number.

  • Floating point and field attributes apply
Parameters
numNumber to format
Returns
This

◆ operator<<() [31/34]

This& operator<< ( ldouble  num)
inline

Append a formatting floating point number.

  • Floating point and field attributes apply
Parameters
numNumber to format
Returns
This

◆ operator<<() [32/34]

This& operator<< ( const FloatT< U > &  num)
inline

Append a formatted integer class.

  • Floating point, field, and null attributes apply
Template Parameters
TFloating point POD type, deduced from arguments
Parameters
numNumber to format (Float, FloatD, etc)
Returns
This

◆ operator<<() [33/34]

This& operator<< ( const FmtPtr fmtptr)
inline

Writer formatted pointer field to stream.

Parameters
fmtptrPointer info
Returns
This

◆ operator<<() [34/34]

This& operator<< ( const FmtDump fmtdump)
inline

Write formatted data dump to stream.

Parameters
fmtdumpDump info
Returns
This

◆ operator=()

This& operator= ( const This src)
inline

Assignment operator copies attributes.

  • This does not copy the referenced string
Parameters
srcSource to copy attributes from
Returns
This

◆ write_out()

Out& write_out ( )
inline

Get parent output string.

Returns
Parent output string (this)

Member Data Documentation

◆ fmt

Formatting attributes (state)

◆ out

Out& out

Associated output stream.


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