#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 } |
The list of possible data types of this Formattable object. More... | |
Public Methods | |
Formattable () | |
Default constructor. More... | |
Formattable (UDate d, ISDATE flag) | |
Creates a Formattable object with a UDate instance. More... | |
Formattable (double d) | |
Creates a Formattable object with a double number. More... | |
Formattable (int32_t l) | |
Creates a Formattable object with a long number. More... | |
Formattable (int64_t ll) | |
Creates a Formattable object with an int64_t number. More... | |
Formattable (const char *strToCopy) | |
Creates a Formattable object with a char string pointer. More... | |
Formattable (const UnicodeString &strToCopy) | |
Creates a Formattable object with a UnicodeString object to copy from. More... | |
Formattable (UnicodeString *strToAdopt) | |
Creates a Formattable object with a UnicodeString object to adopt from. More... | |
Formattable (const Formattable *arrayToCopy, int32_t count) | |
Creates a Formattable object with an array of Formattable objects. More... | |
Formattable (const Formattable &) | |
Copy constructor. More... | |
Formattable & | operator= (const Formattable &rhs) |
Assignment operator. More... | |
UBool | operator== (const Formattable &other) const |
Equality comparison. More... | |
UBool | operator!= (const Formattable &other) const |
Equality operator. More... | |
virtual | ~Formattable () |
Destructor. More... | |
Formattable * | clone () const |
Clone this object. More... | |
Type | getType (void) const |
Gets the data type of this Formattable object. More... | |
double | getDouble (void) const |
Gets the double value of this object. More... | |
double | getDouble (UErrorCode *status) const |
Gets the double value of this object. More... | |
int32_t | getLong (void) const |
Gets the long value of this object. More... | |
int32_t | getLong (UErrorCode *status) const |
Gets the long value of this object. More... | |
int64_t | getInt64 (void) const |
Gets the int64 value of this object. More... | |
int64_t | getInt64 (UErrorCode *status) const |
Gets the int64 value of this object. More... | |
UDate | getDate () const |
Gets the Date value of this object. More... | |
UDate | getDate (UErrorCode *status) const |
Gets the Date value of this object. More... | |
UnicodeString & | getString (UnicodeString &result) const |
Gets the string value of this object. More... | |
UnicodeString & | getString (UnicodeString &result, UErrorCode *status) const |
Gets the string value of this object. More... | |
const UnicodeString & | getString (void) const |
Gets a const reference to the string value of this object. More... | |
const UnicodeString & | getString (UErrorCode *status) const |
Gets a const reference to the string value of this object. More... | |
UnicodeString & | getString (void) |
Gets a reference to the string value of this object. More... | |
UnicodeString & | getString (UErrorCode *status) |
Gets a reference to the string value of this object. More... | |
const Formattable * | getArray (int32_t &count) const |
Gets the array value and count of this object. More... | |
const Formattable * | getArray (int32_t &count, UErrorCode *status) const |
Gets the array value and count of this object. More... | |
Formattable & | operator[] (int32_t index) |
Accesses the specified element in the array value of this Formattable object. More... | |
void | setDouble (double d) |
Sets the double value of this object. More... | |
void | setLong (int32_t l) |
Sets the long value of this object. More... | |
void | setInt64 (int64_t ll) |
Sets the int64 value of this object. More... | |
void | setDate (UDate d) |
Sets the Date value of this object. More... | |
void | setString (const UnicodeString &stringToCopy) |
Sets the string value of this object. More... | |
void | setArray (const Formattable *array, int32_t count) |
Sets the array value and count of this object. More... | |
void | adoptString (UnicodeString *stringToAdopt) |
Sets and adopts the string value and count of this object. More... | |
void | adoptArray (Formattable *array, int32_t count) |
Sets and adopts the array value and count of this object. More... | |
virtual UClassID | getDynamicClassID () const |
ICU "poor man's RTTI", returns a UClassID for the actual class. More... | |
Static Public Methods | |
UClassID | getStaticClassID () |
ICU "poor man's RTTI", returns a UClassID for this class. More... | |
Private Methods | |
void | dispose (void) |
Cleans up the memory for unwanted values. More... | |
Static Private Methods | |
Formattable * | createArrayCopy (const Formattable *array, int32_t count) |
Creates a new Formattable array and copies the values from the specified original. More... | |
UnicodeString * | getBogus () |
Private Attributes | |
Formattable:: { ... } | fValue |
Type | fType |
UnicodeString * | fString |
double | fDouble |
int64_t | fInt64 |
UDate | fDate |
Formattable * | fArray |
int32_t | fCount |
Formattable:: { ... } ::@11 | fArrayAndCount |
Static Private Attributes | |
UnicodeString * | gBogus |
Formattable is a thin wrapper class which interconverts between the primitive numeric types (double, long, etc.) as well as UDate and UnicodeString.
Note that this is fundamentally different from the Java behavior, since in this case the various formattable objects do not occupy a hierarchy, but are all wrapped within this one class. Formattable encapsulates all the polymorphism in itself.
It would be easy to change this so that Formattable was an abstract base class of a genuine hierarchy, and that would clean up the code that currently must explicitly check for type, but that seems like overkill at this point.
The Formattable class is not suitable for subclassing.
Definition at line 44 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.
|
|
|
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.
|
|
Copy constructor.
|
|
Destructor.
|
|
Sets and adopts the array value and count of this object.
|
|
Sets and adopts the string value and count of this object.
|
|
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.
|
|
Creates a new Formattable array and copies the values from the specified original.
|
|
Cleans up the memory for unwanted values. For example, the adopted string or array objects. |
|
Gets the array value and count of this object.
|
|
Gets the array value and count of this object.
|
|
|
|
Gets the Date value of this object.
|
|
Gets the Date value of this object.
|
|
Gets the double value of this object. This converts from long or int64 values as required (conversion from int64 can lose precision). If the type is not a numeric type, 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.
|
|
Gets the double value of this object.
|
|
ICU "poor man's RTTI", returns a UClassID for the actual class.
Reimplemented from UObject. |
|
Gets the int64 value of this object. This converts from double or int64 values as required. If the value value won't fit in an int64, the maximum or minimum in64 value, as appropriate, is returned and the status is set to U_INVALID_FORMAT_ERROR. If the type is not a numeric type, 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.
|
|
Gets the int64 value of this object.
|
|
Gets the long value of this object. This converts from double or int64 values as required. If the magnitude is too large to fit in a long, the maximum or minimum long value, as appropriate, is returned and the status is set to U_INVALID_FORMAT_ERROR. If the type is not a numeric type, 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.
|
|
Gets the long value of this object.
|
|
ICU "poor man's RTTI", returns a UClassID for this class.
|
|
Gets a reference to the string value of this object.
|
|
Gets a reference to the string value of this object.
|
|
Gets a const reference to the string value of this object.
|
|
Gets a const reference to the string value of this object.
|
|
Gets the string value of this object.
|
|
Gets the string value of this object.
|
|
Gets the data type of this Formattable object.
|
|
Equality operator.
|
|
Assignment operator.
|
|
Equality comparison.
|
|
Accesses the specified element in the array value of this Formattable object.
|
|
Sets the array value and count of this object.
|
|
Sets the Date value of this object.
|
|
Sets the double value of this object.
|
|
Sets the int64 value of this object.
|
|
Sets the long value of this object.
|
|
Sets the string value of this object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|