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

#include <evo/impl/str.h>

Detailed Description

Holds integer 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) << 123 << ',' << FmtSetInt(fHEX, fPREFIX2, 4) << 10 << ',' << 20 << NL
<< FmtSetInt(fDEC, 5, '_') << 123 << NL
<< fOCT << fPREFIX0 << 5 << ',' << 456 << NL;
// Format same output to a string
String str;
String::Format(str) << 123 << ',' << FmtSetInt(fHEX, fPREFIX2, 4) << 10 << NL
<< FmtSetInt(fDEC, 5, '_') << 123 << NL
<< fOCT << fPREFIX0 << 5 << ',' << 456 << NL;
return 0;
}

Output:

123,0x000A,0x0014
__123
5,710

Public Member Functions

 FmtSetInt (int base=fbCURRENT, FmtBasePrefix prefix=fbpCURRENT, int width=-1, char ch=0)
 Main constructor with all attributes. More...
 
 FmtSetInt (int base, int width, char ch=0)
 Short constructor without prefix. More...
 
void merge (const FmtSetInt &src)
 Merge source attributes (used internally). More...
 
FmtSetIntreset ()
 Reset attributes to defaults (not unspecified). More...
 

Public Attributes

int base
 Base for formatting (default: fDEC) More...
 
char pad_ch
 Fill character, 0 if unspecified (use baseline or default) (default: '0') More...
 
int pad_width
 Width to fill to, 0 for none, -1 if unspecified (use baseline or default) (default: 0) More...
 
FmtBasePrefix prefix
 Formatting prefix type (default: fPREFIX0) More...
 

Constructor & Destructor Documentation

◆ FmtSetInt() [1/2]

FmtSetInt ( int  base = fbCURRENT,
FmtBasePrefix  prefix = fbpCURRENT,
int  width = -1,
char  ch = 0 
)
inline

Main constructor with all attributes.

Parameters
baseFormatting base to use (see FmtBase), fbCURRENT for unspecified (default: fDEC)
prefixFormatting prefix to use (see FmtBasePrefix), fbpCURRENT for unspecified (default: fPREFIX0)
widthWidth to pad to, -1 for unspecified (default: 0)
chPadding character to use, 0 for unspecified (default: '0')

◆ FmtSetInt() [2/2]

FmtSetInt ( int  base,
int  width,
char  ch = 0 
)
inline

Short constructor without prefix.

Parameters
baseFormatting base to use (see FmtBase), fbCURRENT for unspecified (default: fDEC)
widthWidth to pad to, -1 for unspecified (default: 0)
chPadding character to use, 0 for unspecified (default: '0')

Member Function Documentation

◆ merge()

void merge ( const FmtSetInt src)
inline

Merge source attributes (used internally).

  • This copies attributes from src that aren't "unspecified"
Parameters
srcSource to merge from

◆ reset()

FmtSetInt& reset ( )
inline

Reset attributes to defaults (not unspecified).

Member Data Documentation

◆ base

int base

Base for formatting (default: fDEC)

◆ pad_ch

char pad_ch

Fill character, 0 if unspecified (use baseline or default) (default: '0')

◆ pad_width

int pad_width

Width to fill to, 0 for none, -1 if unspecified (use baseline or default) (default: 0)

◆ prefix

FmtBasePrefix prefix

Formatting prefix type (default: fPREFIX0)


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