Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::NumberString Class Reference

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
 
NumberStringoperator= (uint32_t uInput) noexcept
 Copy operator for an unsigned 32 bit integer.
 
NumberStringoperator= (int32_t iInput) noexcept
 Copy operator for a signed 32 bit integer.
 
NumberStringoperator= (uint64_t uInput) noexcept
 Copy operator for an unsigned 64 bit integer.
 
NumberStringoperator= (int64_t iInput) noexcept
 Copy operator for a signed 64 bit integer.
 
NumberStringoperator= (float fInput) noexcept
 Copy operator for a 32 bit float.
 
NumberStringoperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ NumberString() [1/17]

Burger::NumberString::NumberString ( )
inlinenoexcept

Default constructor.


Initialize to an empty string

See also
NumberString(int32_t) or NumberString(uint32_t)

◆ NumberString() [2/17]

Burger::NumberString::NumberString ( uint32_t uInput)
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.

Parameters
uInputUnsigned 32 bit integer to convert to ASCII.
See also
NumberString(int32_t) or NumberString(uint32_t,uint_t)

◆ NumberString() [3/17]

Burger::NumberString::NumberString ( uint32_t uInput,
uint_t uFormat )
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.

Parameters
uInputUnsigned 32 bit integer to convert to ASCII.
uFormatFormatting parameter.
See also
NumberString(uint32_t) or NumberString(uint32_t, uint_t) NumberToAscii(char*, uint32_t, uint_t)

◆ NumberString() [4/17]

Burger::NumberString::NumberString ( int32_t iInput)
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.

Parameters
iInputSigned 32 bit integer to convert to ASCII.
See also
NumberString(uint32_t) or NumberString(int32_t, uint_t)

◆ NumberString() [5/17]

Burger::NumberString::NumberString ( int32_t iInput,
uint_t uFormat )
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.

Parameters
iInputSigned 32 bit integer to convert to ASCII.
uFormatFormatting parameter.
See also
NumberString(int32_t) or NumberString(uint32_t, uint_t) NumberToAscii(char*, uint32_t, uint_t)

◆ NumberString() [6/17]

Burger::NumberString::NumberString ( uint64_t uInput)
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.

Parameters
uInputUnsigned 64 bit integer to convert to ASCII.
See also
NumberString(int64_t) or NumberString(uint64_t, uint_t)

◆ NumberString() [7/17]

Burger::NumberString::NumberString ( uint64_t uInput,
uint_t uFormat )
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.

Parameters
uInputUnsigned 64 bit integer to convert to ASCII.
uFormatFormatting parameter.
See also
NumberString(uint64_t) or NumberString(uint64_t, uint_t) NumberToAscii(char*, uint64_t, uint_t)

◆ NumberString() [8/17]

Burger::NumberString::NumberString ( int64_t iInput)
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.

Parameters
iInputSigned 64 bit integer to convert to ASCII.
See also
NumberString(uint64_t) or NumberString(int64_t, uint_t)

◆ NumberString() [9/17]

Burger::NumberString::NumberString ( int64_t iInput,
uint_t uFormat )
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.

Parameters
iInputSigned 64 bit integer to convert to ASCII.
uFormatFormatting parameter.
See also
NumberString(int64_t) or NumberString(uint64_t, uint_t) NumberToAscii(char*, uint64_t, uint_t)

◆ NumberString() [10/17]

Burger::NumberString::NumberString ( float fInput)
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.

Parameters
fInput32 bit float to convert to ASCII.
See also
NumberString(double) or NumberToAscii(char *, float, uint_t)

◆ NumberString() [11/17]

Burger::NumberString::NumberString ( double dInput)
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.

Parameters
dInput64 bit float to convert to ASCII.
See also
NumberString(float) or NumberToAscii(char *, double, uint_t)

◆ NumberString() [12/17]

Burger::NumberString::NumberString ( wchar_t uInput)
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.

Parameters
uInputUnsigned 64 bit integer to convert to ASCII.
See also
NumberString(int64_t) or NumberString(uint64_t, uint_t)

◆ NumberString() [13/17]

Burger::NumberString::NumberString ( wchar_t uInput,
uint_t uFormat )
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.

Parameters
uInput16/32 bit wchar_t to convert to ASCII.
uFormatFormatting parameter.
See also
NumberString(uint32_t) or NumberToAscii(char *, uint32_t, uint_t)

◆ NumberString() [14/17]

Burger::NumberString::NumberString ( unsigned int uInput)
noexcept

◆ NumberString() [15/17]

Burger::NumberString::NumberString ( unsigned int uInput,
uint_t uFormat )
noexcept

◆ NumberString() [16/17]

Burger::NumberString::NumberString ( unsigned long uInput)
noexcept

◆ NumberString() [17/17]

Burger::NumberString::NumberString ( unsigned long uInput,
uint_t uFormat )
noexcept

Member Function Documentation

◆ c_str()

const char * Burger::NumberString::c_str ( void ) const
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.

Returns
const char * to the string within. The string is always valid.
See also
NumberString::operator const char *() const

◆ clear()

void Burger::NumberString::clear ( void )
inlinenoexcept

Erase the string.


Set the string to a blank string, I.E. "".

See also
empty() const

◆ empty()

uint_t Burger::NumberString::empty ( void ) const
inlinenoexcept

Return TRUE if the string is blank.


If the string inside is blank, return TRUE, otherwise return FALSE.

Returns
TRUE if the string is blank, FALSE if not.
See also
length() const or clear()

◆ length()

uintptr_t Burger::NumberString::length ( void ) const
inlinenoexcept

Get the length of the string in bytes.


By calling StringLength(), return the length of the string contained within.

Note
This function performs no caching. If the length of the string is not expected to change in a performance critical loop, cache the returned value and use it in the loop instead of calling this function repeatedly.
Returns
Length of the string in bytes. The terminating zero doesn't count.
See also
empty() const or size() const

◆ operator const char *()

Burger::NumberString::operator const char * ( ) const
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.

Returns
const char * to the string within. The string is always valid.
See also
c_str(void) const

◆ operator=() [1/6]

Burger::NumberString & Burger::NumberString::operator= ( double dInput)
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.

Parameters
dInput64 bit float to convert to ASCII.
See also
NumberString(double) or NumberToAscii(char *, double, uint_t)

◆ operator=() [2/6]

Burger::NumberString & Burger::NumberString::operator= ( float fInput)
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.

Parameters
fInput32 bit float to convert to ASCII.
See also
NumberString(float) or NumberToAscii(char *, float, uint_t)

◆ operator=() [3/6]

Burger::NumberString & Burger::NumberString::operator= ( int32_t iInput)
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.

Parameters
iInputSigned 32 bit integer to convert to ASCII.
See also
NumberString(int32_t) or NumberString(int32_t, uint_t)

◆ operator=() [4/6]

Burger::NumberString & Burger::NumberString::operator= ( int64_t iInput)
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.

Parameters
iInputSigned 64 bit integer to convert to ASCII.
See also
NumberString(int64_t) or NumberString(int64_t, uint_t)

◆ operator=() [5/6]

Burger::NumberString & Burger::NumberString::operator= ( uint32_t uInput)
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.

Parameters
uInputUnsigned 32 bit integer to convert to ASCII.
See also
NumberString(uint32_t) or NumberString(uint32_t, uint_t)

◆ operator=() [6/6]

Burger::NumberString & Burger::NumberString::operator= ( uint64_t uInput)
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.

Parameters
uInputUnsigned 64 bit integer to convert to ASCII.
See also
NumberString(uint64_t) or NumberString(uint64_t, uint_t)

◆ operator[]() [1/2]

char Burger::NumberString::operator[] ( uintptr_t uIndex) const
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.

Returns
One character from the string.
See also
NumberString::operator [](uintptr_t)

◆ operator[]() [2/2]

const char & Burger::NumberString::operator[] ( uintptr_t uIndex)
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.

Returns
A const character reference from the string.
See also
NumberString::operator [](uintptr_t) const

◆ size()

uintptr_t Burger::NumberString::size ( void ) const
inlinenoexcept

Get the length of the string in bytes.


By calling StringLength(), return the length of the string contained within.

Note
This function performs no caching. If the length of the string is not expected to change in a performance critical loop, cache the returned value and use it in the loop instead of calling this function repeatedly.
Returns
Length of the string in bytes. The terminating zero doesn't count.
See also
empty() const or length() const

Member Data Documentation

◆ m_Data

char Burger::NumberString::m_Data[32]
private

String buffer.