|
BurgerLib
|
Simple "C" string numeric conversion class. More...
#include <brnumberstring.h>
Public Member Functions | |
| NumberString (Word32 uInput) | |
| Default constructor for an unsigned 32 bit integer. | |
| NumberString (Word32 uInput, Word uFormat) | |
| Default constructor for an unsigned 32 bit integer with formatting. | |
| NumberString (Int32 iInput) | |
| Default constructor for a signed 32 bit integer. | |
| NumberString (Int32 iInput, Word uFormat) | |
| Default constructor for a signed 32 bit integer with formatting. | |
| NumberString (float fInput) | |
| Default constructor for a 32 bit float. | |
| NumberString (double dInput) | |
| Default constructor for a 64 bit float. | |
| Burger::NumberString & | operator= (Word32 uInput) |
| Copy operator for an unsigned 32 bit integer. | |
| Burger::NumberString & | operator= (Int32 iInput) |
| Copy operator for a signed 32 bit integer. | |
| Burger::NumberString & | operator= (float fInput) |
| Copy operator for a 32 bit float. | |
| Burger::NumberString & | operator= (double dInput) |
| Copy operator for a 64 bit float. | |
| BURGER_INLINE | operator const char * () const |
| Get a pointer to the string. | |
| BURGER_INLINE const char * | GetPtr (void) const |
| Get a pointer to the string. | |
| BURGER_INLINE char | operator[] (WordPtr uIndex) const |
| Get a character from the string. | |
| BURGER_INLINE const char & | operator[] (WordPtr uIndex) |
| Get a character reference from the string. | |
| BURGER_INLINE void | Clear (void) |
| Erase the string. | |
| BURGER_INLINE Word | IsEmpty (void) const |
| Return TRUE if the string is blank. | |
| BURGER_INLINE WordPtr | GetLength (void) const |
| 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 Burger::NumberString::GetPtr() 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.
| Burger::NumberString::NumberString | ( | Word32 | uInput | ) |
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. |
| Burger::NumberString::NumberString | ( | Word32 | uInput, |
| Word | uFormat | ||
| ) |
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 Burger::NumberToAscii(char *,Word32,Word), please see that function's documentation for what values you can pass.
| uInput | Unsigned 32 bit integer to convert to ASCII. |
| uFormat | Formatting parameter. |
| Burger::NumberString::NumberString | ( | Int32 | iInput | ) |
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. |
| Burger::NumberString::NumberString | ( | Int32 | iInput, |
| Word | uFormat | ||
| ) |
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 Burger::NumberToAscii(char *,Int32,Word), please see that function's documentation for what values you can pass.
| iInput | Signed 32 bit integer to convert to ASCII. |
| uFormat | Formatting parameter. |
| Burger::NumberString::NumberString | ( | float | fInput | ) |
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. |
| Burger::NumberString::NumberString | ( | double | dInput | ) |
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. |
| Burger::NumberString::Clear | ( | void | ) | [inline] |
Erase the string.
Set the string to a blank string, I.E. "".
| Burger::NumberString::GetLength | ( | void | ) | const [inline] |
Get the length of the string in bytes.
By calling Burger::StringLength(), return the length of the string contained within.
| Burger::NumberString::GetPtr | ( | void | ) | const [inline] |
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.
| Burger::NumberString::IsEmpty | ( | void | ) | const [inline] |
| Burger::NumberString::operator const char * | ( | ) | const [inline] |
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.
| Burger::NumberString & Burger::NumberString::operator= | ( | Word32 | uInput | ) |
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. |
| Burger::NumberString & Burger::NumberString::operator= | ( | Int32 | iInput | ) |
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. |
| Burger::NumberString & Burger::NumberString::operator= | ( | float | fInput | ) |
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. |
| Burger::NumberString & Burger::NumberString::operator= | ( | double | dInput | ) |
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. |
| Burger::NumberString::operator[] | ( | WordPtr | uIndex | ) | const [inline] |
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.
| Burger::NumberString::operator[] | ( | WordPtr | uIndex | ) | [inline] |
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.
char Burger::NumberString::m_Data[32] [private] |
String buffer.
1.8.0