Simple "C" string numeric conversion class. More...
Public Member Functions | |
NumberString () noexcept | |
Default constructor. | |
NumberString (uint32_t uInput) noexcept | |
Default constructor for an unsigned 32 bit integer. | |
NumberString (uint32_t uInput, uint_t uFormat) noexcept | |
Default constructor for an unsigned 32 bit integer with formatting. | |
NumberString (int32_t iInput) noexcept | |
Default constructor for a signed 32 bit integer. | |
NumberString (int32_t iInput, uint_t uFormat) noexcept | |
Default constructor for a signed 32 bit integer with formatting. | |
NumberString (uint64_t uInput) noexcept | |
Default constructor for an unsigned 64 bit integer. | |
NumberString (uint64_t uInput, uint_t uFormat) noexcept | |
Default constructor for an unsigned 64 bit integer with formatting. | |
NumberString (int64_t iInput) noexcept | |
Default constructor for a signed 64 bit integer. | |
NumberString (int64_t iInput, uint_t uFormat) noexcept | |
Default constructor for a signed 64 bit integer with formatting. | |
NumberString (float fInput) noexcept | |
Default constructor for a 32 bit float. | |
NumberString (double dInput) noexcept | |
Default constructor for a 64 bit float. | |
NumberString (wchar_t uInput) noexcept | |
Default constructor for a wchar_t. | |
NumberString (wchar_t uInput, uint_t uFormat) noexcept | |
Default constructor for a wchar_t. | |
NumberString (unsigned int uInput) noexcept | |
NumberString (unsigned int uInput, uint_t uFormat) noexcept | |
NumberString (unsigned long uInput) noexcept | |
NumberString (unsigned long uInput, uint_t uFormat) noexcept | |
NumberString & | operator= (uint32_t uInput) noexcept |
Copy operator for an unsigned 32 bit integer. | |
NumberString & | operator= (int32_t iInput) noexcept |
Copy operator for a signed 32 bit integer. | |
NumberString & | operator= (uint64_t uInput) noexcept |
Copy operator for an unsigned 64 bit integer. | |
NumberString & | operator= (int64_t iInput) noexcept |
Copy operator for a signed 64 bit integer. | |
NumberString & | operator= (float fInput) noexcept |
Copy operator for a 32 bit float. | |
NumberString & | operator= (double dInput) noexcept |
Copy operator for a 64 bit float. | |
operator const char * () 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 | size (void) const noexcept |
Get the length of the string in bytes. | |
uintptr_t | length (void) const noexcept |
Get the length of the string in bytes. | |
Private Attributes | |
char | m_Data [32] |
String buffer. | |
Simple "C" string numeric conversion class.
To convert a 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 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. You then access the string and use it as you wish.
Most constructors can take an optional format parameter so you can have some control as to how the string is created.
|
inlinenoexcept |
Default constructor.
Initialize to an empty string
|
noexcept |
Default constructor for an unsigned 32 bit integer.
Convert the 32 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 10 digits in length.
uInput | Unsigned 32 bit integer to convert to ASCII. |
|
noexcept |
Default constructor for an unsigned 32 bit integer with formatting.
Convert the 32 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 10 digits in length. Formatting will have some influence on the string's length.
The format parameter is passed directly to NumberToAscii(char *, uint32_t, uint_t), please see that function's documentation for what values you can pass.
uInput | Unsigned 32 bit integer to convert to ASCII. |
uFormat | Formatting parameter. |
|
noexcept |
Default constructor for a signed 32 bit integer.
Convert the 32 bit signed integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 11 digits in length.
iInput | Signed 32 bit integer to convert to ASCII. |
|
noexcept |
Default constructor for a signed 32 bit integer with formatting.
Convert the 32 bit signed integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 11 digits in length. Formatting will have some influence on the string's length.
The format parameter is passed directly to NumberToAscii(char*, int32_t, uint_t), please see that function's documentation for what values you can pass.
iInput | Signed 32 bit integer to convert to ASCII. |
uFormat | Formatting parameter. |
|
noexcept |
Default constructor for an unsigned 64 bit integer.
Convert the 64 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 20 digits in length.
uInput | Unsigned 64 bit integer to convert to ASCII. |
|
noexcept |
Default constructor for an unsigned 64 bit integer with formatting.
Convert the 64 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 20 digits in length. Formatting will have some influence on the string's length.
The format parameter is passed directly to NumberToAscii(char*,uint64_t,uint_t), please see that function's documentation for what values you can pass.
uInput | Unsigned 64 bit integer to convert to ASCII. |
uFormat | Formatting parameter. |
|
noexcept |
Default constructor for a signed 64 bit integer.
Convert the 64 bit signed integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 22 digits in length.
iInput | Signed 64 bit integer to convert to ASCII. |
|
noexcept |
Default constructor for a signed 64 bit integer with formatting.
Convert the 64 bit signed integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 22 digits in length. Formatting will have some influence on the string's length.
The format parameter is passed directly to NumberToAscii(char*,int64_t,uint_t), please see that function's documentation for what values you can pass.
iInput | Signed 64 bit integer to convert to ASCII. |
uFormat | Formatting parameter. |
|
noexcept |
Default constructor for a 32 bit float.
Convert the 32 bit float into an ASCII string and store that string inside the class. The resulting string is from 1 to 32 digits in length.
fInput | 32 bit float to convert to ASCII. |
|
noexcept |
Default constructor for a 64 bit float.
Convert the 64 bit float into an ASCII string and store that string inside the class. The resulting string is from 1 to 32 digits in length.
dInput | 64 bit float to convert to ASCII. |
|
noexcept |
Default constructor for a wchar_t.
Convert the 16/32 bit wchar_t into an ASCII string and store that string inside the class. The resulting string is from 1 to 20 digits in length. wchar_t is considered unsigned for printing.
uInput | Unsigned 64 bit integer to convert to ASCII. |
|
noexcept |
Default constructor for a wchar_t.
Convert the 16 or 32 bit wchar_t into an ASCII string and store that string inside the class. The resulting string is from 1 to 32 digits in length. wchar_t is considered unsigned for printing.
uInput | 16/32 bit wchar_t to convert to ASCII. |
uFormat | Formatting parameter. |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
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 |
|
inlinenoexcept |
Get the length of the string in bytes.
By calling StringLength(), return the length of the string contained within.
|
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.
|
noexcept |
Copy operator for a 64 bit float.
Convert the 64 bit float into an ASCII string and store that string inside the class. The resulting string is from 1 to 32 digits in length.
dInput | 64 bit float to convert to ASCII. |
|
noexcept |
Copy operator for a 32 bit float.
Convert the 32 bit float into an ASCII string and store that string inside the class. The resulting string is from 1 to 32 digits in length.
fInput | 32 bit float to convert to ASCII. |
|
noexcept |
Copy operator for a signed 32 bit integer.
Convert the 32 bit signed integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 11 digits in length.
iInput | Signed 32 bit integer to convert to ASCII. |
|
noexcept |
Copy operator for a signed 64 bit integer.
Convert the 64 bit signed integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 21 digits in length.
iInput | Signed 64 bit integer to convert to ASCII. |
|
noexcept |
Copy operator for an unsigned 32 bit integer.
Convert the 32 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 10 digits in length.
uInput | Unsigned 32 bit integer to convert to ASCII. |
|
noexcept |
Copy operator for an unsigned 64 bit integer.
Convert the 64 bit unsigned integer into an ASCII string and store that string inside the class. The resulting string is from 1 to 20 digits in length.
uInput | Unsigned 64 bit integer to convert to ASCII. |
|
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 refernce 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 the length of the string in bytes.
By calling StringLength(), return the length of the string contained within.
|
private |
String buffer.