SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
Text.h File Reference
#include <stdexcept>
#include <string_view>
#include <unordered_map>
Include dependency graph for Text.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  sourcepp::parser::text::syntax_error

Namespaces

namespace  sourcepp
namespace  sourcepp::parser
namespace  sourcepp::parser::text

Typedefs

using sourcepp::parser::text::EscapeSequenceMap = std::unordered_map<char, char>

Functions

const EscapeSequenceMapsourcepp::parser::text::getDefaultEscapeSequences ()
const EscapeSequenceMapsourcepp::parser::text::getDefaultEscapeSequencesOrNone (bool useEscapes)
bool sourcepp::parser::text::isNewLine (char c)
 If a char is a newline character.
bool sourcepp::parser::text::isNewLine (std::string_view str)
 If a string is entirely composed of newline characters.
bool sourcepp::parser::text::isWhitespace (char c)
 If a char is a whitespace character.
bool sourcepp::parser::text::isWhitespace (std::string_view str)
 If a string is entirely composed of whitespace characters.
bool sourcepp::parser::text::isNumber (char c)
 If a char is a numerical character (0-9).
bool sourcepp::parser::text::isNumber (std::string_view str)
 If a string is entirely composed of numerical characters (0-9).
std::string sourcepp::parser::text::convertSpecialCharsToEscapes (std::string_view str, const EscapeSequenceMap &escapeSequences)
 Convert special characters like \n to escaped special characters like \\n.
std::string sourcepp::parser::text::convertEscapesToSpecialChars (std::string_view str, const EscapeSequenceMap &escapeSequences)
 Convert escaped special characters like \\n to special characters like \n.
void sourcepp::parser::text::eatWhitespace (BufferStream &stream)
 Eat all whitespace after the current stream position.
void sourcepp::parser::text::eatSingleLineComment (BufferStream &stream)
 If a single line comment is detected, eat its contents.
void sourcepp::parser::text::eatMultiLineComment (BufferStream &stream, std::string_view multiLineCommentEnd=DEFAULT_MULTI_LINE_COMMENT_END)
 If a multi line comment is detected, eat its contents.
void sourcepp::parser::text::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 sourcepp::parser::text::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 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.
bool sourcepp::parser::text::tryToEatChar (BufferStream &stream, char c)
 If the given char exists at the current position, skip over it.
std::string sourcepp::parser::text::readString (BufferStream &stream, std::string_view start=DEFAULT_STRING_START, std::string_view end=DEFAULT_STRING_END, const EscapeSequenceMap &escapeSequences=getDefaultEscapeSequences())
 Read a string starting at the current stream position.
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=getDefaultEscapeSequences())
 Read a string starting at the current stream position.
std::string sourcepp::parser::text::readUnquotedString (BufferStream &stream, const EscapeSequenceMap &escapeSequences=getDefaultEscapeSequences())
 Read a string starting at the current stream position.
std::string_view sourcepp::parser::text::readUnquotedStringToBuffer (BufferStream &stream, BufferStream &backing, const EscapeSequenceMap &escapeSequences=getDefaultEscapeSequences())
 Read a string starting at the current stream position.
std::string sourcepp::parser::text::readUnquotedString (BufferStream &stream, std::string_view end, const EscapeSequenceMap &escapeSequences=getDefaultEscapeSequences())
 Read a string starting at the current stream position.
std::string_view sourcepp::parser::text::readUnquotedStringToBuffer (BufferStream &stream, BufferStream &backing, std::string_view end, const EscapeSequenceMap &escapeSequences=getDefaultEscapeSequences())
 Read a string starting at the current stream position.

Variables

constexpr std::string_view sourcepp::parser::text::DEFAULT_SINGLE_LINE_COMMENT_START = "//"
constexpr std::string_view sourcepp::parser::text::DEFAULT_MULTI_LINE_COMMENT_START = "/*"
constexpr std::string_view sourcepp::parser::text::DEFAULT_MULTI_LINE_COMMENT_END = "*/"
constexpr std::string_view sourcepp::parser::text::DEFAULT_STRING_START = "\""
constexpr std::string_view sourcepp::parser::text::DEFAULT_STRING_END = "\""