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

#include <evo/impl/str.h>

Detailed Description

Holds field and alignment formatting attributes.

Example
#include <evo/io.h>
#include <evo/string.h>
using namespace evo;
static Console& c = con();
int main() {
// Format to stream
<< "Col A" << "Col B" << NL;
<< 1 << 2 << NL;
// Format same output to a string
String str;
<< "Col A" << "Col B" << NL;
<< 1 << 2 << NL;
return 0;
}

Output:

Col A Col B
1 2

Public Member Functions

 FmtSetField (FmtAlign align=faCURRENT, int width=-1, char fill=0)
 Main constructor. More...
 
 FmtSetField (int width, char fill=0)
 Short constructor with default alignment. More...
 
void merge (const FmtSetField &src)
 Merge source attributes (used internally). More...
 
FmtSetFieldreset ()
 Reset attributes to defaults (not unspecified). More...
 

Static Public Member Functions

static void setup_align (int &align_padleft, int &align_padright, int align_padding, const FmtSetField *field)
 Used to setup and calculate alignment padding (used internally). More...
 

Public Attributes

FmtAlign align
 Field alignment type (default: fLEFT) More...
 
char fill
 Field fill character to pad up to width (default: ' ') More...
 
int width
 Field width to align in (default: 0) More...
 

Constructor & Destructor Documentation

◆ FmtSetField() [1/2]

FmtSetField ( FmtAlign  align = faCURRENT,
int  width = -1,
char  fill = 0 
)
inline

Main constructor.

Parameters
alignAlignment type to use: fLEFT, fRIGHT, or fCENTER (faCURRENT for unspecified/default)
widthField character width, (-1 for unspecified/default)
fillField fill character to pad up to width (0 for unspecified/default)

◆ FmtSetField() [2/2]

FmtSetField ( int  width,
char  fill = 0 
)
inline

Short constructor with default alignment.

Parameters
widthField character width, (-1 for unspecified/default)
fillField fill character to pad up to width (0 for unspecified/default)

Member Function Documentation

◆ merge()

void merge ( const FmtSetField src)
inline

Merge source attributes (used internally).

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

◆ reset()

FmtSetField& reset ( )
inline

Reset attributes to defaults (not unspecified).

◆ setup_align()

static void setup_align ( int &  align_padleft,
int &  align_padright,
int  align_padding,
const FmtSetField field 
)
inlinestatic

Used to setup and calculate alignment padding (used internally).

Parameters
align_padleftSet to left-padding size [out]
align_padrightSet to right-padding size [out]
align_paddingPadding width to use
fieldField attribuets to use for alignment type (field->align), NULL for no alignment

Member Data Documentation

◆ align

FmtAlign align

Field alignment type (default: fLEFT)

◆ fill

char fill

Field fill character to pad up to width (default: ' ')

◆ width

int width

Field width to align in (default: 0)


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