ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Fields | Public Methods | Protected Fields | List of all members
StandardConverter Class Reference

#include <textlogger.hpp>

Inheritance diagram for StandardConverter:
[legend]
Collaboration diagram for StandardConverter:
[legend]

Class Description


Implements the interface ObjectConverter. Class TextLogger creates an instance of this type in the moment no other (custom) type was set prior to 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 98 of file textlogger.hpp.

Public Fields

std::vector< Formatter * > Formatters
 

Public Methods

ALIB_API StandardConverter ()
 
virtual ALIB_API ~StandardConverter () override
 
virtual ALIB_API void ConvertObjects (AString &target, Boxes &logables) override
 
virtual ALIB_API AutoSizesGetAutoSizes () override
 
virtual ALIB_API void ResetAutoSizes () override
 
- Public Methods inherited from ObjectConverter
virtual ~ObjectConverter ()
 

Protected Fields

int cntRecursionx
 

Constructor & Destructor Documentation

◆ StandardConverter()


Constructor.

Definition at line 43 of file textlogger.cpp.

◆ ~StandardConverter()

~StandardConverter ( )
overridevirtual

Virtual destructor.

Definition at line 57 of file textlogger.cpp.

Member Function Documentation

◆ ConvertObjects()

void ConvertObjects ( AString target,
Boxes logables 
)
overridevirtual

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

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

Implements ObjectConverter.

Definition at line 71 of file textlogger.cpp.

◆ GetAutoSizes()

AutoSizes * 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 ObjectConverter.

Definition at line 111 of file textlogger.cpp.

◆ ResetAutoSizes()

void ResetAutoSizes ( )
overridevirtual

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

Implements ObjectConverter.

Definition at line 119 of file textlogger.cpp.

Member Data Documentation

◆ cntRecursionx

int cntRecursionx
protected

A counter to detect recursive calls.

Definition at line 128 of file textlogger.hpp.

◆ Formatters

std::vector<Formatter*> 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 formatter 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.

The formatters created internally are set to unsafe locking mode (locking is switched-off). This is a small optimization and allowed due to the fact that class Lox is already thread-safe.

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 123 of file textlogger.hpp.


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