|
ai::NumberFormat Class Reference
Class used for locale-dependent number formatting.
More...
#include <IAIStringFormatUtils.h>
List of all members.
Public Member Functions |
| NumberFormat (void) AINOTHROW |
| Empty object constructor.
|
| NumberFormat (const ai::LocaleID locale) |
| Creates an instance for a given locale.
|
| NumberFormat (const NumberFormat &format) |
| Copy constructor.
|
| ~NumberFormat () |
| Default destructor.
|
ai::UnicodeString & | toString (const float value, const ai::int32 precision, ai::UnicodeString &str, bool padToPrecision=false) |
| Formats a numeric value to a string, using the locale with which this instance was created.
|
ai::UnicodeString & | toString (const ai::int32 value, ai::UnicodeString &str) |
| Formats a numeric value to a string, using the locale with which this instance was created.
|
ai::UnicodeString & | toString (const double value, const ai::int32 precision, ai::UnicodeString &str, bool padToPrecision=false) |
| Formats a numeric value to a string, using the locale with which this instance was created.
|
bool | parseString (const ai::UnicodeString &str, float &value) |
| Converts a string to a numeric floating-point value, if the string contains a number formatted according to the locale with which this instance was created.
|
bool | parseString (const ai::UnicodeString &str, ai::int32 &value) |
| Converts a string to a numeric integer value, if the string contains a number formatted according to the locale with which this instance was created.
|
bool | parseString (const ai::UnicodeString &str, double &value) |
| Converts a string to a numeric floating-point value, if the string contains a number formatted according to the locale with which this instance was created.
|
ai::NumberFormat & | operator= (const NumberFormat &rhs) |
| Equality operator.
|
ai::UnicodeString | getDecimalSeparator () |
| Retrieves the decimal separator symbol used for the locale with which this instance was created.
|
ai::UnicodeString | getThousandsSeparator () |
| Retrieves the thousands separator symbol used for the locale with which this instance was created.
|
void | deleteImpl () |
| Internal.
|
NumberFormat & | assign (const NumberFormat &format) |
| Internal.
|
Static Public Member Functions |
static NumberFormat | getFormat (const ai::LocaleID locale=ai::Locale::kDefault) |
| Creates or retrieves a NumberFormat instance for a given locale.
|
Detailed Description
Class used for locale-dependent number formatting.
Based on the input locale, this class internally handles the conversion between numbers and strings using the appropriate decimal and thousands separator characters.
Constructor & Destructor Documentation
ai::NumberFormat::NumberFormat |
( |
void |
|
) |
[explicit] |
Empty object constructor.
Creates a valid, empty NumberFormat instance that represents the default system setting for number formatting. This method is guaranteed to not throw any exceptions.
- Returns:
- The new instance.
ai::NumberFormat::NumberFormat |
( |
const ai::LocaleID |
locale |
) |
[explicit] |
Creates an instance for a given locale.
- Parameters:
-
| locale | The locale to be used for formatting. Use kDefault for the current system locale setting. |
- Returns:
- The new instance.
ai::NumberFormat::NumberFormat |
( |
const NumberFormat & |
format |
) |
|
Copy constructor.
- Returns:
- The new instance.
ai::NumberFormat::~NumberFormat |
( |
|
) |
|
Member Function Documentation
void ai::NumberFormat::deleteImpl |
( |
|
) |
|
Retrieves the decimal separator symbol used for the locale with which this instance was created.
- Returns:
- The decimal separator character
Creates or retrieves a NumberFormat instance for a given locale.
- Parameters:
-
| locale | The locale. Use kDefault for the current system locale setting. |
- Returns:
- The new instance for the locale, or the static instance that the application maintains for the current system locale setting.
- Note:
- If you require a new instance for the system locale setting, use the constructor instead.
Retrieves the thousands separator symbol used for the locale with which this instance was created.
- Returns:
- The thousands separator character
Converts a string to a numeric floating-point value, if the string contains a number formatted according to the locale with which this instance was created.
- Parameters:
-
| str | The string. |
| value | [out] A buffer in which to return the numeric value. |
- Returns:
- True if the string could be parsed to a valid numeric value, false otherwise.
Converts a string to a numeric integer value, if the string contains a number formatted according to the locale with which this instance was created.
- Parameters:
-
| str | The string. |
| value | [out] A buffer in which to return the numeric value. |
- Returns:
- True if the string could be parsed to a valid numeric value, false otherwise.
Converts a string to a numeric floating-point value, if the string contains a number formatted according to the locale with which this instance was created.
- Parameters:
-
| str | The string. |
| value | [out] A buffer in which to return the numeric value. |
- Returns:
- True if the string could be parsed to a valid numeric value, false otherwise.
Formats a numeric value to a string, using the locale with which this instance was created.
- Parameters:
-
| value | The numeric value. |
| precision | The maximum number of digits allowed after the decimal point. If the input value has greater precision, the value is rounded down. |
| str | [out] A buffer in which to return the formatted string. |
| padToPrecision | When true, if the precision of the input value is less than the maximum, pads the result string with zeros after the decimal place. When false, does not pad the string. |
- Returns:
- The result string (the same string returned in
str ).
Formats a numeric value to a string, using the locale with which this instance was created.
- Parameters:
-
| value | The numeric value. |
| str | [out] A buffer in which to return the formatted string. |
- Returns:
- The result string (the same string returned in
str ).
Formats a numeric value to a string, using the locale with which this instance was created.
- Parameters:
-
| value | The numeric value. |
| precision | The maximum number of digits allowed after the decimal point. If the input value has greater precision, the value is rounded down. |
| str | [out] A buffer in which to return the formatted string. |
| padToPrecision | When true, if the precision of the input value is less than the maximum, pads the result string with zeros after the decimal place. When false, does not pad the string. |
- Returns:
- The result string (the same string returned in
str ).
The documentation for this class was generated from the following file:
|