Simple "C" string hexadecimal conversion class. More...
Public Member Functions | |
NumberStringHex () noexcept | |
Default constructor. | |
template<class T > | |
NumberStringHex (T input) noexcept | |
Default constructor for an integral. | |
template<class T > | |
NumberStringHex (T uInput, uint_t uFormat) noexcept | |
Default constructor for an integral with formatting. | |
template<class T > | |
NumberStringHex & | operator= (T input) noexcept |
Copy operator for an integral. | |
operator const char * () const noexcept | |
Get a pointer to the string. | |
const char * | data (void) const noexcept |
Get a pointer to the string. | |
const char * | c_str (void) const noexcept |
Get a pointer to the string. | |
char | operator[] (uintptr_t uIndex) const noexcept |
Get a character from the string. | |
const char & | operator[] (uintptr_t uIndex) noexcept |
Get a character reference from the string. | |
void | clear (void) noexcept |
Erase the string. | |
uint_t | empty (void) const noexcept |
Return TRUE if the string is blank. | |
uintptr_t | length (void) const noexcept |
Get the length of the string in bytes. | |
uintptr_t | capacity (void) const noexcept |
Get the size of the internal buffer in bytes. | |
Private Attributes | |
char | m_Data [24] |
String buffer. | |
Simple "C" string hexadecimal conversion class.
To convert a hexadecimal number into a string quickly and without the worry of creating a text buffer to contain the ASCII string, use this class. Once the string is created, you can access via NumberStringHex::c_str() const or const char * accessors.
The main benefit of this class is that the string buffer is part of the class instance, so no behind the scenes memory allocation is performed. It's best used with creating a local on the stack instance with the number to be converted as input to the constructor. After which, the program can access the string and use it as needed.
Most constructors can take an optional format parameter so the code can have some control as to how the string is created.
|
inlinenoexcept |
Default constructor.
Initialize to an empty string
Default constructor for an integral.
Convert the integral into an ASCII hex string and store that string inside the class. The resulting string is from 1 to 8 digits in length depending on the number of bytes the integral occupies.
T | input data type, tested with is_integral. |
input | Integral value to print in HEX to a string. |
Default constructor for an integral with formatting.
Convert the integral into an ASCII hex string and store that string inside the class. The resulting string is from 1 to 8 digits in length in length depending on the number of bytes the integral occupies. Formatting will have some influence on the string's length.
The format parameter is passed directly to NumberToAsciiHex(char*,T,uint_t), please see that function's documentation for what values you can pass.
T | input data type, tested with is_integral. |
input | Integral value to print in HEX to a string. |
uFormat | Formatting parameter. |
|
inlinenoexcept |
Get a pointer to the string.
Retrieve a char * to the string contained in this class. The pointer is const because this class was not meant to have anything modify the string without the class knowing about the operation.
|
inlinenoexcept |
Get the size of the internal buffer in bytes.
Return the immutable buffer length.
|
inlinenoexcept |
|
inlinenoexcept |
Get a pointer to the string.
Retrieve a char * to the string contained in this class. The pointer is const because this class was not meant to have anything modify the string without the class knowing about the operation.
|
inlinenoexcept |
|
inlinenoexcept |
Get the length of the string in bytes.
By calling Burger::StringLength(), return the length of the string contained within.
Get a pointer to the string.
Retrieve a char * to the string contained in this class. The pointer is const because this class was not meant to have anything modify the string without the class knowing about the operation.
Copy operator for an integral.
Convert the 32 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is 8 digits in length.
T | input data type, tested with is_integral. |
input | Integral value to print in HEX to a string. |
|
inlinenoexcept |
Get a character from the string.
Retrieve a char from inside the string contained in this class. There is no bounds checking performed on the index passed just like if this were a literal char array.
|
inlinenoexcept |
Get a character reference from the string.
Retrieve a const char reference from inside the string contained in this class. There is no bounds checking performed on the index passed just like if this were a literal char array.