Evo C++ Library v0.5.1
Public Member Functions | Public Attributes | List of all members
FmtSetFloat Struct Reference

#include <evo/impl/str.h>

Detailed Description

Holds floating point formatting attributes.

Example
#include <evo/io.h>
#include <evo/string.h>
using namespace evo;
static Console& c = con();
int main() {
// Format to stream
Stream::Format(c.out) << 12.3 << ',' << FmtSetFloat(fPREC2, 6) << 10 << ',' << 20 << NL
<< fPREC3 << 1.23 << NL;
// Format same output to a string
String str;
String::Format(str) << 12.3 << ',' << FmtSetFloat(fPREC2, 6) << 10 << ',' << 20 << NL
<< fPREC3 << 1.23 << NL;
return 0;
}

Output:

12.3,010.00,020.00
12.300

Public Member Functions

 FmtSetFloat (int precision=fpCURRENT, int width=-1, char ch=0, char ch_sp=0)
 Constructor with all attributes. More...
 
void merge (const FmtSetFloat &src)
 Merge from source (used internally). More...
 
FmtSetFloatreset ()
 Reset to defaults. More...
 

Public Attributes

char pad_ch
 Padding character, 0 to ignore (leave current fill character) (default: '0') More...
 
char pad_ch_sp
 Padding character used with special value (inf or nan), 0 to ignore (leave current fill character) (default: ' ') More...
 
int pad_width
 Width to fill to, 0 for none, -1 to ignore (leave current width) (default: 0) More...
 
int precision
 Floating point precision (number of digits after decimal), fPREC_AUTO for automatic (default: fPREC_AUTO) More...
 

Constructor & Destructor Documentation

◆ FmtSetFloat()

FmtSetFloat ( int  precision = fpCURRENT,
int  width = -1,
char  ch = 0,
char  ch_sp = 0 
)
inline

Constructor with all attributes.

Parameters
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_spSpecial padding character to use when formatting special values like "inf" or "nan" (default: ' ')

Member Function Documentation

◆ merge()

void merge ( const FmtSetFloat src)
inline

Merge from source (used internally).

  • This copies explicit values from src, but ignores "leave current" values
Parameters
srcSource to copy

◆ reset()

FmtSetFloat& reset ( )
inline

Reset to defaults.

Returns
This

Member Data Documentation

◆ pad_ch

char pad_ch

Padding character, 0 to ignore (leave current fill character) (default: '0')

◆ pad_ch_sp

char pad_ch_sp

Padding character used with special value (inf or nan), 0 to ignore (leave current fill character) (default: ' ')

◆ pad_width

int pad_width

Width to fill to, 0 for none, -1 to ignore (leave current width) (default: 0)

◆ precision

int precision

Floating point precision (number of digits after decimal), fPREC_AUTO for automatic (default: fPREC_AUTO)


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