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

#include <formatterpythonstyle.hpp>

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

Class Description


Implements a Formatter according to the formatting standards of the Python language .

Note
Inherited, public fields of parent class FormatterStdImpl provide important possibilities for changing the formatting behavior of instances of this class. Therefore, do not forget to consult the parent classes documentation.

In general, the original Python specification is covered quite well. However, there are some differences, some things are not possible (considering python being a scripting language) but then there are also found some very helpful extensions to that standard. Instead of repeating a complete documentation, please refer to the Python Documentation as the foundation and then take note of the following list of differences, extensions and general hints:

Reference Documentation

Exceptions
<b>aworx::lib::text::Exceptions</b>

Definition at line 327 of file formatterpythonstyle.hpp.

Inner Classes

struct  PlaceholderAttributesPS
 

Public Fields

AutoSizes Sizes
 
- Public Fields inherited from Formatter
NumberFormat AlternativeNumberFormat
 
NumberFormat DefaultNumberFormat
 
std::shared_ptr< FormatterNext
 
- Public Fields inherited from ThreadLock
NCString DbgOwnerFile =nullptr
 
NCString DbgOwnerFunc =nullptr
 
int DbgOwnerLine
 
uint16_t DbgRecursionWarningThreshold =10
 
integer DbgWarningAfterWaitTimeInMillis =2000L
 

Public Methods

ALIB_API FormatterPythonStyle ()
 
virtual ALIB_API FormatterStdImplClone () override
 
- Public Methods inherited from FormatterStdImpl
 FormatterStdImpl (const String &formatterClassName)
 
- Public Methods inherited from Formatter
virtual ~Formatter ()
 
ALIB_API BoxesAcquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
 
virtual ALIB_API void CloneSettings (Formatter &reference)
 
int CountAcquirements () const
 
template<typename... TArgs>
FormatterFormat (AString &target, TArgs &&... args)
 ALIB_THREADS. More...
 
ALIB_API FormatterFormatArgs (AString &target)
 
FormatterFormatArgs (AString &target, const Boxes &args)
 
ALIB_API void Release ()
 defined(ALIB_DOX) More...
 
ALIB_API void ReplaceDefault (Formatter *newFormatter)
 
- Public Methods inherited from ThreadLock
ALIB_API ThreadLock (Safeness safeness=Safeness::Safe)
 
ALIB_API ~ThreadLock ()
 
ALIB_API void Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
 
int CountAcquirements () const
 
ThreadGetOwner () const
 
Safeness GetSafeness () const
 
bool IsOwnedByCurrentThread () const
 
ALIB_API void Release ()
 defined(ALIB_DOX) More...
 
ALIB_API void SetSafeness (Safeness safeness)
 
bool WillRelease () const
 

Protected Fields

PlaceholderAttributesPS placeholderPS
 
- Protected Fields inherited from FormatterStdImpl
int argOffset
 
int argsConsumed
 
bool argumentCountStartsWith1
 
const Boxesarguments
 
AString fieldBuffer
 
String formatString
 
const String formatterName
 
int nextAutoIdx
 
Substring parser
 
PlaceholderAttributes placeholder
 
AStringtargetString
 
integer targetStringStartLength
 
- Protected Fields inherited from Formatter
Boxes boxes
 
AString formatStringBuffer
 
- Protected Fields inherited from ThreadLock
uint16_t cntAcquirements =0
 
std::mutex mutex
 
std::condition_variable mutexNotifier
 
std::thread::id owner
 
Safeness safeness
 

Protected Methods

virtual ALIB_API bool checkStdFieldAgainstArgument () override
 
virtual ALIB_API integer findPlaceholder () override
 
virtual ALIB_API void initializeFormat () override
 
virtual ALIB_API bool parsePlaceholder () override
 
virtual ALIB_API bool parseStdFormatSpec () override
 
virtual ALIB_API bool preAndPostProcess (integer startIdx, AString *target) override
 
virtual ALIB_API void reset () override
 
virtual ALIB_API void resetPlaceholder () override
 
virtual ALIB_API void writeStringPortion (integer length) override
 
- Protected Methods inherited from FormatterStdImpl
virtual ALIB_API int format (AString &targetString, const String &formatString, const Boxes &arguments, int argOffset) override
 
virtual bool setArgument (int pos)
 
virtual bool writeCustomFormat ()
 
virtual void writeStdArgument ()
 
- Protected Methods inherited from Formatter
ALIB_API FormatterformatLoop (AString &target, const Boxes &args)
 

Additional Inherited Members

- Public Static Methods inherited from Formatter
static SPFormatter AcquireDefault (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
 
static SPFormatter GetDefault ()
 
- Protected Types inherited from FormatterStdImpl
enum  PHTypes {
  NotGiven, String, Character, IntBase10,
  IntBinary, IntOctal, IntHex, Float,
  Bool, HashCode, Fill
}
 
- Protected Static Fields inherited from Formatter
static ALIB_API SPFormatter defaultFormatter
 

Constructor & Destructor Documentation

◆ FormatterPythonStyle()


Constructs this formatter. Inherited field DefaultNumberFormat is initialized to meet the formatting defaults of Python.

Definition at line 40 of file formatterpythonstyle.cpp.

Member Function Documentation

◆ checkStdFieldAgainstArgument()

bool checkStdFieldAgainstArgument ( )
overrideprotectedvirtual

Makes some attribute adjustments and invokes standard implementation

Returns
true if OK, false if replacement should be aborted.

Reimplemented from FormatterStdImpl.

Definition at line 592 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ Clone()

FormatterStdImpl * Clone ( )
overridevirtual

Clones and returns a copy of this formatter.

If the formatter attached to field Formatter::Next is of type FormatterStdImpl, then that formatter is copied as well.

Returns
An object of type FormatterPythonStyle and with the same custom settings than this.

Implements Formatter.

Definition at line 49 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ findPlaceholder()

integer findPlaceholder ( )
overrideprotectedvirtual

Searches for '{' which is not '{{'.

Returns
The index found, -1 if not found.

Implements FormatterStdImpl.

Definition at line 98 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ initializeFormat()

void initializeFormat ( )
overrideprotectedvirtual

Sets the actual auto tab stop index to 0.

Reimplemented from Formatter.

Definition at line 70 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ parsePlaceholder()

bool parsePlaceholder ( )
overrideprotectedvirtual

Parses placeholder field in python notation. The portion format_spec is not parsed but stored in member FormatSpec.

Returns
true on success, false on errors.

Implements FormatterStdImpl.

Definition at line 111 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ parseStdFormatSpec()

bool parseStdFormatSpec ( )
overrideprotectedvirtual

Parses the format specification for standard types as specified in "Format Specification Mini Language" .

Returns
true on success, false on errors.

Implements FormatterStdImpl.

Definition at line 206 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ preAndPostProcess()

bool preAndPostProcess ( integer  startIdx,
AString target 
)
overrideprotectedvirtual

Processes "conversions" which are specified with '!'.

Parameters
startIdxThe index of the start of the field written in targetString. -1 indicates pre-phase.
targetThe target string, only if different from field targetString, which indicates intermediate phase.
Returns
false, if the placeholder should be skipped (nothing is written for it). true otherwise.

Reimplemented from FormatterStdImpl.

Definition at line 438 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ reset()

void reset ( )
overrideprotectedvirtual

Resets AutoSizes.

Reimplemented from Formatter.

Definition at line 64 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ resetPlaceholder()

void resetPlaceholder ( )
overrideprotectedvirtual

Invokes parent implementation and then applies some changes to reflect what is defined as default in the Python string format specification.

Reimplemented from FormatterStdImpl.

Definition at line 77 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

◆ writeStringPortion()

void writeStringPortion ( integer  length)
overrideprotectedvirtual

Implementation of abstract method FormatterStdImpl::writeStringPortion.
While writing, replaces "{{" with "{" and "}}" with "}" as well as standard codes like "\\n", "\\r" or "\\t" with corresponding ascii codes.

Parameters
lengthThe number of characters to write.

Implements FormatterStdImpl.

Definition at line 381 of file formatterpythonstyle.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ placeholderPS

PlaceholderAttributesPS placeholderPS
protected

The extended placeholder attributes.

Definition at line 362 of file formatterpythonstyle.hpp.

◆ Sizes

AutoSizes Sizes

Storage of sizes for auto-tabulator feature {!ATab} and auto field width feature {!AWidth}

Definition at line 370 of file formatterpythonstyle.hpp.


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