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

#include <evo/fmt.h>

Detailed Description

Text table formatter.

Output formats (see Type enum):

Classes

struct  CachedWriter
 Used to write formatted output with caching (used internally). More...
 
struct  Column
 Column information. More...
 
struct  Writer
 Used to write formatted output (used internally). More...
 

Public Types

enum  Type { tTEXT, tMARKDOWN }
 Formatting type to use. More...
 

Public Member Functions

 FmtTable ()
 Constructor. More...
 
 FmtTable (const Column *cols, SizeT size)
 Constructor calling add_columns(). More...
 
 FmtTable (const StringBase *names, SizeT size, int minwidth=0, FmtAlign align=fLEFT)
 Constructor calling add_columns(). More...
 
 FmtTable (const FmtTable &src)
 Copy constructor. More...
 
FmtTableadd_column (const Column &column)
 Add column to table. More...
 
FmtTableadd_column (const StringBase &name, FmtAlign align=fLEFT, int width=0)
 Add column to table. More...
 
FmtTableadd_column (const StringBase &name, int width)
 Add column to table. More...
 
FmtTableadd_columns (const Column *cols, SizeT size)
 Add multiple columns to table. More...
 
FmtTableadd_columns (const StringBase *names, SizeT size, int minwidth=0, FmtAlign align=fLEFT)
 Add multiple columns to table. More...
 
FmtTablecolumn_align (SizeT index, FmtAlign align)
 Set align value for column at given index. More...
 
FmtTablecolumn_minsize (SizeT index, int width)
 Update minimum width for column at given index. More...
 
FmtTablecolumn_reset ()
 Reset column information to defaults. More...
 
FmtTableoperator= (const FmtTable &src)
 Assignment operator. More...
 

Public Attributes

List< Columncolumns
 Column information More...
 

Member Enumeration Documentation

◆ Type

enum Type

Formatting type to use.

Enumerator
tTEXT 

Basic text table using whitespace to line up columns.

tMARKDOWN 

Text table using markdown syntax (GitHub style)

Constructor & Destructor Documentation

◆ FmtTable() [1/4]

FmtTable ( )
inline

Constructor.

◆ FmtTable() [2/4]

FmtTable ( const Column cols,
SizeT  size 
)
inline

Constructor calling add_columns().

Parameters
colsPointer to Column array to add from
sizeNumber of columns to add, 0 to stop on empty name

◆ FmtTable() [3/4]

FmtTable ( const StringBase names,
SizeT  size,
int  minwidth = 0,
FmtAlign  align = fLEFT 
)
inline

Constructor calling add_columns().

Parameters
namesPointer to array of strings to use for column names
sizeNumber of columns to add, 0 to stop on empty name
minwidthMinimum width to use for all added columns
alignAlignment to use for all added columns
Returns
This

◆ FmtTable() [4/4]

FmtTable ( const FmtTable src)
inline

Copy constructor.

Parameters
srcSource to copy

Member Function Documentation

◆ add_column() [1/3]

FmtTable& add_column ( const Column column)
inline

Add column to table.

Parameters
columnColumn to add
Returns
This

◆ add_column() [2/3]

FmtTable& add_column ( const StringBase name,
FmtAlign  align = fLEFT,
int  width = 0 
)
inline

Add column to table.

Parameters
nameColumn name
alignColumn alignment
widthColumn minimum width
Returns
This

◆ add_column() [3/3]

FmtTable& add_column ( const StringBase name,
int  width 
)
inline

Add column to table.

Parameters
nameColumn name
widthColumn minimum width
Returns
This

◆ add_columns() [1/2]

FmtTable& add_columns ( const Column cols,
SizeT  size 
)
inline

Add multiple columns to table.

Parameters
colsPointer to Column array to add from
sizeNumber of columns to add, 0 to stop on empty name
Returns
This

◆ add_columns() [2/2]

FmtTable& add_columns ( const StringBase names,
SizeT  size,
int  minwidth = 0,
FmtAlign  align = fLEFT 
)
inline

Add multiple columns to table.

Parameters
namesPointer to array of strings to use for column names
sizeNumber of columns to add, 0 to stop on empty name
minwidthMinimum width to use for all added columns
alignAlignment to use for all added columns
Returns
This

◆ column_align()

FmtTable& column_align ( SizeT  index,
FmtAlign  align 
)
inline

Set align value for column at given index.

  • Ignored if index is out of range
Parameters
indexColumn index
alignAlignment value
Returns
This

◆ column_minsize()

FmtTable& column_minsize ( SizeT  index,
int  width 
)
inline

Update minimum width for column at given index.

  • Ignored if index is out of range
  • This only grows the column width (only modified if new width is larger)
Parameters
indexColumn index
widthMinimum width to use
Returns
This

◆ column_reset()

FmtTable& column_reset ( )
inline

Reset column information to defaults.

Returns
This

◆ operator=()

FmtTable& operator= ( const FmtTable src)
inline

Assignment operator.

Parameters
srcSource to copy
Returns
This

Member Data Documentation

◆ columns

List<Column> columns

Column information


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