GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::base16 Namespace Reference

Functions

constexpr bool isHexadecimalDigit (char ch) noexcept
 Check if a character value represents a valid hexadecimal Base16 character (ASCII values '0'-'9', 'A'-'F' or 'a'-'f').
constexpr Optional< int > getHexadecimalDigitValue (char ch) noexcept
 Get the hexadecimal digit value of a Base16 character.
String encodeLowercase (StringView data)
 Encode arbitrary data into a lowercase hexadecimal Base16 string.
String encodeUppercase (StringView data)
 Encode arbitrary data into an uppercase hexadecimal Base16 string.
String decode (StringView string)
 Decode the original data from a lowercase or uppercase hexadecimal Base16 string.

Function Documentation

◆ isHexadecimalDigit()

bool grem::base16::isHexadecimalDigit ( char ch)
nodiscardconstexprnoexcept

Check if a character value represents a valid hexadecimal Base16 character (ASCII values '0'-'9', 'A'-'F' or 'a'-'f').

Parameters
chcharacter to check.
Returns
true if the character is valid, false otherwise.

◆ getHexadecimalDigitValue()

Optional< int > grem::base16::getHexadecimalDigitValue ( char ch)
nodiscardconstexprnoexcept

Get the hexadecimal digit value of a Base16 character.

(ASCII values '0'-'9', 'A'-'F' or 'a'-'f').

Parameters
chcharacter to get the value of.
Returns
an integer value between 0 and 15 (inclusive), or an empty optional if the given character was invalid.

◆ encodeLowercase()

String grem::base16::encodeLowercase ( StringView data)

Encode arbitrary data into a lowercase hexadecimal Base16 string.

Parameters
datainput data to encode.
Returns
a Base16 string containing the encoded representation of the input.
Exceptions
std::length_errorif the length of the encoded string exceeds the maximum supported string size.
std::bad_allocon allocation failure.

◆ encodeUppercase()

String grem::base16::encodeUppercase ( StringView data)

Encode arbitrary data into an uppercase hexadecimal Base16 string.

Parameters
datainput data to encode.
Returns
a Base16 string containing the encoded representation of the input.
Exceptions
std::length_errorif the length of the encoded string exceeds the maximum supported string size.
std::bad_allocon allocation failure.

◆ decode()

String grem::base16::decode ( StringView string)

Decode the original data from a lowercase or uppercase hexadecimal Base16 string.

Parameters
stringBase16 string to decode.
Returns
a byte sequence containing the data decoded from the Base16 string.
Exceptions
std::invalid_argumentif the length of the Base16 string is not divisible by 2.
std::length_errorif the length of the decoded byte sequence exceeds the maximum supported string size.
std::bad_allocon allocation failure.