ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Fields | Public Methods | Protected Types | Protected Static Fields | Protected Fields | Protected Methods | List of all members
FormatterPythonStyle Class Reference
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:

Public Fields

AutoSizes Sizes = new AutoSizes()
 
- Public Fields inherited from FormatterStdImpl
NumberFormat AlternativeNumberFormat = new NumberFormat()
 
DateTimeFormatInfo DateTimeFormatProvider = DateTimeFormatInfo.InvariantInfo
 
NumberFormat DefaultNumberFormat = new NumberFormat()
 
bool WriteALibErrorReports = true
 
bool WriteErrorsToTargetString = true
 
- Public Fields inherited from Formatter
Formatter Next
 

Public Methods

 FormatterPythonStyle ()
 
override void Reset ()
 
- Public Methods inherited from FormatterStdImpl
 FormatterStdImpl (String formatterClassName)
 
virtual void CloneSettings (FormatterStdImpl reference)
 
- Public Methods inherited from Formatter
virtual void Format (AString target, List< Object > args)
 
virtual void Format (AString target, params Object[] args)
 

Protected Types

enum  ppStates {
  POSITION = 1, CONVERSION = 2, COLON = 3, FORMAT_SPEC = 4,
  END = 10
}
 
- Protected Types inherited from FormatterStdImpl
enum  PHType {
  NotGiven, String, Character, IntBase10,
  IntBinary, IntOctal, IntHex, Float,
  Bool, HashCode, Fill
}
 

Protected Static Fields

static char[] constColonAndClosingBracket = ":}".ToCharArray()
 
- Protected Static Fields inherited from Formatter
static Formatter defaultFormatter
 
static ThreadLock defaultFormatterLock = new ThreadLock()
 

Protected Fields

Substring conversion = new Substring()
 
Substring phaExtConversion = new Substring()
 
int phaExtDefaultPrecision
 
int phaExtPrecision
 
- Protected Fields inherited from FormatterStdImpl
int argOffset
 
int argsConsumed
 
List< Object > arguments
 
AString fieldBuffer = new AString()
 
Substring formatString = new Substring()
 
String formatterName
 
int nextAutoIdx
 
Substring parser = new Substring()
 
Alignment phaAlignment
 
bool phaAlignmentSpecified
 
Object phaArgument
 
int phaArgumentIdx
 
int phaCutContent
 
char phaFillChar
 
Substring phaFormatSpec = new Substring()
 
bool phaIsPercentage
 
NumberFormat phaNF = new NumberFormat()
 
int phaPreviousArgumentIdx
 
bool phaSignPaddingMode
 
PHType phaType
 
char phaTypeCode
 
int phaWidth
 
bool phaWriteBinOctHexPrefix
 
AString targetString
 
int targetStringStartLength
 
- Protected Fields inherited from Formatter
List< Object > boxes
 
Substring lamFormatString = new Substring()
 

Protected Methods

override bool checkStdFieldAgainstArgument ()
 
override int findPlaceholder ()
 
override void initializeFormat ()
 
override bool parsePlaceholder ()
 
override bool parseStdFormatSpec ()
 
override bool preAndPostProcess (int startIdx, AString target)
 
override void replaceEscapeSequences (int startIdx)
 
override void resetPHAs ()
 
- Protected Methods inherited from FormatterStdImpl
virtual void errorFormatString (String msg)
 
override int format (AString targetString, Substring formatString, List< Object > arguments, int argOffset)
 
virtual bool setArgument (int pos, bool countStartsWith_1)
 
virtual bool writeCustomFormat ()
 
virtual void writeStdArgument ()
 

Additional Inherited Members

- Public Static Methods inherited from Formatter
static Formatter AcquireDefault ()
 
static void ReleaseDefault ()
 

Member Enumeration Documentation

◆ ppStates

enum ppStates
strongprotected

States used in parsePlaceholder.

Constructor & Destructor Documentation

◆ FormatterPythonStyle()


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

Member Function Documentation

◆ checkStdFieldAgainstArgument()

override bool checkStdFieldAgainstArgument ( )
inlineprotectedvirtual

Makes some attribute adjustments and invokes standard implementation

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

Reimplemented from FormatterStdImpl.

◆ findPlaceholder()

override int findPlaceholder ( )
inlineprotectedvirtual

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

Returns
The index found, -1 if not found.

Implements FormatterStdImpl.

◆ initializeFormat()

override void initializeFormat ( )
inlineprotectedvirtual

Sets the actual auto tab stop index to 0.

Reimplemented from Formatter.

◆ parsePlaceholder()

override bool parsePlaceholder ( )
inlineprotectedvirtual

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

Returns
true on success, false on errors.

Implements FormatterStdImpl.

◆ parseStdFormatSpec()

override bool parseStdFormatSpec ( )
inlineprotectedvirtual

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

Returns
true on success, false on errors.

Implements FormatterStdImpl.

◆ preAndPostProcess()

override bool preAndPostProcess ( int  startIdx,
AString  target 
)
inlineprotectedvirtual

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

Parameters
startIdxThe int 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.

◆ replaceEscapeSequences()

override void replaceEscapeSequences ( int  startIdx)
inlineprotectedvirtual

Implementation of abstract method.
Replaces "{{" with "{" and "}}" with "}". In addition applies AString.Escape on target which replaces standard codes like "\\n", "\\r" or "\\t" with corresponding ascii codes.

Parameters
startIdxThe start of the region to replace

Implements FormatterStdImpl.

◆ Reset()

override void Reset ( )
inlinevirtual

Resets Sizes.

Reimplemented from Formatter.

◆ resetPHAs()

override void resetPHAs ( )
inlineprotectedvirtual

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

Reimplemented from FormatterStdImpl.

Member Data Documentation

◆ constColonAndClosingBracket

char [] constColonAndClosingBracket = ":}".ToCharArray()
staticprotected

Constant string array

◆ conversion

Substring conversion = new Substring()
protected

Reused object used to parse phaExtConversion in method preAndPostProcess.

◆ phaExtConversion

Substring phaExtConversion = new Substring()
protected

The portion of the replacement field that represents the conversion specification. This specification is given at the beginning of the replacement field, starting with '!'.

◆ phaExtDefaultPrecision

int phaExtDefaultPrecision
protected

The default precision if not given. This is set to 6 in resetPHAs, but is changed when specific.

◆ phaExtPrecision

int phaExtPrecision
protected

The value read from the precision field. This is set to -1 in resetPHAs.

◆ Sizes

AutoSizes Sizes = new AutoSizes()

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


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