ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::lox::textlogger::StandardConverter Class Reference

Description:

Implements the interface ObjectConverter. Class TextLogger creates an instance of this type in the moment no other (custom) type was set before the first log statement.

This implementation uses two specialisations of class Formatter to format the given logables to a textual representation. The formatters (and their sequence!) are:

  1. FormatterPythonStyle
  2. FormatterJavaStyle

This way, standard text logging supports format strings in Python style as well as in Java style.

Definition at line 73 of file textlogger.inl.

Inheritance diagram for alib::lox::textlogger::StandardConverter:
[legend]
Collaboration diagram for alib::lox::textlogger::StandardConverter:
[legend]

Public Field Index:

std::vector< Formatter * > Formatters
 

Public Method Index:

ALIB_DLL StandardConverter ()
 Constructor.
 
virtual ALIB_DLL ~StandardConverter () override
 Virtual destructor.
 
virtual ALIB_DLL void ConvertObjects (AString &target, BoxesMA &logables) override
 
virtual ALIB_DLL AutoSizesGetAutoSizes () override
 
virtual ALIB_DLL void ResetAutoSizes () override
 Resets automatically widened tab stops and field widths of this converter.
 
virtual ALIB_DLL void SetAutoSizes (AutoSizes *autoSizes) override
 
- Public Method Index: inherited from alib::lox::textlogger::ObjectConverter
virtual ~ObjectConverter ()
 Destructs an object of this class.
 

Protected Field Index:

int cntRecursion
 A counter to detect recursive calls.
 

Field Details:

◆ cntRecursion

int alib::lox::textlogger::StandardConverter::cntRecursion
protected

A counter to detect recursive calls.

Definition at line 95 of file textlogger.inl.

◆ Formatters

std::vector<Formatter*> alib::lox::textlogger::StandardConverter::Formatters

A list of formatters used to "convert" logables to strings. By default, each entry contains a concatenated pair of formatters of types FormatterPythonStyle and FormatterJavaStyle are added in the constructor of this class.

A vector of formatters is needed to support recursive log calls. If recursion occurs during logging (aka the conversion of a logable triggers another logging operation), necessary formatters are created on the fly, respectively re-used from previous recursions. Their settings are cloned to those of the main formatters using Formatter::CloneSettings.

To use different formatters, it is recommended to implement a different converter type, instead of "patching" the linked and recursive formatters found in this vector.

Definition at line 91 of file textlogger.inl.

Constructor(s) / Destructor Details:

◆ StandardConverter()

alib::lox::textlogger::StandardConverter::StandardConverter ( )

Constructor.

Definition at line 50 of file textlogger.cpp.

◆ ~StandardConverter()

alib::lox::textlogger::StandardConverter::~StandardConverter ( )
overridevirtual

Virtual destructor.

Definition at line 59 of file textlogger.cpp.

Method Details:

◆ ConvertObjects()

void alib::lox::textlogger::StandardConverter::ConvertObjects ( AString & target,
BoxesMA & logables )
overridevirtual

The conversion method. Passes target and logables to the Formatters.

Parameters
targetAn AString that takes the result.
logablesThe objects to convert.

Implements alib::lox::textlogger::ObjectConverter.

Definition at line 70 of file textlogger.cpp.

◆ GetAutoSizes()

AutoSizes * alib::lox::textlogger::StandardConverter::GetAutoSizes ( )
overridevirtual

Checks if the first formatter in Formatters is of type FormatterPythonStyle. If so, its AutoSizes member is returned. If not, the method returns nullptr.

Returns
The auto sizes object of the main formatter.

Implements alib::lox::textlogger::ObjectConverter.

Definition at line 110 of file textlogger.cpp.

◆ ResetAutoSizes()

void alib::lox::textlogger::StandardConverter::ResetAutoSizes ( )
overridevirtual

Resets automatically widened tab stops and field widths of this converter.

Implements alib::lox::textlogger::ObjectConverter.

Definition at line 118 of file textlogger.cpp.

◆ SetAutoSizes()

void alib::lox::textlogger::StandardConverter::SetAutoSizes ( AutoSizes * autoSizes)
overridevirtual

Checks if the first formatter in Formatters is of type FormatterPythonStyle. If so, its AutoSizes member is set to the given external instance. Otherwise the call is ignored.

Parameters
autoSizesThe instance to use.

Implements alib::lox::textlogger::ObjectConverter.

Definition at line 103 of file textlogger.cpp.


The documentation for this class was generated from the following files: