![]() |
SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
|
Classes | |
class | syntax_error |
Typedefs | |
using | EscapeSequenceMap = std::unordered_map< char, char > |
Functions | |
bool | isNewLine (char c) |
If a char is a newline character. | |
bool | isNewLine (std::string_view str) |
If a string is entirely composed of newline characters. | |
bool | isWhitespace (char c) |
If a char is a whitespace character. | |
bool | isWhitespace (std::string_view str) |
If a string is entirely composed of whitespace characters. | |
bool | isNumber (char c) |
If a char is a numerical character (0-9). | |
bool | isNumber (std::string_view str) |
If a string is entirely composed of numerical characters (0-9). | |
std::string | convertSpecialCharsToEscapes (std::string_view str, const EscapeSequenceMap &escapeSequences) |
Convert special characters like \n to escaped special characters like \\n. | |
std::string | convertEscapesToSpecialChars (std::string_view str, const EscapeSequenceMap &escapeSequences) |
Convert escaped special characters like \\n to special characters like \n. | |
void | eatWhitespace (BufferStream &stream) |
Eat all whitespace after the current stream position. | |
void | eatSingleLineComment (BufferStream &stream) |
If a single line comment is detected, eat its contents. | |
void | eatMultiLineComment (BufferStream &stream, std::string_view multiLineCommentEnd=DEFAULT_MULTI_LINE_COMMENT_END) |
If a multi line comment is detected, eat its contents. | |
void | eatWhitespaceAndSingleLineComments (BufferStream &stream, std::string_view singleLineCommentStart=DEFAULT_SINGLE_LINE_COMMENT_START) |
Eat all whitespace and single line comments after the current stream position. | |
void | eatWhitespaceAndMultiLineComments (BufferStream &stream, std::string_view multiLineCommentStart=DEFAULT_MULTI_LINE_COMMENT_START) |
Eat all whitespace and multi line comments after the current stream position. | |
void | eatWhitespaceAndComments (BufferStream &stream, std::string_view singleLineCommentStart=DEFAULT_SINGLE_LINE_COMMENT_START, std::string_view multiLineCommentStart=DEFAULT_MULTI_LINE_COMMENT_START) |
Eat all whitespace and comments after the current stream position. | |
bool | tryToEatChar (BufferStream &stream, char c) |
If the given char exists at the current position, skip over it. | |
std::string_view | readStringToBuffer (BufferStream &stream, BufferStream &backing, std::string_view start=DEFAULT_STRING_START, std::string_view end=DEFAULT_STRING_END, const EscapeSequenceMap &escapeSequences=DEFAULT_ESCAPE_SEQUENCES) |
Read a string starting at the current stream position. | |
std::string_view | readUnquotedStringToBuffer (BufferStream &stream, BufferStream &backing, const EscapeSequenceMap &escapeSequences=DEFAULT_ESCAPE_SEQUENCES) |
Read a string starting at the current stream position. | |
std::string_view | readUnquotedStringToBuffer (BufferStream &stream, BufferStream &backing, std::string_view end, const EscapeSequenceMap &escapeSequences=DEFAULT_ESCAPE_SEQUENCES) |
Read a string starting at the current stream position. | |
Variables | |
constexpr std::string_view | DEFAULT_SINGLE_LINE_COMMENT_START = "//" |
constexpr std::string_view | DEFAULT_MULTI_LINE_COMMENT_START = "/*" |
constexpr std::string_view | DEFAULT_MULTI_LINE_COMMENT_END = "*/" |
constexpr std::string_view | DEFAULT_STRING_START = "\"" |
constexpr std::string_view | DEFAULT_STRING_END = "\"" |
const EscapeSequenceMap | DEFAULT_ESCAPE_SEQUENCES |
const EscapeSequenceMap | NO_ESCAPE_SEQUENCES = {} |
using sourcepp::parser::text::EscapeSequenceMap = typedef std::unordered_map<char, char> |
std::string sourcepp::parser::text::convertEscapesToSpecialChars | ( | std::string_view | str, |
const EscapeSequenceMap & | escapeSequences | ||
) |
std::string sourcepp::parser::text::convertSpecialCharsToEscapes | ( | std::string_view | str, |
const EscapeSequenceMap & | escapeSequences | ||
) |
void sourcepp::parser::text::eatMultiLineComment | ( | BufferStream & | stream, |
std::string_view | multiLineCommentEnd = DEFAULT_MULTI_LINE_COMMENT_END |
||
) |
void sourcepp::parser::text::eatSingleLineComment | ( | BufferStream & | stream | ) |
void sourcepp::parser::text::eatWhitespace | ( | BufferStream & | stream | ) |
void sourcepp::parser::text::eatWhitespaceAndComments | ( | BufferStream & | stream, |
std::string_view | singleLineCommentStart = DEFAULT_SINGLE_LINE_COMMENT_START , |
||
std::string_view | multiLineCommentStart = DEFAULT_MULTI_LINE_COMMENT_START |
||
) |
Eat all whitespace and comments after the current stream position.
stream | The BufferStream to modify. |
singleLineCommentStart | The single line comment start sequence. Leave empty to skip checking for single line comments. |
multiLineCommentStart | The multi line comment start sequence. Leave empty to skip checking for multi line comments. |
void sourcepp::parser::text::eatWhitespaceAndMultiLineComments | ( | BufferStream & | stream, |
std::string_view | multiLineCommentStart = DEFAULT_MULTI_LINE_COMMENT_START |
||
) |
void sourcepp::parser::text::eatWhitespaceAndSingleLineComments | ( | BufferStream & | stream, |
std::string_view | singleLineCommentStart = DEFAULT_SINGLE_LINE_COMMENT_START |
||
) |
bool sourcepp::parser::text::isNewLine | ( | char | c | ) |
bool sourcepp::parser::text::isNewLine | ( | std::string_view | str | ) |
bool sourcepp::parser::text::isNumber | ( | char | c | ) |
bool sourcepp::parser::text::isNumber | ( | std::string_view | str | ) |
bool sourcepp::parser::text::isWhitespace | ( | char | c | ) |
bool sourcepp::parser::text::isWhitespace | ( | std::string_view | str | ) |
std::string_view sourcepp::parser::text::readStringToBuffer | ( | BufferStream & | stream, |
BufferStream & | backing, | ||
std::string_view | start = DEFAULT_STRING_START , |
||
std::string_view | end = DEFAULT_STRING_END , |
||
const EscapeSequenceMap & | escapeSequences = DEFAULT_ESCAPE_SEQUENCES |
||
) |
Read a string starting at the current stream position.
stream | The BufferStream to modify. |
backing | The BufferStream to store the string data in. |
start | The starting string chars. If any processed char is in this string, the string will be treated as "quoted" and will include spaces. |
end | The ending string chars. If any processed char is in this string, and a starting char is detected, the string will terminate. |
escapeSequences | Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map. |
std::string_view sourcepp::parser::text::readUnquotedStringToBuffer | ( | BufferStream & | stream, |
BufferStream & | backing, | ||
const EscapeSequenceMap & | escapeSequences = DEFAULT_ESCAPE_SEQUENCES |
||
) |
Read a string starting at the current stream position.
stream | The BufferStream to modify. |
backing | The BufferStream to store the string data in. |
escapeSequences | Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map. |
std::string_view sourcepp::parser::text::readUnquotedStringToBuffer | ( | BufferStream & | stream, |
BufferStream & | backing, | ||
std::string_view | end, | ||
const EscapeSequenceMap & | escapeSequences = DEFAULT_ESCAPE_SEQUENCES |
||
) |
Read a string starting at the current stream position.
stream | The BufferStream to modify. |
backing | The BufferStream to store the string data in. |
end | The ending string chars. If any processed char is in this string, the string will terminate. |
escapeSequences | Characters that will be escaped if a backslash is present before them. To disable escapes, pass an empty map. |
bool sourcepp::parser::text::tryToEatChar | ( | BufferStream & | stream, |
char | c | ||
) |
const EscapeSequenceMap sourcepp::parser::text::DEFAULT_ESCAPE_SEQUENCES |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
const EscapeSequenceMap sourcepp::parser::text::NO_ESCAPE_SEQUENCES = {} |