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

#include <bslfmt_standardformatspecification.h>

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

Detailed Description

template<class t_CHAR>
class bslfmt::StandardFormatSpecification< t_CHAR >

A general mechanism to parse and validate a Standard format specification string for a given argument type.

Public Types

enum  Category {
  e_CATEGORY_UNASSIGNED , e_CATEGORY_STRING , e_CATEGORY_INTEGRAL , e_CATEGORY_CHARACTER ,
  e_CATEGORY_BOOLEAN , e_CATEGORY_FLOATING , e_CATEGORY_POINTER
}
 
enum  FormatType {
  e_TYPE_UNASSIGNED , e_STRING_DEFAULT , e_STRING_ESCAPED , e_INTEGRAL_BINARY ,
  e_INTEGRAL_BINARY_UC , e_INTEGRAL_CHARACTER , e_INTEGRAL_DECIMAL , e_INTEGRAL_OCTAL ,
  e_INTEGRAL_HEX , e_INTEGRAL_HEX_UC , e_CHARACTER_CHARACTER , e_CHARACTER_ESCAPED ,
  e_BOOLEAN_STRING , e_FLOATING_DEFAULT , e_FLOATING_HEX , e_FLOATING_HEX_UC ,
  e_FLOATING_SCIENTIFIC , e_FLOATING_SCIENTIFIC_UC , e_FLOATING_FIXED , e_FLOATING_FIXED_UC ,
  e_FLOATING_GENERAL , e_FLOATING_GENERAL_UC , e_POINTER_HEX , e_POINTER_HEX_UC
}
 
- 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
}
 

Public Member Functions

BSLS_KEYWORD_CONSTEXPR_CPP20 StandardFormatSpecification ()
 
template<class t_PARSE_CONTEXT >
BSLS_KEYWORD_CONSTEXPR_CPP20 void parse (t_PARSE_CONTEXT *context, Category category)
 
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 bool localeSpecificFlag () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 FormatType formatType () const
 
BSLS_KEYWORD_CONSTEXPR_CPP20 FormatSpecificationParserEnums::ProcessingState processingState () const
 

Member Enumeration Documentation

◆ Category

template<class t_CHAR >
enum bslfmt::StandardFormatSpecification::Category
Enumerator
e_CATEGORY_UNASSIGNED 
e_CATEGORY_STRING 
e_CATEGORY_INTEGRAL 
e_CATEGORY_CHARACTER 
e_CATEGORY_BOOLEAN 
e_CATEGORY_FLOATING 
e_CATEGORY_POINTER 

◆ FormatType

Enumerator
e_TYPE_UNASSIGNED 
e_STRING_DEFAULT 
e_STRING_ESCAPED 
e_INTEGRAL_BINARY 
e_INTEGRAL_BINARY_UC 
e_INTEGRAL_CHARACTER 
e_INTEGRAL_DECIMAL 
e_INTEGRAL_OCTAL 
e_INTEGRAL_HEX 
e_INTEGRAL_HEX_UC 
e_CHARACTER_CHARACTER 
e_CHARACTER_ESCAPED 
e_BOOLEAN_STRING 
e_FLOATING_DEFAULT 
e_FLOATING_HEX 
e_FLOATING_HEX_UC 
e_FLOATING_SCIENTIFIC 
e_FLOATING_SCIENTIFIC_UC 
e_FLOATING_FIXED 
e_FLOATING_FIXED_UC 
e_FLOATING_GENERAL 
e_FLOATING_GENERAL_UC 
e_POINTER_HEX 
e_POINTER_HEX_UC 

Constructor & Destructor Documentation

◆ StandardFormatSpecification()

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

Create an uninitialized StandardFormatSpecification object.

Member Function Documentation

◆ alignment()

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

Return the enumerator representing the requested alignment unless the status is not at least e_STATE_PARSED in which case throw a bsl::format_error exception indicating that error.

◆ alternativeFlag()

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

Return a boolean indicating if alternative formatting was requested unless the status is not at least e_STATE_PARSED in which case throw a bsl::format_error exception indicating that error.

◆ filler()

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

Return a pointer to the character array that stores the parsed filler character that may be a multibyte code point or just a single character unless the status is not e_STATE_PARSED or e_STATE_POSTPROCESSED in which case throw a bsl::format_error exception indicating that error. See also numFillerCharacters() that provides the number of characters in the array returned by this function (at least one).

◆ fillerCodePointDisplayWidth()

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

Return the display width of the code point represented by the array returned by filler() unless the status is not e_STATE_PARSED or e_STATE_POSTPROCESSED in which case throw a bsl::format_error exception indicating that error.

◆ formatType()

template<class t_CHAR >
BSLS_KEYWORD_CONSTEXPR_CPP20 StandardFormatSpecification< t_CHAR >::FormatType bslfmt::StandardFormatSpecification< t_CHAR >::formatType ( ) const

Return the enumerator representing the requested format type unless the status is not at least e_STATE_PARSED in which case throw a bsl::format_error exception indicating that error.

◆ localeSpecificFlag()

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

Return a boolean indicating if the locale specific flag was present in the format specification unless the status is not at least e_STATE_PARSED in which case throw a bsl::format_error exception indicating that error.

Note
Note that the locale specific flag is not yet supported hence the attempt to format with a specification that has this flags set will result in an exception indicating that.

◆ numFillerCharacters()

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

Return the number of filler characters in the array returned by filler() unless the status is not e_STATE_PARSED or e_STATE_POSTPROCESSED in which case throw a bsl::format_error exception indicating that error.

◆ parse()

template<class t_CHAR >
template<class t_PARSE_CONTEXT >
BSLS_KEYWORD_CONSTEXPR_CPP20 void bslfmt::StandardFormatSpecification< t_CHAR >::parse ( t_PARSE_CONTEXT *  context,
Category  category 
)

Parse a format string using the iterator-range from the specified context assuming it is a Standard format specification for arguments of the specified category and if successful update this object with the parsing result, as well as set the status to e_PARSED; otherwise, if the format specification denoted by the context iterator-range is not a valid Standard format specification for arguments of category category throw a bsl::format_error exception.

◆ postprocess()

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

Update the corresponding attributes of this object using the argument values provided by the specified context to fill in the values of nested width or precision parameters if such nested parameters exist and set the status of this object to e_STATE_POSTPROCESSED. By nested format parameters we mean parameters whose value comes from an argument to the formatter function, and not an literal integer value within the format string. In case of an error throw a bsl::format_error exception.

◆ postprocessedPrecision()

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

Return an optional value representing the requested precision unless the status is not e_STATE_POSTPROCESSED in which case throw a bsl::format_error exception indicating that error.

Note
Note that the returned type is capable of representing more than just an optional integer, but after preprocessing it will have only two possible states: no value, or an integer value.

◆ postprocessedWidth()

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

Return an optional value representing the requested width unless the status is not e_STATE_POSTPROCESSED in which case throw a bsl::format_error exception indicating that error.

Note
Note that the returned type is capable of representing more than just an optional integer, but after preprocessing it will have only two possible states: no value, or an integer value.

◆ processingState()

Return the current processing state of this specification.

◆ sign()

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

Return the enumerator representing the requested sign-treatment option unless the status is not at least e_STATE_PARSED in which case throw a bsl::format_error exception indicating that error.

◆ zeroPaddingFlag()

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

Return a boolean indicating if zero padding was requested unless the status is not at least e_STATE_PARSED in which case throw a bsl::format_error exception indicating that error.


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