ToyGine2 26.2.0
Game Engine for retro consoles
Loading...
Searching...
No Matches
toy::anonymous_namespace{format_pattern.inl} Namespace Reference

Enumerations

enum class  PlaceholderMode { none , autoIndex , positional }
 Auto vs positional placeholder mode while scanning; used only inside validateFormatImpl(). More...

Functions

constexpr bool consumeEscapedBrace (const CStringView &string, size_t length, size_t &position, char brace) noexcept
 Consumes a literal {{ or }} pair at position when present.
constexpr FormatPatternValidationError parsePositionalIndex (const CStringView &string, size_t length, size_t &position, size_t argCount) noexcept
 Reads the decimal index and closing } for a positional placeholder.
constexpr FormatPatternValidationError parseOpeningBrace (const CStringView &string, size_t length, size_t &position, size_t &autoCount, PlaceholderMode &mode, size_t argCount) noexcept
 Parses a non-escaped opening brace: auto {}, positional {N}, or a structural error.
constexpr FormatPatternValidationError reconcilePlaceholderMode (PlaceholderMode mode, size_t autoCount, size_t argCount) noexcept
 Verifies placeholder counts against argCount after the whole pattern has been scanned.
constexpr FormatPatternValidationError validateFormatImpl (const CStringView &string, size_t argCount) noexcept
 Validates auto-indexed {} and positional {N} placeholders for argCount arguments.

Enumeration Type Documentation

◆ PlaceholderMode

enum class toy::anonymous_namespace{format_pattern.inl}::PlaceholderMode
strong

Auto vs positional placeholder mode while scanning; used only inside validateFormatImpl().

Enumerator
none 

No {} or {N} placeholder has been seen yet.

autoIndex 

Only auto {} placeholders appear in the pattern.

positional 

Only positional {N} placeholders appear in the pattern.

Function Documentation

◆ consumeEscapedBrace()

bool toy::anonymous_namespace{format_pattern.inl}::consumeEscapedBrace ( const CStringView & string,
size_t length,
size_t & position,
char brace )
nodiscardconstexprnoexcept

Consumes a literal {{ or }} pair at position when present.

Parameters
stringPattern being scanned.
lengthByte length of string (same value as string.size()).
positionCurrent index.
brace'{' to match {{, or '}' to match }}.
Returns
true if a pair was consumed; false if position does not start a doubled brace.
Note
Internal helper for validateFormatImpl; not part of the public API.

◆ parseOpeningBrace()

FormatPatternValidationError toy::anonymous_namespace{format_pattern.inl}::parseOpeningBrace ( const CStringView & string,
size_t length,
size_t & position,
size_t & autoCount,
PlaceholderMode & mode,
size_t argCount )
nodiscardconstexprnoexcept

Parses a non-escaped opening brace: auto {}, positional {N}, or a structural error.

Parameters
stringPattern being scanned.
lengthByte length of string.
positionIndex of {; updated past the placeholder on success.
autoCountIncremented for each auto {} placeholder.
modeUpdated when the pattern uses auto or positional placeholders.
argCountUpper bound for valid positional indices (N must be less than argCount).
Returns
First FormatPatternValidationError encountered, or FormatPatternValidationError::none when the placeholder is well-formed.
Precondition
string at position is { and not the start of {{.
Note
Internal helper for validateFormatImpl; not part of the public API.

◆ parsePositionalIndex()

FormatPatternValidationError toy::anonymous_namespace{format_pattern.inl}::parsePositionalIndex ( const CStringView & string,
size_t length,
size_t & position,
size_t argCount )
nodiscardconstexprnoexcept

Reads the decimal index and closing } for a positional placeholder.

Parameters
stringPattern being scanned.
lengthByte length of string.
positionIndex of the first digit inside {…}; updated past the closing } on success.
argCountUpper bound for valid indices (N must be less than argCount).
Returns
FormatPatternValidationError::none on success; FormatPatternValidationError::invalidContent when digits or closing } are missing; FormatPatternValidationError::indexOutOfRange when digit overflow occurs or the index is not less than argCount.
Precondition
position refers to a decimal digit in string.
Note
Internal helper for parseOpeningBrace; not part of the public API.

◆ reconcilePlaceholderMode()

FormatPatternValidationError toy::anonymous_namespace{format_pattern.inl}::reconcilePlaceholderMode ( PlaceholderMode mode,
size_t autoCount,
size_t argCount )
nodiscardconstexprnoexcept

Verifies placeholder counts against argCount after the whole pattern has been scanned.

Parameters
modeWhether the pattern used no placeholders, auto {}, or positional {N}.
autoCountNumber of {} placeholders when in auto mode.
argCountExpected sizeof...(Args).
Returns
FormatPatternValidationError::none or FormatPatternValidationError::argCountMismatch.
Note
Internal helper for validateFormatImpl; not part of the public API.