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

Synopsis

Declared in <bslfmt_standardformatspecification.h>

template<class t_CHAR>
class StandardFormatSpecification
    : public FormatSpecificationParserEnums

Base Classes

Name

Description

FormatSpecificationParserEnums

Namespace struct holding enums used for parsing.

Enums

Name

Description

Alignment

Alignment options parsed from a format specification.

Category

Format category enumeration.

FormatType

Format type enumeration.

ProcessingState

Parser processing states for a format specification.

Sections

Bit flags indicating which format‐spec sections were parsed.

Sign

Sign options parsed from a format specification.

Member Functions

Name

Description

StandardFormatSpecification [constructor]

Create an uninitialized StandardFormatSpecification object.

alignment

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

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

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

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

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

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

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

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

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

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

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

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

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.

Created with MrDocs