#include <fmtable.h>
Inheritance diagram for Formattable:
Public Types | |
enum | ISDATE { kIsDate } |
This enum is only used to let callers distinguish between the Formattable(UDate) constructor and the Formattable(double) constructor; the compiler cannot distinguish the signatures, since UDate is currently typedefed to be either double or long. More... | |
enum | Type { kDate, kDouble, kLong, kString, kArray, kInt64, kObject } |
Selector for flavor of data type contained within a Formattable object. More... | |
Public Member Functions | |
Formattable () | |
Default constructor. | |
Formattable (UDate d, ISDATE flag) | |
Creates a Formattable object with a UDate instance. | |
Formattable (double d) | |
Creates a Formattable object with a double number. | |
Formattable (int32_t l) | |
Creates a Formattable object with a long number. | |
Formattable (int64_t ll) | |
Creates a Formattable object with an int64_t number. | |
Formattable (const char *strToCopy) | |
Creates a Formattable object with a char string pointer. | |
Formattable (const UnicodeString &strToCopy) | |
Creates a Formattable object with a UnicodeString object to copy from. | |
Formattable (UnicodeString *strToAdopt) | |
Creates a Formattable object with a UnicodeString object to adopt from. | |
Formattable (const Formattable *arrayToCopy, int32_t count) | |
Creates a Formattable object with an array of Formattable objects. | |
Formattable (UObject *objectToAdopt) | |
Creates a Formattable object that adopts the given UObject. | |
Formattable (const Formattable &) | |
Copy constructor. | |
Formattable & | operator= (const Formattable &rhs) |
Assignment operator. | |
UBool | operator== (const Formattable &other) const |
Equality comparison. | |
UBool | operator!= (const Formattable &other) const |
Equality operator. | |
virtual | ~Formattable () |
Destructor. | |
Formattable * | clone () const |
Clone this object. | |
Type | getType (void) const |
Gets the data type of this Formattable object. | |
UBool | isNumeric () const |
Returns TRUE if the data type of this Formattable object is kDouble, kLong, or kInt64. | |
double | getDouble (void) const |
Gets the double value of this object. | |
double | getDouble (UErrorCode &status) const |
Gets the double value of this object. | |
int32_t | getLong (void) const |
Gets the long value of this object. | |
int32_t | getLong (UErrorCode &status) const |
Gets the long value of this object. | |
int64_t | getInt64 (void) const |
Gets the int64 value of this object. | |
int64_t | getInt64 (UErrorCode &status) const |
Gets the int64 value of this object. | |
UDate | getDate () const |
Gets the Date value of this object. | |
UDate | getDate (UErrorCode &status) const |
Gets the Date value of this object. | |
UnicodeString & | getString (UnicodeString &result) const |
Gets the string value of this object. | |
UnicodeString & | getString (UnicodeString &result, UErrorCode &status) const |
Gets the string value of this object. | |
const UnicodeString & | getString (void) const |
Gets a const reference to the string value of this object. | |
const UnicodeString & | getString (UErrorCode &status) const |
Gets a const reference to the string value of this object. | |
UnicodeString & | getString (void) |
Gets a reference to the string value of this object. | |
UnicodeString & | getString (UErrorCode &status) |
Gets a reference to the string value of this object. | |
const Formattable * | getArray (int32_t &count) const |
Gets the array value and count of this object. | |
const Formattable * | getArray (int32_t &count, UErrorCode &status) const |
Gets the array value and count of this object. | |
Formattable & | operator[] (int32_t index) |
Accesses the specified element in the array value of this Formattable object. | |
const UObject * | getObject () const |
Returns a pointer to the UObject contained within this formattable, or NULL if this object does not contain a UObject. | |
void | setDouble (double d) |
Sets the double value of this object and changes the type to kDouble. | |
void | setLong (int32_t l) |
Sets the long value of this object and changes the type to kLong. | |
void | setInt64 (int64_t ll) |
Sets the int64 value of this object and changes the type to kInt64. | |
void | setDate (UDate d) |
Sets the Date value of this object and changes the type to kDate. | |
void | setString (const UnicodeString &stringToCopy) |
Sets the string value of this object and changes the type to kString. | |
void | setArray (const Formattable *array, int32_t count) |
Sets the array value and count of this object and changes the type to kArray. | |
void | adoptString (UnicodeString *stringToAdopt) |
Sets and adopts the string value and count of this object and changes the type to kArray. | |
void | adoptArray (Formattable *array, int32_t count) |
Sets and adopts the array value and count of this object and changes the type to kArray. | |
void | adoptObject (UObject *objectToAdopt) |
Sets and adopts the UObject value of this object and changes the type to kObject. | |
virtual UClassID | getDynamicClassID () const |
ICU "poor man's RTTI", returns a UClassID for the actual class. | |
int32_t | getLong (UErrorCode *status) const |
Deprecated variant of getLong(UErrorCode&). | |
Static Public Member Functions | |
UClassID | getStaticClassID () |
ICU "poor man's RTTI", returns a UClassID for this class. |
Formattable is a thin wrapper class which interconverts between the primitive numeric types (double, long, etc.) as well as UDate and UnicodeString.
Internally, a Formattable object is a union of primitive types. As such, it can only store one flavor of data at a time. To determine what flavor of data it contains, use the getType method.
As of ICU 3.0, Formattable may also wrap a UObject pointer, which it owns. This allows an instance of any ICU class to be encapsulated in a Formattable. For legacy reasons and for efficiency, primitive numeric types are still stored directly within a Formattable.
The Formattable class is not suitable for subclassing.
Definition at line 47 of file fmtable.h.
|
This enum is only used to let callers distinguish between the Formattable(UDate) constructor and the Formattable(double) constructor; the compiler cannot distinguish the signatures, since UDate is currently typedefed to be either double or long. If UDate is changed later to be a bonafide class or struct, then we no longer need this enum.
|
|
Selector for flavor of data type contained within a Formattable object. Formattable is a union of several different types, and at any time contains exactly one type.
|
|
Default constructor.
|
|
Creates a Formattable object with a UDate instance.
|
|
Creates a Formattable object with a double number.
|
|
Creates a Formattable object with a long number.
|
|
Creates a Formattable object with an int64_t number.
|
|
Creates a Formattable object with a char string pointer. Assumes that the char string is null terminated.
|
|
Creates a Formattable object with a UnicodeString object to copy from.
|
|
Creates a Formattable object with a UnicodeString object to adopt from.
|
|
Creates a Formattable object with an array of Formattable objects.
|
|
Creates a Formattable object that adopts the given UObject.
|
|
Copy constructor.
|
|
Destructor.
|
|
Sets and adopts the array value and count of this object and changes the type to kArray.
|
|
Sets and adopts the UObject value of this object and changes the type to kObject. After this call, the caller must not delete the given object.
|
|
Sets and adopts the string value and count of this object and changes the type to kArray.
|
|
Clone this object. Clones can be used concurrently in multiple threads. If an error occurs, then NULL is returned. The caller must delete the clone.
|
|
Gets the array value and count of this object. If the type is not an array, status is set to U_INVALID_FORMAT_ERROR, count is set to 0, and the result is NULL.
|
|
Gets the array value and count of this object. If this object is not of type kArray then the result is undefined.
|
|
Gets the Date value of this object. If the type is not a date, status is set to U_INVALID_FORMAT_ERROR and the return value is undefined.
|
|
Gets the Date value of this object. If this object is not of type kDate then the result is undefined.
|
|
Gets the double value of this object. If this object is of type long or int64 then a casting conversion is peformed, with possible loss of precision. If the type is kObject and the object is a Measure, then the result of getNumber().getDouble(status) is returned. If this object is neither a numeric type nor a Measure, then 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.
|
|
Gets the double value of this object. If this object is not of type kDouble then the result is undefined.
|
|
ICU "poor man's RTTI", returns a UClassID for the actual class.
Implements UObject. |
|
Gets the int64 value of this object. If this object is of type kDouble and the magnitude is too large to fit in an int64, then the maximum or minimum int64 value, as appropriate, is returned and the status is set to U_INVALID_FORMAT_ERROR. If the magnitude fits in an int64, then a casting conversion is peformed, with truncation of any fractional part. If the type is kObject and the object is a Measure, then the result of getNumber().getDouble(status) is returned. If this object is neither a numeric type nor a Measure, then 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.
|
|
Gets the int64 value of this object. If this object is not of type kInt64 then the result is undefined.
|
|
Deprecated variant of getLong(UErrorCode&).
|
|
Gets the long value of this object. If the magnitude is too large to fit in a long, then the maximum or minimum long value, as appropriate, is returned and the status is set to U_INVALID_FORMAT_ERROR. If this object is of type kInt64 and it fits within a long, then no precision is lost. If it is of type kDouble, then a casting conversion is peformed, with truncation of any fractional part. If the type is kObject and the object is a Measure, then the result of getNumber().getLong(status) is returned. If this object is neither a numeric type nor a Measure, then 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.
|
|
Gets the long value of this object. If this object is not of type kLong then the result is undefined.
|
|
Returns a pointer to the UObject contained within this formattable, or NULL if this object does not contain a UObject.
|
|
ICU "poor man's RTTI", returns a UClassID for this class.
|
|
Gets a reference to the string value of this object. If the type is not a string, status is set to U_INVALID_FORMAT_ERROR and the result is a bogus string.
|
|
Gets a reference to the string value of this object. If this object is not of type kString then the result is undefined.
|
|
Gets a const reference to the string value of this object. If the type is not a string, status is set to U_INVALID_FORMAT_ERROR and the result is a bogus string.
|
|
Gets a const reference to the string value of this object. If this object is not of type kString then the result is undefined.
|
|
Gets the string value of this object. If the type is not a string, status is set to U_INVALID_FORMAT_ERROR and a bogus string is returned.
|
|
Gets the string value of this object. If this object is not of type kString then the result is undefined.
|
|
Gets the data type of this Formattable object.
|
|
Returns TRUE if the data type of this Formattable object is kDouble, kLong, or kInt64.
|
|
Equality operator.
|
|
Assignment operator.
|
|
Equality comparison.
|
|
Accesses the specified element in the array value of this Formattable object. If this object is not of type kArray then the result is undefined.
|
|
Sets the array value and count of this object and changes the type to kArray.
|
|
Sets the Date value of this object and changes the type to kDate.
|
|
Sets the double value of this object and changes the type to kDouble.
|
|
Sets the int64 value of this object and changes the type to kInt64.
|
|
Sets the long value of this object and changes the type to kLong.
|
|
Sets the string value of this object and changes the type to kString.
|