class U_I18N_API Formattable

Formattable objects can be passed to the Format class or its subclasses for formatting

Public Classes

enum ISDATE
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
enum Type
The list of possible data types of this Formattable object

Public Methods

Formattable(UDate d, ISDATE)
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(const char* strToCopy)
Creates a Formattable object with a char string pointer
Formattable(const UnicodeString& stringToCopy)
Creates a Formattable object with a UnicodeString object to copy from
Formattable(UnicodeString* stringToAdopt)
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(const Formattable&)
Copy constructor
Formattable& operator=(const Formattable&)
Assignment operator
bool_t operator==(const Formattable&) const
Equality comparison
virtual ~Formattable()
Destructor
Type getType(void) const
Gets the data type of this Formattable object
double getDouble(void) const
Gets the double value of this object
int32_t getLong(void) const
Gets the long value of this object
UDate getDate(void) const
Gets the Date value of this object
UnicodeString& getString(UnicodeString& result) const
Gets the string value of this object
const Formattable* getArray(int32_t& count) 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
void setDouble(double d)
Sets the double value of this object
void setLong(int32_t l)
Sets the long value of this object
void setDate(UDate d)
Sets the Date value of this object
void setString(const UnicodeString& stringToCopy)
Sets the string value of this object
void setArray(const Formattable* array, int32_t count)
Sets the array value and count of this object
void adoptString(UnicodeString* stringToAdopt)
Sets and adopts the string value and count of this object
void adoptArray(Formattable* array, int32_t count)
Sets and adopts the array value and count of this object

Documentation

Formattable objects can be passed to the Format class or its subclasses for formatting. 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.

enum ISDATE
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.

Formattable(UDate d, ISDATE)
Creates a Formattable object with a UDate instance
Parameters:
d - the UDate instance.
ISDATE - the flag to indicate this is a date.

Formattable(double d)
Creates a Formattable object with a double number
Parameters:
d - the double number.

Formattable(int32_t l)
Creates a Formattable object with a long number
Parameters:
d - the long number.

Formattable(const char* strToCopy)
Creates a Formattable object with a char string pointer. Assumes that the char string is null terminated.
Parameters:
strToCopy - the char string.

Formattable(const UnicodeString& stringToCopy)
Creates a Formattable object with a UnicodeString object to copy from
Parameters:
strToCopy - the UnicodeString string.

Formattable(UnicodeString* stringToAdopt)
Creates a Formattable object with a UnicodeString object to adopt from
Parameters:
strToAdopt - the UnicodeString string.

Formattable(const Formattable* arrayToCopy, int32_t count)
Creates a Formattable object with an array of Formattable objects
Parameters:
arrayToCopy - the Formattable object array.
count - the array count.

Formattable(const Formattable&)
Copy constructor

Formattable& operator=(const Formattable&)
Assignment operator

bool_t operator==(const Formattable&) const
Equality comparison

virtual ~Formattable()
Destructor

enum Type
The list of possible data types of this Formattable object

Type getType(void) const
Gets the data type of this Formattable object

double getDouble(void) const
Gets the double value of this object

int32_t getLong(void) const
Gets the long value of this object

UDate getDate(void) const
Gets the Date value of this object

UnicodeString& getString(UnicodeString& result) const
Gets the string value of this object

const Formattable* getArray(int32_t& count) 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
Returns:
the accessed element in the array.
Parameters:
index - the specified index.

void setDouble(double d)
Sets the double value of this object

void setLong(int32_t l)
Sets the long value of this object

void setDate(UDate d)
Sets the Date value of this object

void setString(const UnicodeString& stringToCopy)
Sets the string value of this object

void setArray(const Formattable* array, int32_t count)
Sets the array value and count of this object

void adoptString(UnicodeString* stringToAdopt)
Sets and adopts the string value and count of this object

void adoptArray(Formattable* array, int32_t count)
Sets and adopts the array value and count of this object


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de