MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
ascii.hpp File Reference
#include "mtcore/colls/result.hpp"
#include "mtcore/colls/slice.hpp"
#include "mtcore/core.hpp"
#include <array>
#include <limits>
Include dependency graph for ascii.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mtcore::ascii::UnescapeError
 Error when unescaping characters fails. More...
 

Namespaces

namespace  mtcore
 Core library for C++ with Zig-related functionality.
 
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.
 

Enumerations

enum class  mtcore::ascii::AsciiNumericParseError { mtcore::ascii::AsciiNumericParseError::INVALID_SLICE , mtcore::ascii::AsciiNumericParseError::INVALID_SIGN , mtcore::ascii::AsciiNumericParseError::INVALID_INPUT , mtcore::ascii::AsciiNumericParseError::OVERFLOW_DETECTED }
 Errors when parsing ASCII strings as numbers. More...
 

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, AsciiNumericParseErrormtcore::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, AsciiNumericParseErrormtcore::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, UnescapeErrormtcore::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)