OpenTTD Source 20260218-master-g2123fca5ea
StringConsumer Class Reference

Parse data from a string / buffer. More...

#include <string_consumer.hpp>

Public Types

enum  SeparatorUsage {
  READ_ALL_SEPARATORS , READ_ONE_SEPARATOR , KEEP_SEPARATOR , SKIP_ONE_SEPARATOR ,
  SKIP_ALL_SEPARATORS
}
 Treatment of separator characters. More...
using size_type = std::string_view::size_type
 The type of the size of our strings.

Public Member Functions

 StringConsumer (std::string_view src)
 Construct parser with data from string.
 StringConsumer (const std::string &src)
 Construct parser with data from string.
 StringConsumer (std::span< const char > src)
 Construct parser with data from span.
bool AnyBytesLeft () const noexcept
 Check whether any bytes left to read.
size_type GetBytesLeft () const noexcept
 Get number of bytes left to read.
bool AnyBytesRead () const noexcept
 Check whether any bytes were already read.
size_type GetBytesRead () const noexcept
 Get number of already read bytes.
std::string_view GetOrigData () const noexcept
 Get the original data, as passed to the constructor.
std::string_view GetReadData () const noexcept
 Get already read data.
std::string_view GetLeftData () const noexcept
 Get data left to read.
void SkipAll ()
 Discard all remaining data.
std::optional< uint8_t > PeekUint8 () const
 Peek binary uint8.
std::optional< uint8_t > TryReadUint8 ()
 Try to read binary uint8, and then advance reader.
uint8_t ReadUint8 (uint8_t def=0)
 Read binary uint8, and advance reader.
void SkipUint8 ()
 Skip binary uint8.
std::optional< int8_t > PeekSint8 () const
 Peek binary int8.
std::optional< int8_t > TryReadSint8 ()
 Try to read binary int8, and then advance reader.
int8_t ReadSint8 (int8_t def=0)
 Read binary int8, and advance reader.
void SkipSint8 ()
 Skip binary int8.
std::optional< uint16_t > PeekUint16LE () const
 Peek binary uint16 using little endian.
std::optional< uint16_t > TryReadUint16LE ()
 Try to read binary uint16, and then advance reader.
uint16_t ReadUint16LE (uint16_t def=0)
 Read binary uint16 using little endian, and advance reader.
void SkipUint16LE ()
 Skip binary uint16, and advance reader.
std::optional< int16_t > PeekSint16LE () const
 Peek binary int16 using little endian.
std::optional< int16_t > TryReadSint16LE ()
 Try to read binary int16, and then advance reader.
int16_t ReadSint16LE (int16_t def=0)
 Read binary int16 using little endian, and advance reader.
void SkipSint16LE ()
 Skip binary int16, and advance reader.
std::optional< uint32_t > PeekUint32LE () const
 Peek binary uint32 using little endian.
std::optional< uint32_t > TryReadUint32LE ()
 Try to read binary uint32, and then advance reader.
uint32_t ReadUint32LE (uint32_t def=0)
 Read binary uint32 using little endian, and advance reader.
void SkipUint32LE ()
 Skip binary uint32, and advance reader.
std::optional< int32_t > PeekSint32LE () const
 Peek binary int32 using little endian.
std::optional< int32_t > TryReadSint32LE ()
 Try to read binary int32, and then advance reader.
int32_t ReadSint32LE (int32_t def=0)
 Read binary int32 using little endian, and advance reader.
void SkipSint32LE ()
 Skip binary int32, and advance reader.
std::optional< uint64_t > PeekUint64LE () const
 Peek binary uint64 using little endian.
std::optional< uint64_t > TryReadUint64LE ()
 Try to read binary uint64, and then advance reader.
uint64_t ReadUint64LE (uint64_t def=0)
 Read binary uint64 using little endian, and advance reader.
void SkipUint64LE ()
 Skip binary uint64, and advance reader.
std::optional< int64_t > PeekSint64LE () const
 Peek binary int64 using little endian.
std::optional< int64_t > TryReadSint64LE ()
 Try to read binary int64, and then advance reader.
int64_t ReadSint64LE (int64_t def=0)
 Read binary int64 using little endian, and advance reader.
void SkipSint64LE ()
 Skip binary int64, and advance reader.
std::optional< char > PeekChar () const
 Peek 8-bit character.
std::optional< char > TryReadChar ()
 Try to read a 8-bit character, and then advance reader.
char ReadChar (char def='?')
 Read 8-bit character, and advance reader.
void SkipChar ()
 Skip 8-bit character, and advance reader.
std::pair< size_type, char32_t > PeekUtf8 () const
 Peek UTF-8 character.
std::optional< char32_t > TryReadUtf8 ()
 Try to read a UTF-8 character, and then advance reader.
char32_t ReadUtf8 (char32_t def='?')
 Read UTF-8 character, and advance reader.
void SkipUtf8 ()
 Skip UTF-8 character, and advance reader.
bool PeekIf (std::string_view str) const
 Check whether the next data matches 'str'.
bool ReadIf (std::string_view str)
 Check whether the next data matches 'str', and skip it.
void SkipIf (std::string_view str)
 If the next data matches 'str', then skip it.
bool PeekCharIf (char c) const
 Check whether the next 8-bit char matches 'c'.
bool ReadCharIf (char c)
 Check whether the next 8-bit char matches 'c', and skip it.
void SkipCharIf (char c)
 If the next data matches the 8-bit char 'c', then skip it.
bool PeekUtf8If (char32_t c) const
 Check whether the next UTF-8 char matches 'c'.
bool ReadUtf8If (char32_t c)
 Check whether the next UTF-8 char matches 'c', and skip it.
void SkipUtf8If (char32_t c)
 If the next data matches the UTF-8 char 'c', then skip it.
std::string_view Peek (size_type len) const
 Peek the next 'len' bytes.
std::string_view Read (size_type len)
 Read the next 'len' bytes, and advance reader.
void Skip (size_type len)
 Discard some bytes.
size_type Find (std::string_view str) const
 Find first occurrence of 'str'.
size_type FindChar (char c) const
 Find first occurrence of 8-bit char 'c'.
size_type FindUtf8 (char32_t c) const
 Find first occurrence of UTF-8 char 'c'.
size_type FindCharIn (std::string_view chars) const
 Find first occurrence of any 8-bit char in 'chars'.
size_type FindCharNotIn (std::string_view chars) const
 Find first occurrence of any 8-bit char not in 'chars'.
std::optional< char > PeekCharIfIn (std::string_view chars) const
 Check whether the next 8-bit char is in 'chars'.
std::optional< char > ReadCharIfIn (std::string_view chars)
 Read next 8-bit char, check whether it is in 'chars', and advance reader.
void SkipCharIfIn (std::string_view chars)
 If the next 8-bit char is in 'chars', skip it.
std::optional< char > PeekCharIfNotIn (std::string_view chars) const
 Check whether the next 8-bit char is not in 'chars'.
std::optional< char > ReadCharIfNotIn (std::string_view chars)
 Read next 8-bit char, check whether it is not in 'chars', and advance reader.
void SkipCharIfNotIn (std::string_view chars)
 If the next 8-bit char is not in 'chars', skip it.
std::string_view PeekUntilCharIn (std::string_view chars) const
 Peek 8-bit chars, while they are not in 'chars', until they are.
std::string_view ReadUntilCharIn (std::string_view chars)
 Read 8-bit chars, while they are not in 'chars', until they are; and advance reader.
void SkipUntilCharIn (std::string_view chars)
 Skip 8-bit chars, while they are not in 'chars', until they are.
std::string_view PeekUntilCharNotIn (std::string_view chars) const
 Peek 8-bit chars, while they are in 'chars', until they are not.
std::string_view ReadUntilCharNotIn (std::string_view chars)
 Read 8-bit chars, while they are in 'chars', until they are not; and advance reader.
void SkipUntilCharNotIn (std::string_view chars)
 Skip 8-bit chars, while they are in 'chars', until they are not.
std::string_view PeekUntil (std::string_view str, SeparatorUsage sep) const
 Peek data until the first occurrence of 'str'.
std::string_view ReadUntil (std::string_view str, SeparatorUsage sep)
 Read data until the first occurrence of 'str', and advance reader.
void SkipUntil (std::string_view str, SeparatorUsage sep)
 Skip data until the first occurrence of 'str'.
std::string_view PeekUntilChar (char c, SeparatorUsage sep) const
 Peek data until the first occurrence of 8-bit char 'c'.
std::string_view ReadUntilChar (char c, SeparatorUsage sep)
 Read data until the first occurrence of 8-bit char 'c', and advance reader.
void SkipUntilChar (char c, SeparatorUsage sep)
 Skip data until the first occurrence of 8-bit char 'c'.
std::string_view PeekUntilUtf8 (char32_t c, SeparatorUsage sep) const
 Peek data until the first occurrence of UTF-8 char 'c'.
std::string_view ReadUntilUtf8 (char32_t c, SeparatorUsage sep)
 Read data until the first occurrence of UTF-8 char 'c', and advance reader.
void SkipUntilUtf8 (char32_t c, SeparatorUsage sep)
 Skip data until the first occurrence of UTF-8 char 'c'.
template<class T>
std::pair< size_type, T > PeekIntegerBase (int base, bool clamp=false) const
 Peek and parse an integer in number 'base'.
template<class T>
std::optional< T > TryReadIntegerBase (int base, bool clamp=false)
 Try to read and parse an integer in number 'base', and then advance the reader.
template<class T>
ReadIntegerBase (int base, T def=0, bool clamp=false)
 Read and parse an integer in number 'base', and advance the reader.
void SkipIntegerBase (int base)
 Skip an integer in number 'base'.

Static Public Attributes

static constexpr size_type npos = std::string_view::npos
 Special value for "end of data".
static const std::string_view WHITESPACE_NO_NEWLINE = "\t\v\f\r "
 ASCII whitespace characters, excluding new-line.
static const std::string_view WHITESPACE_OR_NEWLINE = "\t\n\v\f\r "
 ASCII whitespace characters, including new-line.

Static Private Member Functions

static void LogError (std::string &&msg)
 Log an error in the processing (too small buffer, integer out of range, etc.).
template<class T>
static std::pair< size_type, T > ParseIntegerBase (std::string_view src, int base, bool clamp, bool log_errors)
 Parse an integer from the given string.

Private Attributes

std::string_view src
 The string to parse.
size_type position = 0
 The current parsing position in the string.

Detailed Description

Parse data from a string / buffer.

There are generally four operations for each data type:

  • Peek: Check and return validity and value. Do not advance read position.
  • TryRead: Check and return validity and value. Advance reader, if valid.
  • Read: Check validity, return value or fallback-value. Advance reader, even if value is invalid, to avoid deadlocks/stalling.
  • Skip: Discard value. Advance reader, even if value is invalid, to avoid deadlocks/stalling.

Definition at line 25 of file string_consumer.hpp.

Member Typedef Documentation

◆ size_type

using StringConsumer::size_type = std::string_view::size_type

The type of the size of our strings.

Definition at line 28 of file string_consumer.hpp.

Member Enumeration Documentation

◆ SeparatorUsage

Treatment of separator characters.

Enumerator
READ_ALL_SEPARATORS 

Read all consecutive separators, and include them all in the result.

READ_ONE_SEPARATOR 

Read one separator, and include it in the result.

KEEP_SEPARATOR 

Keep the separator in the data as next value to be read.

SKIP_ONE_SEPARATOR 

Read and discard one separator, do not include it in the result.

SKIP_ALL_SEPARATORS 

Read and discard all consecutive separators, do not include any in the result.

Definition at line 743 of file string_consumer.hpp.

Constructor & Destructor Documentation

◆ StringConsumer() [1/3]

StringConsumer::StringConsumer ( std::string_view src)
inlineexplicit

Construct parser with data from string.

Parameters
srcThe source string to read from..

Definition at line 57 of file string_consumer.hpp.

References src.

◆ StringConsumer() [2/3]

StringConsumer::StringConsumer ( const std::string & src)
inlineexplicit

Construct parser with data from string.

Parameters
srcThe source string to read from..

Definition at line 62 of file string_consumer.hpp.

References src.

◆ StringConsumer() [3/3]

StringConsumer::StringConsumer ( std::span< const char > src)
inlineexplicit

Construct parser with data from span.

Parameters
srcThe source string to read from..

Definition at line 67 of file string_consumer.hpp.

References src.

Member Function Documentation

◆ AnyBytesLeft()

◆ AnyBytesRead()

bool StringConsumer::AnyBytesRead ( ) const
inlinenodiscardnoexcept

Check whether any bytes were already read.

Returns
true iff there were any bytes read.

Definition at line 84 of file string_consumer.hpp.

◆ Find()

StringConsumer::size_type StringConsumer::Find ( std::string_view str) const
nodiscard

Find first occurrence of 'str'.

Parameters
strThe string to search for.
Returns
Offset from current reader position. 'npos' if no match found.

Definition at line 113 of file string_consumer.cpp.

References position, and src.

Referenced by FindChar(), FindUtf8(), and SkipUntil().

◆ FindChar()

size_type StringConsumer::FindChar ( char c) const
inlinenodiscard

Find first occurrence of 8-bit char 'c'.

Parameters
cThe character to search for.
Returns
Offset from current reader position. 'npos' if no match found.

Definition at line 590 of file string_consumer.hpp.

References Find().

Referenced by ParseCompanyManagerFaceCode().

◆ FindCharIn()

StringConsumer::size_type StringConsumer::FindCharIn ( std::string_view chars) const
nodiscard

Find first occurrence of any 8-bit char in 'chars'.

Parameters
charsThe set of characters to find an occurrence for.
Returns
Offset from current reader position. 'npos' if no match found.

Definition at line 126 of file string_consumer.cpp.

References position, and src.

Referenced by PeekUntilCharIn(), ReadUntilCharIn(), and SkipUntilCharIn().

◆ FindCharNotIn()

StringConsumer::size_type StringConsumer::FindCharNotIn ( std::string_view chars) const
nodiscard

Find first occurrence of any 8-bit char not in 'chars'.

Parameters
charsThe set of characters to not find an occurrence for.
Returns
Offset from current reader position. 'npos' if no match found.

Definition at line 133 of file string_consumer.cpp.

References position, and src.

Referenced by PeekUntilCharNotIn(), ReadUntilCharNotIn(), and SkipUntilCharNotIn().

◆ FindUtf8()

StringConsumer::size_type StringConsumer::FindUtf8 ( char32_t c) const
nodiscard

Find first occurrence of UTF-8 char 'c'.

Parameters
cThe character to search for.
Returns
Offset from current reader position. 'npos' if no match found.

Definition at line 120 of file string_consumer.cpp.

References EncodeUtf8(), and Find().

◆ GetBytesLeft()

size_type StringConsumer::GetBytesLeft ( ) const
inlinenodiscardnoexcept

Get number of bytes left to read.

Returns
The number of bytes to read.

Definition at line 78 of file string_consumer.hpp.

Referenced by PeekUint16LE(), PeekUint32LE(), PeekUint64LE(), PeekUint8(), and Skip().

◆ GetBytesRead()

size_type StringConsumer::GetBytesRead ( ) const
inlinenodiscardnoexcept

Get number of already read bytes.

Returns
The number of bytes read so far.

Definition at line 89 of file string_consumer.hpp.

◆ GetLeftData()

std::string_view StringConsumer::GetLeftData ( ) const
inlinenodiscardnoexcept

Get data left to read.

Returns
The part of the original string that we have not read yet.

Definition at line 105 of file string_consumer.hpp.

Referenced by GetDriverParam(), IniLoadFile::LoadFromDisk(), and ClientNetworkContentSocketHandler::OnReceiveData().

◆ GetOrigData()

std::string_view StringConsumer::GetOrigData ( ) const
inlinenodiscardnoexcept

Get the original data, as passed to the constructor.

Returns
The original string.

Definition at line 95 of file string_consumer.hpp.

Referenced by IniLoadFile::LoadFromDisk().

◆ GetReadData()

std::string_view StringConsumer::GetReadData ( ) const
inlinenodiscardnoexcept

Get already read data.

Returns
The part of the original string we have already read.

Definition at line 100 of file string_consumer.hpp.

◆ LogError()

void StringConsumer::LogError ( std::string && msg)
staticprivate

Log an error in the processing (too small buffer, integer out of range, etc.).

Parameters
msgThe message to log.

Definition at line 33 of file string_consumer.cpp.

References DebugPrint(), and FatalErrorI().

Referenced by ParseIntegerBase(), Read(), and Skip().

◆ ParseIntegerBase()

template<class T>
std::pair< size_type, T > StringConsumer::ParseIntegerBase ( std::string_view src,
int base,
bool clamp,
bool log_errors )
inlinestaticnodiscardprivate

Parse an integer from the given string.

Parameters
srcThe source string to read from.
baseThe base of the integer, or 0 to auto detect.
clampWhether to automatically clamp the number to be within the types range.
log_errorsWhether to log errors encountered during parsing.
Template Parameters
TThe type of integer to parse.
Returns
The numbers of bytes parsed and the parsed integer. When the number of parsed bytes is 0, the integer is invalid as well.

Definition at line 866 of file string_consumer.hpp.

References LogError(), ParseIntegerBase(), and src.

Referenced by ParseIntegerBase(), PeekIntegerBase(), and ReadIntegerBase().

◆ Peek()

std::string_view StringConsumer::Peek ( size_type len) const
nodiscard

Peek the next 'len' bytes.

Parameters
lenBytes to read, 'npos' to read all.
Returns
Up to 'len' bytes.

Definition at line 90 of file string_consumer.cpp.

References position, and src.

Referenced by PeekUntilCharIn(), PeekUntilCharNotIn(), and Read().

◆ PeekChar()

std::optional< char > StringConsumer::PeekChar ( ) const
nodiscard

Peek 8-bit character.

Returns
Read char, std::nullopt if not enough data.

Definition at line 77 of file string_consumer.cpp.

References PeekUint8().

Referenced by PeekCharIfIn(), PeekCharIfNotIn(), ReadChar(), and TryReadChar().

◆ PeekCharIf()

bool StringConsumer::PeekCharIf ( char c) const
inlinenodiscard

Check whether the next 8-bit char matches 'c'.

Parameters
cThe character to match.
Returns
true iff the next character is equal to the given character.

Definition at line 497 of file string_consumer.hpp.

References PeekIf().

Referenced by StrMakeValid().

◆ PeekCharIfIn()

std::optional< char > StringConsumer::PeekCharIfIn ( std::string_view chars) const
inlinenodiscard

Check whether the next 8-bit char is in 'chars'.

Parameters
charsThe set of characters to find an occurrence for.
Returns
Matching char, std::nullopt if no match.

Definition at line 619 of file string_consumer.hpp.

References PeekChar().

Referenced by IniLoadFile::LoadFromDisk(), ReadCharIfIn(), and SkipCharIfIn().

◆ PeekCharIfNotIn()

std::optional< char > StringConsumer::PeekCharIfNotIn ( std::string_view chars) const
inlinenodiscard

Check whether the next 8-bit char is not in 'chars'.

Parameters
charsThe set of characters to not find an occurrence for.
Returns
Non-matching char, std::nullopt if match.

Definition at line 652 of file string_consumer.hpp.

References PeekChar().

Referenced by ReadCharIfNotIn(), and SkipCharIfNotIn().

◆ PeekIf()

bool StringConsumer::PeekIf ( std::string_view str) const
inlinenodiscard

Check whether the next data matches 'str'.

Parameters
strString to compare to.
Returns
true iff the next data is equal to the string.

Definition at line 468 of file string_consumer.hpp.

Referenced by PeekCharIf(), ReadIf(), and SkipIf().

◆ PeekIntegerBase()

template<class T>
std::pair< size_type, T > StringConsumer::PeekIntegerBase ( int base,
bool clamp = false ) const
inlinenodiscard

Peek and parse an integer in number 'base'.

If 'base == 0', then a prefix '0x' decides between base 16 or base 10.

Parameters
baseThe base to interpret the string as.
clampIf the value is a valid number, but out of range for T, return the maximum representable value. Negative values for unsigned results are still treated as invalid.
Returns
Length of string match, and parsed value.
Note
The parser rejects leading whitespace and unary plus.

Definition at line 928 of file string_consumer.hpp.

References ParseIntegerBase().

Referenced by TryReadIntegerBase().

◆ PeekSint16LE()

std::optional< int16_t > StringConsumer::PeekSint16LE ( ) const
inlinenodiscard

Peek binary int16 using little endian.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 216 of file string_consumer.hpp.

References PeekUint16LE().

Referenced by ReadSint16LE(), and TryReadSint16LE().

◆ PeekSint32LE()

std::optional< int32_t > StringConsumer::PeekSint32LE ( ) const
inlinenodiscard

Peek binary int32 using little endian.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 287 of file string_consumer.hpp.

References PeekUint32LE().

Referenced by ReadSint32LE(), and TryReadSint32LE().

◆ PeekSint64LE()

std::optional< int64_t > StringConsumer::PeekSint64LE ( ) const
inlinenodiscard

Peek binary int64 using little endian.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 358 of file string_consumer.hpp.

References PeekUint64LE().

Referenced by ReadSint64LE(), and TryReadSint64LE().

◆ PeekSint8()

std::optional< int8_t > StringConsumer::PeekSint8 ( ) const
inlinenodiscard

Peek binary int8.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 147 of file string_consumer.hpp.

References PeekUint8().

Referenced by ReadSint8(), and TryReadSint8().

◆ PeekUint16LE()

std::optional< uint16_t > StringConsumer::PeekUint16LE ( ) const
nodiscard

Peek binary uint16 using little endian.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 48 of file string_consumer.cpp.

References GetBytesLeft(), position, and src.

Referenced by PeekSint16LE(), ReadUint16LE(), and TryReadUint16LE().

◆ PeekUint32LE()

std::optional< uint32_t > StringConsumer::PeekUint32LE ( ) const
nodiscard

Peek binary uint32 using little endian.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 55 of file string_consumer.cpp.

References GetBytesLeft(), position, and src.

Referenced by ByteReader::PeekDWord(), PeekSint32LE(), ReadUint32LE(), and TryReadUint32LE().

◆ PeekUint64LE()

std::optional< uint64_t > StringConsumer::PeekUint64LE ( ) const
nodiscard

Peek binary uint64 using little endian.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 64 of file string_consumer.cpp.

References GetBytesLeft(), position, and src.

Referenced by PeekSint64LE(), ReadUint64LE(), and TryReadUint64LE().

◆ PeekUint8()

std::optional< uint8_t > StringConsumer::PeekUint8 ( ) const
nodiscard

Peek binary uint8.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 42 of file string_consumer.cpp.

References GetBytesLeft(), position, and src.

Referenced by PeekChar(), PeekSint8(), ReadUint8(), and TryReadUint8().

◆ PeekUntil()

std::string_view StringConsumer::PeekUntil ( std::string_view str,
SeparatorUsage sep ) const
nodiscard

Peek data until the first occurrence of 'str'.

Parameters
strSeparator string.
sepWhether to include/exclude 'str' from the result.
Returns
The string up to the separator.

Definition at line 140 of file string_consumer.cpp.

References position, READ_ALL_SEPARATORS, READ_ONE_SEPARATOR, and src.

Referenced by PeekUntilChar(), PeekUntilUtf8(), and ReadUntil().

◆ PeekUntilChar()

std::string_view StringConsumer::PeekUntilChar ( char c,
SeparatorUsage sep ) const
inlinenodiscard

Peek data until the first occurrence of 8-bit char 'c'.

Parameters
cSeparator char.
sepWhether to include/exclude 'c' from the result.
Returns
The string up to the character.

Definition at line 810 of file string_consumer.hpp.

References PeekUntil().

◆ PeekUntilCharIn()

std::string_view StringConsumer::PeekUntilCharIn ( std::string_view chars) const
inlinenodiscard

Peek 8-bit chars, while they are not in 'chars', until they are.

Parameters
charsThe set of characters to find an occurrence for.
Returns
Non-matching chars.

Definition at line 685 of file string_consumer.hpp.

References FindCharIn(), and Peek().

◆ PeekUntilCharNotIn()

std::string_view StringConsumer::PeekUntilCharNotIn ( std::string_view chars) const
inlinenodiscard

Peek 8-bit chars, while they are in 'chars', until they are not.

Parameters
charsThe set of characters to not find an occurrence for.
Returns
Matching chars.

Definition at line 715 of file string_consumer.hpp.

References FindCharNotIn(), and Peek().

◆ PeekUntilUtf8()

std::string_view StringConsumer::PeekUntilUtf8 ( char32_t c,
SeparatorUsage sep ) const
nodiscard

Peek data until the first occurrence of UTF-8 char 'c'.

Parameters
cSeparator char.
sepWhether to include/exclude 'c' from the result.
Returns
The string up to the character.

Definition at line 160 of file string_consumer.cpp.

References EncodeUtf8(), and PeekUntil().

◆ PeekUtf8()

std::pair< StringConsumer::size_type, char32_t > StringConsumer::PeekUtf8 ( ) const
nodiscard

Peek UTF-8 character.

Returns
Length and read char, {0, 0} if no valid data.

Definition at line 84 of file string_consumer.cpp.

References DecodeUtf8(), position, and src.

Referenced by PeekUtf8If(), ReadUtf8(), ReadUtf8If(), SkipUtf8(), SkipUtf8If(), and TryReadUtf8().

◆ PeekUtf8If()

bool StringConsumer::PeekUtf8If ( char32_t c) const
inlinenodiscard

Check whether the next UTF-8 char matches 'c'.

Parameters
cThe character to match.
Returns
true iff the next character is equal to the given character.

Definition at line 524 of file string_consumer.hpp.

References PeekUtf8().

Referenced by DecodeEncodedString().

◆ Read()

std::string_view StringConsumer::Read ( size_type len)
inlinenodiscard

Read the next 'len' bytes, and advance reader.

Parameters
lenBytes to read, 'npos' to read all.
Returns
Up to 'len' bytes.

Definition at line 564 of file string_consumer.hpp.

References LogError(), npos, Peek(), and Skip().

Referenced by DecodeEncodedString(), FormatString(), FileStringReader::HandlePragma(), ReadUntilCharIn(), ReadUntilCharNotIn(), and EncodedString::ReplaceParam().

◆ ReadChar()

char StringConsumer::ReadChar ( char def = '?')
inlinenodiscard

Read 8-bit character, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read character, 'def' if not enough data.

Definition at line 412 of file string_consumer.hpp.

References PeekChar(), and SkipChar().

Referenced by DumpLine().

◆ ReadCharIf()

bool StringConsumer::ReadCharIf ( char c)
inlinenodiscard

Check whether the next 8-bit char matches 'c', and skip it.

Parameters
cThe character to match.
Returns
true iff the next character is equal to the given character.

Definition at line 506 of file string_consumer.hpp.

References ReadIf().

Referenced by BadgeClassLoadConfigFeature(), and IniLoadFile::LoadFromDisk().

◆ ReadCharIfIn()

std::optional< char > StringConsumer::ReadCharIfIn ( std::string_view chars)
inlinenodiscard

Read next 8-bit char, check whether it is in 'chars', and advance reader.

Parameters
charsThe set of characters to find an occurrence for.
Returns
Matching char, std::nullopt if no match.

Definition at line 631 of file string_consumer.hpp.

References PeekCharIfIn(), and Skip().

◆ ReadCharIfNotIn()

std::optional< char > StringConsumer::ReadCharIfNotIn ( std::string_view chars)
inlinenodiscard

Read next 8-bit char, check whether it is not in 'chars', and advance reader.

Parameters
charsThe set of characters to not find an occurrence for.
Returns
Non-matching char, std::nullopt if match.

Definition at line 664 of file string_consumer.hpp.

References PeekCharIfNotIn(), and Skip().

◆ ReadIf()

bool StringConsumer::ReadIf ( std::string_view str)
inlinenodiscard

Check whether the next data matches 'str', and skip it.

Parameters
strString to compare to.
Returns
true iff the next data is equal to the string.

Definition at line 477 of file string_consumer.hpp.

References PeekIf(), and Skip().

Referenced by DumpLine(), GetDriverParam(), ClientNetworkContentSocketHandler::OnReceiveData(), ParseIntList(), ParseResolution(), ReadCharIf(), ReadUntil(), SkipIntegerBase(), and SkipUntil().

◆ ReadIntegerBase()

template<class T>
T StringConsumer::ReadIntegerBase ( int base,
T def = 0,
bool clamp = false )
inlinenodiscard

Read and parse an integer in number 'base', and advance the reader.

If 'base == 0', then a prefix '0x' decides between base 16 or base 10.

Parameters
baseThe base to interpret the string as.
defThe default when no valid integer could be parsed.
clampIf the value is a valid number, but out of range for T, return the maximum representable value. Negative values for unsigned results are still treated as invalid.
Returns
Parsed value, or 'def' if invalid.
Note
The reader is advanced, even if no valid data was present.
The parser rejects leading whitespace and unary plus.

Definition at line 961 of file string_consumer.hpp.

References ParseIntegerBase(), and SkipIntegerBase().

Referenced by DecodeEncodedString(), FixSCCEncodedNegative(), FileStringReader::HandlePragma(), StringReader::HandlePragma(), NetworkAddress::IsInNetmask(), ClientNetworkContentSocketHandler::OnReceiveData(), SelectGameWindow::ReadIntroGameViewportCommand(), and EncodedString::ReplaceParam().

◆ ReadSint16LE()

int16_t StringConsumer::ReadSint16LE ( int16_t def = 0)
inlinenodiscard

Read binary int16 using little endian, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.
Note
The reader is advanced, even if not enough data was present.

Definition at line 238 of file string_consumer.hpp.

References PeekSint16LE(), and SkipSint16LE().

◆ ReadSint32LE()

int32_t StringConsumer::ReadSint32LE ( int32_t def = 0)
inlinenodiscard

Read binary int32 using little endian, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.
Note
The reader is advanced, even if not enough data was present.

Definition at line 309 of file string_consumer.hpp.

References PeekSint32LE(), and SkipSint32LE().

◆ ReadSint64LE()

int64_t StringConsumer::ReadSint64LE ( int64_t def = 0)
inlinenodiscard

Read binary int64 using little endian, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.
Note
The reader is advanced, even if not enough data was present.

Definition at line 380 of file string_consumer.hpp.

References PeekSint64LE(), and SkipSint64LE().

◆ ReadSint8()

int8_t StringConsumer::ReadSint8 ( int8_t def = 0)
inlinenodiscard

Read binary int8, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.

Definition at line 168 of file string_consumer.hpp.

References PeekSint8(), and SkipSint8().

◆ ReadUint16LE()

uint16_t StringConsumer::ReadUint16LE ( uint16_t def = 0)
inlinenodiscard

Read binary uint16 using little endian, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.
Note
The reader is advanced, even if not enough data was present.

Definition at line 200 of file string_consumer.hpp.

References PeekUint16LE(), and SkipUint16LE().

Referenced by FormatString(), ProcessNewGRFStringControlCode(), and TranslateTTDPatchCodes().

◆ ReadUint32LE()

uint32_t StringConsumer::ReadUint32LE ( uint32_t def = 0)
inlinenodiscard

Read binary uint32 using little endian, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.
Note
The reader is advanced, even if not enough data was present.

Definition at line 271 of file string_consumer.hpp.

References PeekUint32LE(), and SkipUint32LE().

◆ ReadUint64LE()

uint64_t StringConsumer::ReadUint64LE ( uint64_t def = 0)
inlinenodiscard

Read binary uint64 using little endian, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.
Note
The reader is advanced, even if not enough data was present.

Definition at line 342 of file string_consumer.hpp.

References PeekUint64LE(), and SkipUint64LE().

◆ ReadUint8()

uint8_t StringConsumer::ReadUint8 ( uint8_t def = 0)
inlinenodiscard

Read binary uint8, and advance reader.

Parameters
defDefault value to return, if not enough data.
Returns
Read integer, 'def' if not enough data.

Definition at line 132 of file string_consumer.hpp.

References PeekUint8(), and SkipUint8().

Referenced by FormatString(), ProcessNewGRFStringControlCode(), and TranslateTTDPatchCodes().

◆ ReadUntil()

std::string_view StringConsumer::ReadUntil ( std::string_view str,
SeparatorUsage sep )
inlinenodiscard

Read data until the first occurrence of 'str', and advance reader.

Parameters
strSeparator string.
sepWhether to include/exclude 'str' from the result, and/or skip it.
Returns
The string up to the separator.

Definition at line 764 of file string_consumer.hpp.

References PeekUntil(), ReadIf(), Skip(), SKIP_ALL_SEPARATORS, SKIP_ONE_SEPARATOR, and SkipIf().

Referenced by HasStringInExtensionList(), ReadUntilChar(), and ReadUntilUtf8().

◆ ReadUntilChar()

std::string_view StringConsumer::ReadUntilChar ( char c,
SeparatorUsage sep )
inlinenodiscard

Read data until the first occurrence of 8-bit char 'c', and advance reader.

Parameters
cSeparator char.
sepWhether to include/exclude 'c' from the result, and/or skip it.
Returns
The string up to the character.

Definition at line 820 of file string_consumer.hpp.

References ReadUntil().

Referenced by ConStartAI(), FileStringReader::HandlePragma(), StringReader::HandlePragma(), NetworkAddress::IsInNetmask(), IniLoadFile::LoadFromDisk(), ClientNetworkContentSocketHandler::OnReceiveData(), ParseCompanyManagerFaceCode(), ParseHotkeys(), ParseKeycode(), and ByteReader::ReadString().

◆ ReadUntilCharIn()

std::string_view StringConsumer::ReadUntilCharIn ( std::string_view chars)
inlinenodiscard

Read 8-bit chars, while they are not in 'chars', until they are; and advance reader.

Parameters
charsThe set of characters to find an occurrence for.
Returns
Non-matching chars.

Definition at line 695 of file string_consumer.hpp.

References FindCharIn(), and Read().

Referenced by IniLoadFile::LoadFromDisk(), and LookupManyOfMany().

◆ ReadUntilCharNotIn()

std::string_view StringConsumer::ReadUntilCharNotIn ( std::string_view chars)
inlinenodiscard

Read 8-bit chars, while they are in 'chars', until they are not; and advance reader.

Parameters
charsThe set of characters to not find an occurrence for.
Returns
Matching chars.

Definition at line 725 of file string_consumer.hpp.

References FindCharNotIn(), and Read().

Referenced by DumpLine(), and SetDebugString().

◆ ReadUntilUtf8()

std::string_view StringConsumer::ReadUntilUtf8 ( char32_t c,
SeparatorUsage sep )
nodiscard

Read data until the first occurrence of UTF-8 char 'c', and advance reader.

Parameters
cSeparator char.
sepWhether to include/exclude 'c' from the result, and/or skip it.
Returns
The string up to the character.

Definition at line 166 of file string_consumer.cpp.

References EncodeUtf8(), and ReadUntil().

Referenced by DecodeEncodedString(), FixSCCEncodedNegative(), and EncodedString::ReplaceParam().

◆ ReadUtf8()

char32_t StringConsumer::ReadUtf8 ( char32_t def = '?')
inlinenodiscard

Read UTF-8 character, and advance reader.

Parameters
defDefault value to return, if no valid data.
Returns
Read char, 'def' if no valid data.
Note
The reader is advanced, even if no valid data was present.

Definition at line 444 of file string_consumer.hpp.

References PeekUtf8(), and Skip().

Referenced by DecodeEncodedString(), FormatString(), GetKeyboardLayout(), HandleNewGRFStringControlCodes(), IConsoleAliasExec(), ProcessNewGRFStringControlCode(), SelectGameWindow::ReadIntroGameViewportCommand(), and EncodedString::ReplaceParam().

◆ ReadUtf8If()

bool StringConsumer::ReadUtf8If ( char32_t c)
inlinenodiscard

Check whether the next UTF-8 char matches 'c', and skip it.

Parameters
cThe character to match.
Returns
true iff the next character is equal to the given character.

Definition at line 534 of file string_consumer.hpp.

References PeekUtf8(), and Skip().

Referenced by FixSCCEncodedNegative(), FormatString(), IConsoleCmdExec(), EncodedString::ReplaceParam(), and TranslateTTDPatchCodes().

◆ Skip()

◆ SkipAll()

void StringConsumer::SkipAll ( )
inline

Discard all remaining data.

Definition at line 110 of file string_consumer.hpp.

Referenced by DecodeEncodedString().

◆ SkipChar()

void StringConsumer::SkipChar ( )
inline

Skip 8-bit character, and advance reader.

Definition at line 420 of file string_consumer.hpp.

References Skip().

Referenced by ReadChar(), and TryReadChar().

◆ SkipCharIf()

void StringConsumer::SkipCharIf ( char c)
inline

If the next data matches the 8-bit char 'c', then skip it.

Parameters
cThe character to match.

Definition at line 514 of file string_consumer.hpp.

References SkipIf().

◆ SkipCharIfIn()

void StringConsumer::SkipCharIfIn ( std::string_view chars)
inline

If the next 8-bit char is in 'chars', skip it.

Parameters
charsThe set of characters to find an occurrence for.

Definition at line 641 of file string_consumer.hpp.

References PeekCharIfIn(), and Skip().

◆ SkipCharIfNotIn()

void StringConsumer::SkipCharIfNotIn ( std::string_view chars)
inline

If the next 8-bit char is not in 'chars', skip it.

Parameters
charsThe set of characters to not find an occurrence for.

Definition at line 674 of file string_consumer.hpp.

References PeekCharIfNotIn(), and Skip().

◆ SkipIf()

void StringConsumer::SkipIf ( std::string_view str)
inline

If the next data matches 'str', then skip it.

Parameters
strString to compare to.

Definition at line 487 of file string_consumer.hpp.

References PeekIf(), and Skip().

Referenced by ReadUntil(), SkipCharIf(), SkipIntegerBase(), and SkipUntil().

◆ SkipIntegerBase()

void StringConsumer::SkipIntegerBase ( int base)

Skip an integer in number 'base'.

If 'base == 0', then a prefix '0x' decides between base 16 or base 10.

Parameters
baseThe base to interpret the string as.
Note
The reader is advanced, even if no valid data was present.
The parser rejects leading whitespace and unary plus.

Definition at line 178 of file string_consumer.cpp.

References ReadIf(), SkipIf(), and SkipUntilCharNotIn().

Referenced by ReadIntegerBase(), and TryReadIntegerBase().

◆ SkipSint16LE()

void StringConsumer::SkipSint16LE ( )
inline

Skip binary int16, and advance reader.

Note
The reader is advanced, even if not enough data was present.

Definition at line 248 of file string_consumer.hpp.

References Skip().

Referenced by ReadSint16LE(), and TryReadSint16LE().

◆ SkipSint32LE()

void StringConsumer::SkipSint32LE ( )
inline

Skip binary int32, and advance reader.

Note
The reader is advanced, even if not enough data was present.

Definition at line 319 of file string_consumer.hpp.

References Skip().

Referenced by ReadSint32LE(), and TryReadSint32LE().

◆ SkipSint64LE()

void StringConsumer::SkipSint64LE ( )
inline

Skip binary int64, and advance reader.

Note
The reader is advanced, even if not enough data was present.

Definition at line 390 of file string_consumer.hpp.

References Skip().

Referenced by ReadSint64LE(), and TryReadSint64LE().

◆ SkipSint8()

void StringConsumer::SkipSint8 ( )
inline

Skip binary int8.

Definition at line 177 of file string_consumer.hpp.

References Skip().

Referenced by ReadSint8(), and TryReadSint8().

◆ SkipUint16LE()

void StringConsumer::SkipUint16LE ( )
inline

Skip binary uint16, and advance reader.

Note
The reader is advanced, even if not enough data was present.

Definition at line 210 of file string_consumer.hpp.

References Skip().

Referenced by ProcessNewGRFStringControlCode(), ReadUint16LE(), and TryReadUint16LE().

◆ SkipUint32LE()

void StringConsumer::SkipUint32LE ( )
inline

Skip binary uint32, and advance reader.

Note
The reader is advanced, even if not enough data was present.

Definition at line 281 of file string_consumer.hpp.

References Skip().

Referenced by ReadUint32LE(), and TryReadUint32LE().

◆ SkipUint64LE()

void StringConsumer::SkipUint64LE ( )
inline

Skip binary uint64, and advance reader.

Note
The reader is advanced, even if not enough data was present.

Definition at line 352 of file string_consumer.hpp.

References Skip().

Referenced by ReadUint64LE(), and TryReadUint64LE().

◆ SkipUint8()

void StringConsumer::SkipUint8 ( )
inline

Skip binary uint8.

Definition at line 141 of file string_consumer.hpp.

References Skip().

Referenced by ProcessNewGRFStringControlCode(), ReadUint8(), TranslateTTDPatchCodes(), and TryReadUint8().

◆ SkipUntil()

void StringConsumer::SkipUntil ( std::string_view str,
SeparatorUsage sep )
inline

Skip data until the first occurrence of 'str'.

Parameters
strSeparator string.
sepWhether to also skip 'str'.

Definition at line 786 of file string_consumer.hpp.

References Find(), READ_ALL_SEPARATORS, READ_ONE_SEPARATOR, ReadIf(), Skip(), SKIP_ALL_SEPARATORS, SKIP_ONE_SEPARATOR, and SkipIf().

Referenced by SkipUntilChar(), and SkipUntilUtf8().

◆ SkipUntilChar()

void StringConsumer::SkipUntilChar ( char c,
SeparatorUsage sep )
inline

Skip data until the first occurrence of 8-bit char 'c'.

Parameters
cSeparator char.
sepWhether to also skip 'c'.

Definition at line 829 of file string_consumer.hpp.

References SkipUntil().

Referenced by ClientNetworkContentSocketHandler::OnReceiveData().

◆ SkipUntilCharIn()

void StringConsumer::SkipUntilCharIn ( std::string_view chars)
inline

Skip 8-bit chars, while they are not in 'chars', until they are.

Parameters
charsThe set of characters to find an occurrence for.

Definition at line 704 of file string_consumer.hpp.

References FindCharIn(), and Skip().

Referenced by SetDebugString().

◆ SkipUntilCharNotIn()

void StringConsumer::SkipUntilCharNotIn ( std::string_view chars)
inline

Skip 8-bit chars, while they are in 'chars', until they are not.

Parameters
charsThe set of characters to not find an occurrence for.

Definition at line 734 of file string_consumer.hpp.

References FindCharNotIn(), and Skip().

Referenced by IniLoadFile::LoadFromDisk(), LookupManyOfMany(), ParseInteger(), ParseIntList(), and SkipIntegerBase().

◆ SkipUntilUtf8()

void StringConsumer::SkipUntilUtf8 ( char32_t c,
SeparatorUsage sep )

Skip data until the first occurrence of UTF-8 char 'c'.

Parameters
cSeparator char.
sepWhether to also skip 'c'.

Definition at line 172 of file string_consumer.cpp.

References EncodeUtf8(), and SkipUntil().

◆ SkipUtf8()

void StringConsumer::SkipUtf8 ( )
inline

Skip UTF-8 character, and advance reader.

Note
The reader is advanced, even if no valid data was present.
This behaves different to Utf8View::iterator. Here we do not skip overlong encodings, because we want to allow binary data to follow UTF-8 data.

Definition at line 457 of file string_consumer.hpp.

References PeekUtf8(), and Skip().

Referenced by RemapNewGRFStringControlCode().

◆ SkipUtf8If()

void StringConsumer::SkipUtf8If ( char32_t c)
inline

If the next data matches the UTF-8 char 'c', then skip it.

Parameters
cThe character to match.

Definition at line 545 of file string_consumer.hpp.

References PeekUtf8(), and Skip().

Referenced by DecodeEncodedString().

◆ TryReadChar()

std::optional< char > StringConsumer::TryReadChar ( )
inlinenodiscard

Try to read a 8-bit character, and then advance reader.

Returns
Read character, std::nullopt if not enough data.

Definition at line 401 of file string_consumer.hpp.

References PeekChar(), and SkipChar().

◆ TryReadIntegerBase()

template<class T>
std::optional< T > StringConsumer::TryReadIntegerBase ( int base,
bool clamp = false )
inlinenodiscard

Try to read and parse an integer in number 'base', and then advance the reader.

If 'base == 0', then a prefix '0x' decides between base 16 or base 10.

Parameters
baseThe base to interpret the string as.
clampIf the value is a valid number, but out of range for T, return the maximum representable value. Negative values for unsigned results are still treated as invalid.
Returns
Parsed value, if valid.
Note
The parser rejects leading whitespace and unary plus.

Definition at line 942 of file string_consumer.hpp.

References PeekIntegerBase(), and SkipIntegerBase().

Referenced by BadgeClassLoadConfigFeature(), ConNewGRFProfile(), ConStartAI(), FileList::FindItem(), FixSCCEncodedNegative(), ParseCompanyManagerFaceCode(), ParseInteger(), ParseIntList(), ParseResolution(), OneOfManySettingDesc::ParseSingleValue(), IntSettingDesc::ParseValue(), EncodedString::ReplaceParam(), and SetDebugString().

◆ TryReadSint16LE()

std::optional< int16_t > StringConsumer::TryReadSint16LE ( )
inlinenodiscard

Try to read binary int16, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 226 of file string_consumer.hpp.

References PeekSint16LE(), and SkipSint16LE().

◆ TryReadSint32LE()

std::optional< int32_t > StringConsumer::TryReadSint32LE ( )
inlinenodiscard

Try to read binary int32, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 297 of file string_consumer.hpp.

References PeekSint32LE(), and SkipSint32LE().

◆ TryReadSint64LE()

std::optional< int64_t > StringConsumer::TryReadSint64LE ( )
inlinenodiscard

Try to read binary int64, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 368 of file string_consumer.hpp.

References PeekSint64LE(), and SkipSint64LE().

◆ TryReadSint8()

std::optional< int8_t > StringConsumer::TryReadSint8 ( )
inlinenodiscard

Try to read binary int8, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 157 of file string_consumer.hpp.

References PeekSint8(), and SkipSint8().

◆ TryReadUint16LE()

std::optional< uint16_t > StringConsumer::TryReadUint16LE ( )
inlinenodiscard

Try to read binary uint16, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 188 of file string_consumer.hpp.

References PeekUint16LE(), and SkipUint16LE().

Referenced by ByteReader::ReadWord().

◆ TryReadUint32LE()

std::optional< uint32_t > StringConsumer::TryReadUint32LE ( )
inlinenodiscard

Try to read binary uint32, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 259 of file string_consumer.hpp.

References PeekUint32LE(), and SkipUint32LE().

Referenced by ByteReader::ReadDWord().

◆ TryReadUint64LE()

std::optional< uint64_t > StringConsumer::TryReadUint64LE ( )
inlinenodiscard

Try to read binary uint64, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 330 of file string_consumer.hpp.

References PeekUint64LE(), and SkipUint64LE().

◆ TryReadUint8()

std::optional< uint8_t > StringConsumer::TryReadUint8 ( )
inlinenodiscard

Try to read binary uint8, and then advance reader.

Returns
Read integer, std::nullopt if not enough data.

Definition at line 121 of file string_consumer.hpp.

References PeekUint8(), and SkipUint8().

Referenced by ByteReader::ReadByte().

◆ TryReadUtf8()

std::optional< char32_t > StringConsumer::TryReadUtf8 ( )
inlinenodiscard

Try to read a UTF-8 character, and then advance reader.

Returns
Read character, std::nullopt if not enough data.

Definition at line 431 of file string_consumer.hpp.

References PeekUtf8(), and Skip().

Referenced by FixSCCEncoded(), IConsoleAliasExec(), IConsoleCmdExec(), StrMakeValid(), StrValid(), and TranslateTTDPatchCodes().

Field Documentation

◆ npos

size_type StringConsumer::npos = std::string_view::npos
staticconstexpr

Special value for "end of data".

Definition at line 33 of file string_consumer.hpp.

Referenced by DecodeEncodedString(), FileStringReader::HandlePragma(), ParseCompanyManagerFaceCode(), Read(), and EncodedString::ReplaceParam().

◆ position

size_type StringConsumer::position = 0
private

The current parsing position in the string.

Definition at line 48 of file string_consumer.hpp.

Referenced by Find(), FindCharIn(), FindCharNotIn(), Peek(), PeekUint16LE(), PeekUint32LE(), PeekUint64LE(), PeekUint8(), PeekUntil(), PeekUtf8(), and Skip().

◆ src

std::string_view StringConsumer::src
private

◆ WHITESPACE_NO_NEWLINE

const std::string_view StringConsumer::WHITESPACE_NO_NEWLINE = "\t\v\f\r "
static

ASCII whitespace characters, excluding new-line.

Usable in FindChar(In|NotIn), (Peek|Read|Skip)(If|Until)Char(In|NotIn)

Definition at line 39 of file string_consumer.hpp.

Referenced by ConClientNickChange(), ConsoleAutoCompletion::GetSuggestions(), ParseCode(), ParseInteger(), ParseIntList(), and StrTrimInPlace().

◆ WHITESPACE_OR_NEWLINE

const std::string_view StringConsumer::WHITESPACE_OR_NEWLINE = "\t\n\v\f\r "
static

ASCII whitespace characters, including new-line.

Usable in FindChar(In|NotIn), (Peek|Read|Skip)(If|Until)Char(In|NotIn)

Definition at line 44 of file string_consumer.hpp.

Referenced by IniLoadFile::LoadFromDisk(), StringReader::ParseFile(), and ReadRawLanguageStrings().


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