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

#include <formatterjavastyle.hpp>

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

Class Description


Implements a Formatter according to the formatting standards of the Java 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 specification is covered quite well. The differences and specialties are:

Reference Documentation

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

Definition at line 125 of file formatterjavastyle.hpp.

Inner Classes

struct  PlaceholderAttributesJS
 

Public Methods

ALIB_API FormatterJavaStyle ()
 
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

PlaceholderAttributesJS placeholderJS
 
- 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 bool parsePlaceholder () override
 
virtual bool parseStdFormatSpec () override
 
virtual ALIB_API bool preAndPostProcess (integer startIdx, AString *target) 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)
 
virtual void initializeFormat ()
 
virtual void reset ()
 

Additional Inherited Members

- 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 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

◆ FormatterJavaStyle()


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

Definition at line 27 of file formatterjavastyle.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 415 of file formatterjavastyle.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 50 of file formatterjavastyle.cpp.

Here is the call graph for this function:

◆ findPlaceholder()

integer findPlaceholder ( )
overrideprotectedvirtual

Searches for '%' which is not '%' or 'n'.

Returns
The index found, -1 if not found.

Implements FormatterStdImpl.

Definition at line 85 of file formatterjavastyle.cpp.

Here is the call graph for this function:

◆ parsePlaceholder()

bool parsePlaceholder ( )
overrideprotectedvirtual

Parses placeholder field in Java syntax. The portion format_spec is not set as this is not supported by the syntax.

Returns
true on success, false on errors.

Implements FormatterStdImpl.

Definition at line 158 of file formatterjavastyle.cpp.

Here is the call graph for this function:

◆ parseStdFormatSpec()

virtual bool parseStdFormatSpec ( )
inlineoverrideprotectedvirtual

Does nothing. Java does not support custom format specifications.

Returns
true to indicate success.

Implements FormatterStdImpl.

Definition at line 220 of file formatterjavastyle.hpp.

◆ preAndPostProcess()

bool preAndPostProcess ( integer  startIdx,
AString target 
)
overrideprotectedvirtual

All that this formatter does with this overridden method is to convert strings to upper case.

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 407 of file formatterjavastyle.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 Java string format specification.

Reimplemented from FormatterStdImpl.

Definition at line 66 of file formatterjavastyle.cpp.

Here is the call graph for this function:

◆ writeStringPortion()

void writeStringPortion ( integer  length)
overrideprotectedvirtual

Implementation of abstract method FormatterStdImpl::writeStringPortion.
Replaces "%%" with '%' and "%n" with ascii 0x0a. In addition applies Format::Escape on target which replaces standard codes like "\\n", "\\r" or "\\t" with corresponding ascii codes. (The latter is an extension to the standard behavior of Java formatter.)

Parameters
lengthThe number of characters to write.

Implements FormatterStdImpl.

Definition at line 99 of file formatterjavastyle.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ placeholderJS

PlaceholderAttributesJS placeholderJS
protected

The extended placeholder attributes.

Definition at line 156 of file formatterjavastyle.hpp.


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