BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslfmt::FormatSpecificationParser< t_CHAR > Class Template Reference

#include <bslfmt_formatspecificationparser.h>

Inheritance diagram for bslfmt::FormatSpecificationParser< t_CHAR >:
bslfmt::FormatSpecificationParserEnums

Detailed Description

template<class t_CHAR>
class bslfmt::FormatSpecificationParser< t_CHAR >

A general mechanism used in format specification parsers. It supports parsing syntaxes of the form fill-and-align?sign # 0 width?precision?L and any syntax that contains a subset of the sections therein.

Public Member Functions

BSLS_KEYWORD_CONSTEXPR_CPP20 FormatSpecificationParser ()
 
template<class t_PARSE_CONTEXT >
BSLS_KEYWORD_CONSTEXPR_CPP20 void parse (t_PARSE_CONTEXT *parseContext, Sections sections)
 
template<typename t_FORMAT_CONTEXT >
void postprocess (const t_FORMAT_CONTEXT &context)
 
BSLS_KEYWORD_CONSTEXPR_CPP20 const t_CHAR * filler () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 int numFillerCharacters () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 int fillerCodePointDisplayWidth () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 Alignment alignment () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 Sign sign () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 bool alternativeFlag () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 bool zeroPaddingFlag () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue postprocessedWidth () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue postprocessedPrecision () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue rawWidth () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue rawPrecision () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 bool localeSpecificFlag () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 ProcessingState processingState () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 const bsl::basic_string_view< t_CHAR > remainingSpec () const
 

Additional Inherited Members

- Public Types inherited from bslfmt::FormatSpecificationParserEnums
enum  ProcessingState { e_STATE_UNPARSED , e_STATE_PARSED , e_STATE_POSTPROCESSED }
 
enum  Alignment { e_ALIGN_DEFAULT , e_ALIGN_LEFT , e_ALIGN_MIDDLE , e_ALIGN_RIGHT }
 
enum  Sign { e_SIGN_DEFAULT , e_SIGN_POSITIVE , e_SIGN_NEGATIVE , e_SIGN_SPACE }
 
enum  Sections {
  e_SECTIONS_NONE = 0 , e_SECTIONS_FILL_ALIGN = 1 , e_SECTIONS_SIGN_FLAG = 2 , e_SECTIONS_ALTERNATE_FLAG = 4 ,
  e_SECTIONS_ZERO_PAD_FLAG = 8 , e_SECTIONS_WIDTH = 16 , e_SECTIONS_PRECISION = 32 , e_SECTIONS_LOCALE_FLAG = 64 ,
  e_SECTIONS_REMAINING_SPEC = 128 , e_SECTIONS_ALL = 256 - 1
}
 

Constructor & Destructor Documentation

◆ FormatSpecificationParser()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 bslfmt::FormatSpecificationParser< t_CHAR >::FormatSpecificationParser ( )

Create a default instance of FormatSpecificationParser.

Member Function Documentation

◆ alignment()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 FormatSpecificationParser< t_CHAR >::Alignment bslfmt::FormatSpecificationParser< t_CHAR >::alignment ( ) const

Return the stored alignment value. If parse has not previously been called throw a format_error exception.

◆ alternativeFlag()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 bool bslfmt::FormatSpecificationParser< t_CHAR >::alternativeFlag ( ) const

Return true if parsing detected an alternative processing flag in the specification, otherwise return false. If parse has not previously been called throw a format_error exception.

◆ filler()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 const t_CHAR * bslfmt::FormatSpecificationParser< t_CHAR >::filler ( ) const

Return the stored filler string. If parse has not previously been called throw a format_error exception.

◆ fillerCodePointDisplayWidth()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 int bslfmt::FormatSpecificationParser< t_CHAR >::fillerCodePointDisplayWidth ( ) const

Return the width of the filler code point. If postprocess has not previously been called throw a format_error exception.

◆ localeSpecificFlag()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 bool bslfmt::FormatSpecificationParser< t_CHAR >::localeSpecificFlag ( ) const

Return true if parsing detected a locale-specific formatting flag in the specification, otherwise return false. If parse has not previously been called throw a format_error exception.

◆ numFillerCharacters()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 int bslfmt::FormatSpecificationParser< t_CHAR >::numFillerCharacters ( ) const

Return the size of the stored filler string. If parse has not previously been called throw a format_error exception.

◆ parse()

template<class t_CHAR >
template<class t_PARSE_CONTEXT >
BSLS_KEYWORD_CONSTEXPR_CPP20 void bslfmt::FormatSpecificationParser< t_CHAR >::parse ( t_PARSE_CONTEXT *  parseContext,
Sections  sections 
)

Parse the string contained by the specified input/output parseContext to extract the items indicated by the specified sections, update this object with the parsing result and update the iterator held by parseContext to point to the start of the unparsed section of the string. In the event of an error throw a format_error exception.

◆ postprocess()

template<class t_CHAR >
template<typename t_FORMAT_CONTEXT >
void bslfmt::FormatSpecificationParser< t_CHAR >::postprocess ( const t_FORMAT_CONTEXT &  context)

Update any nested width and precision values to contain actual values based on the appropriate arguments held by the specified context format context. In the event of an error throw a format_error exception.

◆ postprocessedPrecision()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue bslfmt::FormatSpecificationParser< t_CHAR >::postprocessedPrecision ( ) const

Return the modified numeric precision extracted during postprocessing. If postprocess has not previously been called throw a format_error exception.

◆ postprocessedWidth()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue bslfmt::FormatSpecificationParser< t_CHAR >::postprocessedWidth ( ) const

Return the modified numeric width extracted during postprocessing. If postprocess has not previously been called throw a format_error exception.

◆ processingState()

Return the current processing state of this parser.

Return that section of the specification string parsed during the call to parse.

Note
Note that this may be a truncated version of the string held by the parse context. If parse has not previously been called throw a format_error exception.

◆ rawPrecision()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue bslfmt::FormatSpecificationParser< t_CHAR >::rawPrecision ( ) const

Return the unmodified precision extracted during parsing. If parse has not previously been called throw a format_error exception.

◆ rawWidth()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 const FormatterSpecificationNumericValue bslfmt::FormatSpecificationParser< t_CHAR >::rawWidth ( ) const

Return the unmodified width extracted during parsing. If parse has not previously been called throw a format_error exception.

◆ remainingSpec()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 const bsl::basic_string_view< t_CHAR > bslfmt::FormatSpecificationParser< t_CHAR >::remainingSpec ( ) const

Return that section of the specification string that remains unparsed after the call to parse.

Note
Note that this may be a truncated version of the string held by the parse context. If parse has not previously been called throw a format_error exception.

◆ sign()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 FormatSpecificationParser< t_CHAR >::Sign bslfmt::FormatSpecificationParser< t_CHAR >::sign ( ) const

Return the stored sign value. If parse has not previously been called throw a format_error exception.

◆ zeroPaddingFlag()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 bool bslfmt::FormatSpecificationParser< t_CHAR >::zeroPaddingFlag ( ) const

Return true if parsing detected a zero padding flag in the specification, otherwise return false. If parse has not previously been called throw a format_error exception.


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