MT Core (C++)
Core library for replacing C++ standard in project usage
|
ASCII related operations. More...
Namespaces | |
namespace | mtcore::ascii |
ASCII-related methods for parsing and character classification Split into its own namespace to allow for clear differentiation from any unicode-related methods. | |
Functions | |
bool | mtcore::ascii::is_digit (const char c) |
Checks if a character is an ASCII digit (0-9) | |
bool | mtcore::ascii::is_hex (const char c) |
Checks if a character is an ASCII hex digit (0-9, a-f, A-F) | |
bool | mtcore::ascii::is_hex_str (Slice< const char > str) |
Checks if a string is composed of only hex characters Will return false if string is empty. | |
bool | mtcore::ascii::is_int_str (Slice< const char > str) |
Checks if a string is composed of only integer characters Will return false if string is empty. | |
bool | mtcore::ascii::is_pos_int_str (Slice< const char > str) |
Checks if a string is composed of only positive integer characters Will return false if string is empty. | |
template<typename Out = i32> | |
Result< Out, AsciiNumericParseError > | mtcore::ascii::hex_to_int (const Slice< const char > &parse) |
Tries to parse an ASCII hex string into an integer Will return an error if the parsed string does not fit. | |
template<typename Out = i32> | |
Result< Out, AsciiNumericParseError > | mtcore::ascii::base10_to_int (const Slice< const char > &parse) |
Tries to parse an ASCII numeric string into an integer Will return an error if the parsed string does not fit. | |
Result< char, UnescapeError > | mtcore::ascii::unescape_char (Slice< const char > str, char escapeChar='\\') |
Unescapes the first (potentially) escaped character in a character sequence If the sequence is empty, will return an error. | |
template<typename Writer> | |
Result< size_t, std::variant< typename Writer::ErrType, UnescapeError > > | mtcore::ascii::write_unescaped (Writer &writer, Slice< const char > str, char escapeChar='\\') |
Writes unescaped ASCII characters to a stream Note: This does NOT support writing Unicode escape codes at this time (so \uhhhh or \Uhhhhhhhh) | |
ASCII related operations.
Result< Out, AsciiNumericParseError > mtcore::ascii::base10_to_int | ( | const Slice< const char > & | parse | ) |
Tries to parse an ASCII numeric string into an integer Will return an error if the parsed string does not fit.
Out | Out integer type |
parse | ASCII string to parse |
Definition at line 244 of file ascii.hpp.
Result< Out, AsciiNumericParseError > mtcore::ascii::hex_to_int | ( | const Slice< const char > & | parse | ) |
Tries to parse an ASCII hex string into an integer Will return an error if the parsed string does not fit.
Out | Out integer type |
parse | ASCII string to parse |
Definition at line 156 of file ascii.hpp.
|
inline |
|
inline |
Checks if a character is an ASCII hex digit (0-9, a-f, A-F)
c | Character to check |
Definition at line 58 of file ascii.hpp.
|
inline |
Checks if a string is composed of only hex characters Will return false if string is empty.
str | String to check |
Definition at line 72 of file ascii.hpp.
|
inline |
Checks if a string is composed of only integer characters Will return false if string is empty.
str | String to check |
Definition at line 93 of file ascii.hpp.
|
inline |
Checks if a string is composed of only positive integer characters Will return false if string is empty.
str | String to check |
Definition at line 123 of file ascii.hpp.
|
inline |
Unescapes the first (potentially) escaped character in a character sequence If the sequence is empty, will return an error.
str | String to unescape |
escapeChar | Escape character |
Definition at line 343 of file ascii.hpp.
Result< size_t, std::variant< typename Writer::ErrType, UnescapeError > > mtcore::ascii::write_unescaped | ( | Writer & | writer, |
Slice< const char > | str, | ||
char | escapeChar = '\\' ) |
Writes unescaped ASCII characters to a stream Note: This does NOT support writing Unicode escape codes at this time (so \uhhhh or \Uhhhhhhhh)
Supported escape sequences (assuming escape character is \):
All other escaped characters are that escaped character (e.g. \ => \, \{ => {)
Writer | Writer type to write to |
writer | Writer to write to |
str | String to write |
escapeChar | Character to recognize as the escape character (default is '\') |
Definition at line 447 of file ascii.hpp.