libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::detail::BasicFormatParseContext< CharType > Class Template Reference

#include <format_parse_context.hpp>

Public Member Functions

template<std::size_t N>
constexpr BasicFormatParseContext (const CharType(&format)[N], const ParameterType *parameters, std::size_t parameters_size) noexcept
 
constexpr std::size_t next_position ()
 
constexpr std::optional< ParameterType > parameter_type (std::size_t position)
 
constexpr fly::BasicLexer< CharType > & lexer ()
 
constexpr view_type view () const
 
void on_error (const char *error)
 
constexpr bool has_error () const
 
std::string error () const
 

Detailed Description

template<fly::StandardCharacter CharType>
class fly::detail::BasicFormatParseContext< CharType >

Provides access to the format string parsing state consisting of the format string being parsed, and the format parameter types and indices.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
April 25, 2021

Constructor & Destructor Documentation

◆ BasicFormatParseContext()

template<fly::StandardCharacter CharType>
template<std::size_t N>
constexpr fly::detail::BasicFormatParseContext< CharType >::BasicFormatParseContext ( const CharType(&)  format[N],
const ParameterType *  parameters,
std::size_t  parameters_size 
)
explicitconstexprnoexcept

Constructor.

Parameters
formatThe format string to be parsed.
parametersPointer to a list of parameter types to be formatted.
parameters_sizeSize of the parameter types list.

Member Function Documentation

◆ error()

template<fly::StandardCharacter CharType>
std::string fly::detail::BasicFormatParseContext< CharType >::error

If an error was stored from a non-constant-evaluated context, returns the last error that was encountered while parsing the format string.

Returns
The error (if any) that was encountered while parsing the format string.

◆ has_error()

template<fly::StandardCharacter CharType>
constexpr bool fly::detail::BasicFormatParseContext< CharType >::has_error
constexpr

If an error was stored from a non-constant-evaluated context, returns whether an error was encountered while parsing the format string.

Returns
True if an error was encountered while parsing.

◆ lexer()

template<fly::StandardCharacter CharType>
constexpr fly::BasicLexer< CharType > & fly::detail::BasicFormatParseContext< CharType >::lexer
constexpr
Returns
The lexer for parsing the format string.

◆ next_position()

template<fly::StandardCharacter CharType>
constexpr std::size_t fly::detail::BasicFormatParseContext< CharType >::next_position
constexpr

Parse the optional position argument of the current replacement field. If a position was not found, the position is observed to be the next format parameter in order.

It is an error if the format string has a mix of manual and automatic positioning.

Returns
The parsed or observed format parameter position.

◆ on_error()

template<fly::StandardCharacter CharType>
void fly::detail::BasicFormatParseContext< CharType >::on_error ( const char *  error)

Record an error that was encountered while parsing the format string.

If invoked from a constant-evaluation context, this will raise a compilation error because this method is purposefully non-constexpr. This results in an attempt to invoke a non-constant expression from a constant context, which is erroneous. The error message from the caller should be displayed in the terminal.

If not invoked from a constant-evaluation context, this will store the error message.

Parameters
errorA message describing the error that was encountered.

◆ parameter_type()

template<fly::StandardCharacter CharType>
constexpr std::optional< ParameterType > fly::detail::BasicFormatParseContext< CharType >::parameter_type ( std::size_t  position)
constexpr

Retrieve the type of the format parameter at the provided index.

Parameters
indexThe index of the format parameter.
Returns
If the index exists, the format parameter type. Otherwise, an uninitialized value.

◆ view()

template<fly::StandardCharacter CharType>
constexpr auto fly::detail::BasicFormatParseContext< CharType >::view
constexpr
Returns
A string view into the format string.

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