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

#include <evo/impl/str.h>

Detailed Description

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

Explicitly format a floating pointer number.

Example

Example using FmtFloat

#include <evo/string.h>
using namespace evo;
int main() {
// Format string as: 01.230,4.56
String str;
str << FmtFloat(1.23, 3, 6) << ',' << 4.56;
return 0;
}

Public Types

typedef FloatT< T >::This FloatClass
 Number class type. More...
 
typedef T FloatPod
 Number POD type. More...
 
typedef FmtFieldFloat< T > FmtFieldType
 This type paired with field info. More...
 
typedef FmtFloatT< T > This
 This type. More...
 

Public Member Functions

 FmtFloatT (T num, int precision=fpCURRENT, int width=-1, char ch='0', char ch_sp=' ')
 Constructor for POD number type with all attributes. More...
 
 FmtFloatT (const FloatClass &num, int precision=fpCURRENT, int width=-1, char ch='0', char ch_sp=' ')
 Constructor for class number type (Float, etc) with all attributes. More...
 
Thiswidth (int width, char ch=0, char ch_sp=0)
 Helper for setting padding attributes. More...
 

Public Attributes

FmtSetFloat fmt
 
bool null
 
num
 

Member Typedef Documentation

◆ FloatClass

typedef FloatT<T>::This FloatClass

Number class type.

◆ FloatPod

typedef T FloatPod

Number POD type.

◆ FmtFieldType

This type paired with field info.

◆ This

typedef FmtFloatT<T> This

This type.

Constructor & Destructor Documentation

◆ FmtFloatT() [1/2]

FmtFloatT ( num,
int  precision = fpCURRENT,
int  width = -1,
char  ch = '0',
char  ch_sp = ' ' 
)
inline

Constructor for POD number type with all attributes.

Parameters
numNumber to format
precisionPrecision to use (number of digits after decimal), fPREC_AUTO for automatic (default: fPREC_AUTO)
widthWidth to pad to, -1 for unspecified (default: 0)
chPadding character to use, 0 for unspecified (default: '0')
ch_spPadding character to use with special value (inf or nan), 0 for unspecified (default: ' ')

◆ FmtFloatT() [2/2]

FmtFloatT ( const FloatClass num,
int  precision = fpCURRENT,
int  width = -1,
char  ch = '0',
char  ch_sp = ' ' 
)
inline

Constructor for class number type (Float, etc) with all attributes.

Parameters
numNumber to format
precisionPrecision to use (number of digits after decimal), fPREC_AUTO for automatic (default: fPREC_AUTO)
widthWidth to pad to, -1 for unspecified (default: 0)
chPadding character to use, 0 for unspecified (default: '0')
ch_spPadding character to use with special value (inf or nan), 0 for unspecified (default: ' ')

Member Function Documentation

◆ width()

This& width ( int  width,
char  ch = 0,
char  ch_sp = 0 
)
inline

Helper for setting padding attributes.

Parameters
widthWidth to pad to, -1 for unspecified (default: 0)
chPadding character to use, 0 for unspecified (default: '0')
ch_spPadding character to use with special value (inf or nan), 0 for unspecified (default: ' ')
Returns
This

Member Data Documentation

◆ fmt

◆ null

bool null

◆ num

T num

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