Logo Search packages:      
Sourcecode: icu version File versions  Download package

Formattable Class Reference

#include <fmtable.h>

Inheritance diagram for Formattable:

UObject UMemory

List of all members.

Detailed Description

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.

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 52 of file fmtable.h.

Public Types

enum  ISDATE { kIsDate }
enum  Type {
  kDate, kDouble, kLong, kString,
  kArray, kInt64, kObject

Public Member Functions

void adoptArray (Formattable *array, int32_t count)
void adoptDigitList (DigitList *dl)
void adoptObject (UObject *objectToAdopt)
void adoptString (UnicodeString *stringToAdopt)
Formattableclone () const
 Formattable (const Formattable &)
 Formattable (UObject *objectToAdopt)
 Formattable (const Formattable *arrayToCopy, int32_t count)
 Formattable (UnicodeString *strToAdopt)
 Formattable (const UnicodeString &strToCopy)
 Formattable (const StringPiece &number, UErrorCode &status)
 Formattable (const char *strToCopy)
 Formattable (int64_t ll)
 Formattable (int32_t l)
 Formattable (double d)
 Formattable (UDate d, ISDATE flag)
 Formattable ()
const FormattablegetArray (int32_t &count, UErrorCode &status) const
const FormattablegetArray (int32_t &count) const
UDate getDate (UErrorCode &status) const
UDate getDate () const
StringPiece getDecimalNumber (UErrorCode &status)
DigitListgetDigitList () const
double getDouble (UErrorCode &status) const
double getDouble (void) const
virtual UClassID getDynamicClassID () const
int64_t getInt64 (UErrorCode &status) const
int64_t getInt64 (void) const
int32_t getLong (UErrorCode *status) const
int32_t getLong (UErrorCode &status) const
int32_t getLong (void) const
const UObjectgetObject () const
UnicodeStringgetString (UErrorCode &status)
UnicodeStringgetString (void)
const UnicodeStringgetString (UErrorCode &status) const
const UnicodeStringgetString (void) const
UnicodeStringgetString (UnicodeString &result, UErrorCode &status) const
UnicodeStringgetString (UnicodeString &result) const
Type getType (void) const
UBool isNumeric () const
UBool operator!= (const Formattable &other) const
Formattableoperator= (const Formattable &rhs)
UBool operator== (const Formattable &other) const
Formattableoperator[] (int32_t index)
void setArray (const Formattable *array, int32_t count)
void setDate (UDate d)
void setDecimalNumber (const StringPiece &numberString, UErrorCode &status)
void setDouble (double d)
void setInt64 (int64_t ll)
void setLong (int32_t l)
void setString (const UnicodeString &stringToCopy)
virtual ~Formattable ()

Static Public Member Functions

static UClassID U_EXPORT2 getStaticClassID ()
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW

Private Member Functions

void dispose (void)
UnicodeStringgetBogus () const
void init ()

Private Attributes

UnicodeString fBogus
DecimalNumberString * fDecimalStr
Type fType
union {
   struct {
      Formattable *   fArray
      int32_t   fCount
   }   fArrayAndCount
   UDate   fDate
   double   fDouble
   int64_t   fInt64
   UObject *   fObject
   UnicodeString *   fString

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index