ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
TFormat< TChar >::Field Struct Reference

Description:

template<typename TChar>
struct alib::strings::TFormat< TChar >::Field

Used to create temporary objects which are appended to AString instances.

Appends the given object to the AString using a defined 'field'-width. If the contents of the field is shorter than parameter width specifies, the field is filled with a corresponding amount of padChar characters.
Parameter alignment of type Alignment allows to left-, right- or center-align the contents of the field.

Note
In case, module ALib Boxing is not available, the field content parameter will be of type const String&.
Otherwise, box-function FAppend will be invoked on the given box internally to receive the string representation.
Therefore, it is mandatory, that for any type that is used with this class to be formatted in a field, this box-function has to be implemented. As documented with that interface, for types that are appendable to AString objects already, all that is needed is to use macro ALIB_BOXING_BOOTSTRAP_REGISTER_FAPPEND_FOR_APPENDABLE_TYPE with the type in the bootstrap section of an application.

Definition at line 166 of file format.hpp.

#include <format.hpp>

Collaboration diagram for TFormat< TChar >::Field:
[legend]

Public Field Index:

lang::Alignment alignment
 The alignment of the contents within the field.
 
integer fieldWidth
 The width of the field.
 
TChar padChar
 The characters used for padding the contents within the field.
 
Box theContent
 

Public Method Index:

 Field (Box content, integer pWidth, lang::Alignment pAlignment=lang::Alignment::Right, TChar fillChar=' ')
 

Field Details:

◆ alignment

template<typename TChar >
lang::Alignment alignment

The alignment of the contents within the field.

Definition at line 177 of file format.hpp.

◆ fieldWidth

template<typename TChar >
integer fieldWidth

The width of the field.

Definition at line 176 of file format.hpp.

◆ padChar

template<typename TChar >
TChar padChar

The characters used for padding the contents within the field.

Definition at line 178 of file format.hpp.

◆ theContent

template<typename TChar >
Box theContent

The content of the field. If module ALib Boxing is not available, this field is of type const TString<TChar>&

Definition at line 170 of file format.hpp.

Constructor(s) / Destructor Details::

◆ Field()

template<typename TChar >
Field ( Box content,
integer pWidth,
lang::Alignment pAlignment = lang::Alignment::Right,
TChar fillChar = ' ' )
inline

Constructor. Copies the parameters.

Parameters
contentThe contents of the field. If module ALib Boxing is not available, this field is of type const TString<TChar>&, otherwise of type Box .
pWidthThe width of the field
pAlignmentThe alignment of the contents within the field. Defaults to Alignment::Right Other options are Alignment::Left and Alignment::Center .
fillCharThe character used to fill the field up to its size. Defaults to ' ' (space).

Definition at line 196 of file format.hpp.


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