Movatterモバイル変換


[0]ホーム

URL:


ICU 78.1  78.1
Public Types |Public Member Functions |Static Public Member Functions
icu::Formattable Class Reference

Formattable objects can be passed to theFormat class or its subclasses for formatting.More...

#include <fmtable.h>

Inheritance diagram for icu::Formattable:

Public Types

enum  ISDATE {kIsDate }
 This enum is only used to let callers distinguish between theFormattable(UDate) constructor and theFormattable(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 aFormattable object.More...
 

Public Member Functions

 Formattable ()
 Default constructor.More...
 
 Formattable (UDate d,ISDATE flag)
 Creates aFormattable object with a UDate instance.More...
 
 Formattable (double d)
 Creates aFormattable object with a double number.More...
 
 Formattable (int32_t l)
 Creates aFormattable object with a long number.More...
 
 Formattable (int64_t ll)
 Creates aFormattable object with an int64_t number.More...
 
 Formattable (const char *strToCopy)
 Creates aFormattable object with a char string pointer.More...
 
 Formattable (StringPiece number,UErrorCode &status)
 Creates aFormattable object of an appropriate numeric type from a a decimal number in string form.More...
 
 Formattable (constUnicodeString &strToCopy)
 Creates aFormattable object with aUnicodeString object to copy from.More...
 
 Formattable (UnicodeString *strToAdopt)
 Creates aFormattable object with aUnicodeString object to adopt from.More...
 
 Formattable (constFormattable *arrayToCopy, int32_t count)
 Creates aFormattable object with an array ofFormattable objects.More...
 
 Formattable (UObject *objectToAdopt)
 Creates aFormattable object that adopts the givenUObject.More...
 
 Formattable (constFormattable &)
 Copy constructor.More...
 
Formattableoperator= (constFormattable &rhs)
 Assignment operator.More...
 
bool operator== (constFormattable &other) const
 Equality comparison.More...
 
bool operator!= (constFormattable &other) const
 Equality operator.More...
 
virtual ~Formattable ()
 Destructor.More...
 
Formattableclone () const
 Clone this object.More...
 
Type getType () const
 Gets the data type of thisFormattable object.More...
 
UBool isNumeric () const
 Returns true if the data type of thisFormattable object is kDouble, kLong, or kInt64.More...
 
double getDouble () 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 () 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 () 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...
 
UnicodeStringgetString (UnicodeString &result) const
 Gets the string value of this object.More...
 
UnicodeStringgetString (UnicodeString &result,UErrorCode &status) const
 Gets the string value of this object.More...
 
constUnicodeStringgetString () const
 Gets a const reference to the string value of this object.More...
 
constUnicodeStringgetString (UErrorCode &status) const
 Gets a const reference to the string value of this object.More...
 
UnicodeStringgetString ()
 Gets a reference to the string value of this object.More...
 
UnicodeStringgetString (UErrorCode &status)
 Gets a reference to the string value of this object.More...
 
constFormattablegetArray (int32_t &count) const
 Gets the array value and count of this object.More...
 
constFormattablegetArray (int32_t &count,UErrorCode &status) const
 Gets the array value and count of this object.More...
 
Formattableoperator[] (int32_t index)
 Accesses the specified element in the array value of thisFormattable object.More...
 
constUObjectgetObject () const
 Returns a pointer to theUObject contained within this formattable, or nullptr if this object does not contain aUObject.More...
 
StringPiece getDecimalNumber (UErrorCode &status)
 Returns a numeric string representation of the number contained within this formattable, or nullptr if this object does not contain numeric type.More...
 
void setDouble (double d)
 Sets the double value of this object and changes the type to kDouble.More...
 
void setLong (int32_t l)
 Sets the long value of this object and changes the type to kLong.More...
 
void setInt64 (int64_t ll)
 Sets the int64 value of this object and changes the type to kInt64.More...
 
void setDate (UDate d)
 Sets the Date value of this object and changes the type to kDate.More...
 
void setString (constUnicodeString &stringToCopy)
 Sets the string value of this object and changes the type to kString.More...
 
void setArray (constFormattable *array, int32_t count)
 Sets the array value and count of this object and changes the type to kArray.More...
 
void adoptString (UnicodeString *stringToAdopt)
 Sets and adopts the string value and count of this object and changes the type to kArray.More...
 
void adoptArray (Formattable *array, int32_t count)
 Sets and adopts the array value and count of this object and changes the type to kArray.More...
 
void adoptObject (UObject *objectToAdopt)
 Sets and adopts theUObject value of this object and changes the type to kObject.More...
 
void setDecimalNumber (StringPiece numberString,UErrorCode &status)
 Sets the numeric value from a decimal number string, and changes the type to to a numeric type appropriate for the number.More...
 
virtualUClassID getDynamicClassID () const override
 ICU "poor man's RTTI", returns a UClassID for the actual class.More...
 
UFormattabletoUFormattable ()
 Convert this object pointer to a UFormattable.More...
 
constUFormattabletoUFormattable () const
 Convert this object pointer to a UFormattable.More...
 
int32_t getLong (UErrorCode *status) const
 Deprecated variant of getLong(UErrorCode&).More...
 
number::impl::DecimalQuantity * getDecimalQuantity () const
 Internal function, do not use.More...
 
void populateDecimalQuantity (number::impl::DecimalQuantity &output,UErrorCode &status) const
 Export the value of thisFormattable to a DecimalQuantity.More...
 
void adoptDecimalQuantity (number::impl::DecimalQuantity *dq)
 Adopt, and set value from, a DecimalQuantity Internal Function, do not use.More...
 
FixedString * internalGetFixedString (UErrorCode &status)
 Internal function to return the FixedString pointer.More...
 
- Public Member Functions inherited fromicu::UObject
virtual ~UObject ()
 Destructor.More...
 

Static Public Member Functions

staticUClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class.More...
 
staticFormattablefromUFormattable (UFormattable *fmt)
 Convert the UFormattable to aFormattable.More...
 
static constFormattablefromUFormattable (constUFormattable *fmt)
 Convert the const UFormattable to a constFormattable.More...
 

Detailed Description

Formattable objects can be passed to theFormat 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 andUnicodeString.

Internally, aFormattable 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 aUObject pointer, which it owns. This allows an instance of any ICU class to be encapsulated in aFormattable. For legacy reasons and for efficiency, primitive numeric types are still stored directly within aFormattable.

TheFormattable class is not suitable for subclassing.

See UFormattable for a C wrapper.

Definition at line63 of filefmtable.h.

Member Enumeration Documentation

◆ ISDATE

enumicu::Formattable::ISDATE

This enum is only used to let callers distinguish between theFormattable(UDate) constructor and theFormattable(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.

Stable:
ICU 2.4

Definition at line74 of filefmtable.h.

◆ Type

enumicu::Formattable::Type

Selector for flavor of data type contained within aFormattable object.

Formattable is a union of several different types, and at any time contains exactly one type.

Stable:
ICU 2.4
Enumerator
kDate 

Selector indicating a UDate value.

Use getDate to retrieve the value.

Stable:
ICU 2.4
kDouble 

Selector indicating a double value.

Use getDouble to retrieve the value.

Stable:
ICU 2.4
kLong 

Selector indicating a 32-bit integer value.

Use getLong to retrieve the value.

Stable:
ICU 2.4
kString 

Selector indicating aUnicodeString value.

Use getString to retrieve the value.

Stable:
ICU 2.4
kArray 

Selector indicating an array of Formattables.

Use getArray to retrieve the value.

Stable:
ICU 2.4
kInt64 

Selector indicating a 64-bit integer value.

Use getInt64 to retrieve the value.

Stable:
ICU 2.8
kObject 

Selector indicating aUObject value.

Use getObject to retrieve the value.

Stable:
ICU 3.0

Definition at line220 of filefmtable.h.

Constructor & Destructor Documentation

◆ Formattable()[1/12]

icu::Formattable::Formattable()

Default constructor.

Stable:
ICU 2.4

◆ Formattable()[2/12]

icu::Formattable::Formattable(UDate d,
ISDATE flag 
)

Creates aFormattable object with a UDate instance.

Parameters
dthe UDate instance.
flagthe flag to indicate this is a date. Always set it to kIsDate
Stable:
ICU 2.0

◆ Formattable()[3/12]

icu::Formattable::Formattable(double d)

Creates aFormattable object with a double number.

Parameters
dthe double number.
Stable:
ICU 2.0

◆ Formattable()[4/12]

icu::Formattable::Formattable(int32_t l)

Creates aFormattable object with a long number.

Parameters
lthe long number.
Stable:
ICU 2.0

◆ Formattable()[5/12]

icu::Formattable::Formattable(int64_t ll)

Creates aFormattable object with an int64_t number.

Parameters
llthe int64_t number.
Stable:
ICU 2.8

◆ Formattable()[6/12]

icu::Formattable::Formattable(const char * strToCopy)

Creates aFormattable object with a char string pointer.

Assumes that the char string is null terminated.

Parameters
strToCopythe char string.
Stable:
ICU 2.0

◆ Formattable()[7/12]

icu::Formattable::Formattable(StringPiece number,
UErrorCodestatus 
)

Creates aFormattable object of an appropriate numeric type from a a decimal number in string form.

TheFormattable will retain the full precision of the input in decimal format, even when it exceeds what can be represented by a double or int64_t.

Parameters
numberthe unformatted (not localized) string representation of the Decimal number.
statusthe error code. Possible errors include U_INVALID_FORMAT_ERROR if the format of the string does not conform to that of a decimal number.
Stable:
ICU 4.4

◆ Formattable()[8/12]

icu::Formattable::Formattable(constUnicodeStringstrToCopy)

Creates aFormattable object with aUnicodeString object to copy from.

Parameters
strToCopytheUnicodeString string.
Stable:
ICU 2.0

◆ Formattable()[9/12]

icu::Formattable::Formattable(UnicodeStringstrToAdopt)

Creates aFormattable object with aUnicodeString object to adopt from.

Parameters
strToAdopttheUnicodeString string.
Stable:
ICU 2.0

◆ Formattable()[10/12]

icu::Formattable::Formattable(constFormattablearrayToCopy,
int32_t count 
)

Creates aFormattable object with an array ofFormattable objects.

Parameters
arrayToCopytheFormattable object array.
countthe array count.
Stable:
ICU 2.0

◆ Formattable()[11/12]

icu::Formattable::Formattable(UObjectobjectToAdopt)

Creates aFormattable object that adopts the givenUObject.

Parameters
objectToAdopttheUObject to set this object to
Stable:
ICU 3.0

◆ Formattable()[12/12]

icu::Formattable::Formattable(constFormattable)

Copy constructor.

Stable:
ICU 2.0

◆ ~Formattable()

virtual icu::Formattable::~Formattable()
virtual

Destructor.

Stable:
ICU 2.0

Member Function Documentation

◆ adoptArray()

void icu::Formattable::adoptArray(Formattablearray,
int32_t count 
)

Sets and adopts the array value and count of this object and changes the type to kArray.

Stable:
ICU 2.0

◆ adoptDecimalQuantity()

void icu::Formattable::adoptDecimalQuantity(number::impl::DecimalQuantity * dq)

Adopt, and set value from, a DecimalQuantity Internal Function, do not use.

Parameters
dqthe DecimalQuantity to be adopted
Internal:
Do not use. This API is for internal use only.

◆ adoptObject()

void icu::Formattable::adoptObject(UObjectobjectToAdopt)

Sets and adopts theUObject value of this object and changes the type to kObject.

After this call, the caller must not delete the given object.

Parameters
objectToAdopttheUObject value to be adopted
Stable:
ICU 3.0

◆ adoptString()

void icu::Formattable::adoptString(UnicodeStringstringToAdopt)

Sets and adopts the string value and count of this object and changes the type to kArray.

Parameters
stringToAdoptthe new string value to be adopted.
Stable:
ICU 2.0

◆ clone()

Formattable* icu::Formattable::clone() const

Clone this object.

Clones can be used concurrently in multiple threads. If an error occurs, then nullptr is returned. The caller must delete the clone.

Returns
a clone of this object
See also
getDynamicClassID
Stable:
ICU 2.8

◆ fromUFormattable()[1/2]

constFormattable * icu::Formattable::fromUFormattable(constUFormattablefmt)
inlinestatic

Convert the const UFormattable to a constFormattable.

Internally, this is a reinterpret_cast.

Parameters
fmta valid UFormattable
Returns
the UFormattable as aFormattable object pointer. This is an alias to the original UFormattable, and so is only valid while the original argument remains in scope.
Stable:
ICU 52

Definition at line747 of filefmtable.h.

◆ fromUFormattable()[2/2]

Formattable * icu::Formattable::fromUFormattable(UFormattablefmt)
inlinestatic

Convert the UFormattable to aFormattable.

Internally, this is a reinterpret_cast.

Parameters
fmta valid UFormattable
Returns
the UFormattable as aFormattable object pointer. This is an alias to the original UFormattable, and so is only valid while the original argument remains in scope.
Stable:
ICU 52

Definition at line743 of filefmtable.h.

◆ getArray()[1/2]

constFormattable* icu::Formattable::getArray(int32_t & count) const
inline

Gets the array value and count of this object.

If this object is not of type kArray then the result is undefined.

Parameters
countfill-in with the count of this object.
Returns
the array value of this object.
Stable:
ICU 2.0

Definition at line442 of filefmtable.h.

◆ getArray()[2/2]

constFormattable* icu::Formattable::getArray(int32_t & count,
UErrorCodestatus 
) const

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 nullptr.

Parameters
countfill-in with the count of this object.
statusthe error code.
Returns
the array value of this object.
Stable:
ICU 3.0

◆ getDate()[1/2]

UDate icu::Formattable::getDate() const
inline

Gets the Date value of this object.

If this object is not of type kDate then the result is undefined.

Returns
the Date value of this object.
Stable:
ICU 2.0

Definition at line365 of filefmtable.h.

◆ getDate()[2/2]

UDate icu::Formattable::getDate(UErrorCodestatus) const
inline

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.

Parameters
statusthe error code.
Returns
the Date value of this object.
Stable:
ICU 3.0

Definition at line711 of filefmtable.h.

ReferencesU_INVALID_FORMAT_ERROR, andU_SUCCESS.

◆ getDecimalNumber()

StringPiece icu::Formattable::getDecimalNumber(UErrorCodestatus)

Returns a numeric string representation of the number contained within this formattable, or nullptr if this object does not contain numeric type.

For values obtained by parsing, the returned decimal number retains the full precision and range of the original input, unconstrained by the limits of a double floating point or a 64 bit int.

This function is not thread safe, and therefore is not declared const, even though it is logically const.

Possible errors include U_MEMORY_ALLOCATION_ERROR, and U_INVALID_STATE if the formattable object has not been set to a numeric type.

Parameters
statusthe error code.
Returns
the unformatted string representation of a number.
Stable:
ICU 4.4

◆ getDecimalQuantity()

number::impl::DecimalQuantity* icu::Formattable::getDecimalQuantity() const
inline

Internal function, do not use.

TODO: figure out how to make this be non-public.NumberFormat::format(Formattable, ... needs to get at the DecimalQuantity, if it exists, for big decimal formatting.

Internal:
Do not use. This API is for internal use only.

Definition at line651 of filefmtable.h.

◆ getDouble()[1/2]

double icu::Formattable::getDouble() const
inline

Gets the double value of this object.

If this object is not of type kDouble then the result is undefined.

Returns
the double value of this object.
Stable:
ICU 2.0

Definition at line292 of filefmtable.h.

◆ getDouble()[2/2]

double icu::Formattable::getDouble(UErrorCodestatus) const

Gets the double value of this object.

If this object is of type long, int64 or Decimal Number then a conversion is performed, with possible loss of precision. If the type is kObject and the object is aMeasure, then the result of getNumber().getDouble(status) is returned. If this object is neither a numeric type nor aMeasure, then 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.

Parameters
statusthe error code
Returns
the double value of this object.
Stable:
ICU 3.0

◆ getDynamicClassID()

virtualUClassID icu::Formattable::getDynamicClassID() const
overridevirtual

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 2.2

Reimplemented fromicu::UObject.

◆ getInt64()[1/2]

int64_t icu::Formattable::getInt64() const
inline

Gets the int64 value of this object.

If this object is not of type kInt64 then the result is undefined.

Returns
the int64 value of this object.
Stable:
ICU 2.8

Definition at line340 of filefmtable.h.

◆ getInt64()[2/2]

int64_t icu::Formattable::getInt64(UErrorCodestatus) const

Gets the int64 value of this object.

If this object is of a numeric type 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 performed, with truncation of any fractional part. If the type is kObject and the object is aMeasure, then the result of getNumber().getDouble(status) is returned. If this object is neither a numeric type nor aMeasure, then 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.

Parameters
statusthe error code
Returns
the int64 value of this object.
Stable:
ICU 3.0

◆ getLong()[1/3]

int32_t icu::Formattable::getLong() const
inline

Gets the long value of this object.

If this object is not of type kLong then the result is undefined.

Returns
the long value of this object.
Stable:
ICU 2.0

Definition at line314 of filefmtable.h.

◆ getLong()[2/3]

int32_t icu::Formattable::getLong(UErrorCodestatus) const

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 conversion is performed, with truncation of any fractional part. If the type is kObject and the object is aMeasure, then the result of getNumber().getLong(status) is returned. If this object is neither a numeric type nor aMeasure, then 0 is returned and the status is set to U_INVALID_FORMAT_ERROR.

Parameters
statusthe error code
Returns
the long value of this object.
Stable:
ICU 3.0

◆ getLong()[3/3]

int32_t icu::Formattable::getLong(UErrorCodestatus) const
inline

Deprecated variant of getLong(UErrorCode&).

Parameters
statusthe error code
Returns
the long value of this object.
Deprecated:
ICU 3.0 use getLong(UErrorCode&) instead

Definition at line730 of filefmtable.h.

◆ getObject()

constUObject* icu::Formattable::getObject() const

Returns a pointer to theUObject contained within this formattable, or nullptr if this object does not contain aUObject.

Returns
aUObject pointer, or nullptr
Stable:
ICU 3.0

◆ getStaticClassID()

staticUClassID icu::Formattable::getStaticClassID()
static

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 2.2

◆ getString()[1/6]

UnicodeString & icu::Formattable::getString()
inline

Gets a reference to the string value of this object.

If this object is not of type kString then the result is undefined.

Returns
a reference to the string value of this object.
Stable:
ICU 2.0

Definition at line725 of filefmtable.h.

◆ getString()[2/6]

constUnicodeString & icu::Formattable::getString() const
inline

Gets a const reference to the string value of this object.

If this object is not of type kString then the result is undefined.

Returns
a const reference to the string value of this object.
Stable:
ICU 2.0

Definition at line721 of filefmtable.h.

◆ getString()[3/6]

UnicodeString& icu::Formattable::getString(UErrorCodestatus)

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.

Parameters
statusthe error code.
Returns
a reference to the string value of this object.
Stable:
ICU 3.0

◆ getString()[4/6]

constUnicodeString& icu::Formattable::getString(UErrorCodestatus) const

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.

Parameters
statusthe error code.
Returns
a const reference to the string value of this object.
Stable:
ICU 3.0

◆ getString()[5/6]

UnicodeString& icu::Formattable::getString(UnicodeStringresult) const
inline

Gets the string value of this object.

If this object is not of type kString then the result is undefined.

Parameters
resultOutput param to receive the Date value of this object.
Returns
A reference to 'result'.
Stable:
ICU 2.0

Definition at line384 of filefmtable.h.

◆ getString()[6/6]

UnicodeString& icu::Formattable::getString(UnicodeStringresult,
UErrorCodestatus 
) const

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.

Parameters
resultOutput param to receive the Date value of this object.
statusthe error code.
Returns
A reference to 'result'.
Stable:
ICU 3.0

◆ getType()

Type icu::Formattable::getType() const

Gets the data type of thisFormattable object.

Returns
the data type of thisFormattable object.
Stable:
ICU 2.0

◆ internalGetFixedString()

FixedString* icu::Formattable::internalGetFixedString(UErrorCodestatus)

Internal function to return the FixedString pointer.

Parameters
statuserror code
Returns
pointer to the FixedString - may become invalid if the object is modified
Internal:
Do not use. This API is for internal use only.

◆ isNumeric()

UBool icu::Formattable::isNumeric() const

Returns true if the data type of thisFormattable object is kDouble, kLong, or kInt64.

Returns
true if this is a pure numeric object
Stable:
ICU 3.0

◆ operator!=()

bool icu::Formattable::operator!=(constFormattableother) const
inline

Equality operator.

Parameters
otherthe object to be compared with.
Returns
true if other are unequal to this, false otherwise.
Stable:
ICU 2.0

Definition at line192 of filefmtable.h.

Referencesicu::operator==().

◆ operator=()

Formattable& icu::Formattable::operator=(constFormattablerhs)

Assignment operator.

Parameters
rhsTheFormattable object to copy into this object.
Stable:
ICU 2.0

◆ operator==()

bool icu::Formattable::operator==(constFormattableother) const

Equality comparison.

Parameters
otherthe object to be compared with.
Returns
true if other are equal to this, false otherwise.
Stable:
ICU 2.0

◆ operator[]()

Formattable& icu::Formattable::operator[](int32_t index)
inline

Accesses the specified element in the array value of thisFormattable object.

If this object is not of type kArray then the result is undefined.

Parameters
indexthe specified index.
Returns
the accessed element in the array.
Stable:
ICU 2.0

Definition at line464 of filefmtable.h.

◆ populateDecimalQuantity()

void icu::Formattable::populateDecimalQuantity(number::impl::DecimalQuantity & output,
UErrorCodestatus 
) const

Export the value of thisFormattable to a DecimalQuantity.

Internal:
Do not use. This API is for internal use only.

◆ setArray()

void icu::Formattable::setArray(constFormattablearray,
int32_t count 
)

Sets the array value and count of this object and changes the type to kArray.

Parameters
arraythe array value.
countthe number of array elements to be copied.
Stable:
ICU 2.0

◆ setDate()

void icu::Formattable::setDate(UDate d)

Sets the Date value of this object and changes the type to kDate.

Parameters
dthe new Date value to be set.
Stable:
ICU 2.0

◆ setDecimalNumber()

void icu::Formattable::setDecimalNumber(StringPiece numberString,
UErrorCodestatus 
)

Sets the numeric value from a decimal number string, and changes the type to to a numeric type appropriate for the number.

The syntax of the number is a "numeric string" as defined in the Decimal Arithmetic Specification, available athttp://speleotrove.com/decimal The full precision and range of the input number will be retained, even when it exceeds what can be represented by a double or an int64.

Parameters
numberStringa string representation of the unformatted decimal number.
statusthe error code. Set to U_INVALID_FORMAT_ERROR if the incoming string is not a valid decimal number.
Stable:
ICU 4.4

◆ setDouble()

void icu::Formattable::setDouble(double d)

Sets the double value of this object and changes the type to kDouble.

Parameters
dthe new double value to be set.
Stable:
ICU 2.0

◆ setInt64()

void icu::Formattable::setInt64(int64_t ll)

Sets the int64 value of this object and changes the type to kInt64.

Parameters
llthe new int64 value to be set.
Stable:
ICU 2.8

◆ setLong()

void icu::Formattable::setLong(int32_t l)

Sets the long value of this object and changes the type to kLong.

Parameters
lthe new long value to be set.
Stable:
ICU 2.0

◆ setString()

void icu::Formattable::setString(constUnicodeStringstringToCopy)

Sets the string value of this object and changes the type to kString.

Parameters
stringToCopythe new string value to be set.
Stable:
ICU 2.0

◆ toUFormattable()[1/2]

UFormattable * icu::Formattable::toUFormattable()
inline

Convert this object pointer to a UFormattable.

Returns
this object as a UFormattable pointer. This is an alias to this object, and so is only valid while this object remains in scope.
Stable:
ICU 52

Definition at line735 of filefmtable.h.

◆ toUFormattable()[2/2]

constUFormattable * icu::Formattable::toUFormattable() const
inline

Convert this object pointer to a UFormattable.

Returns
this object as a UFormattable pointer. This is an alias to this object, and so is only valid while this object remains in scope.
Stable:
ICU 52

Definition at line739 of filefmtable.h.


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

Generated by doxygen 1.9.1
[8]ページ先頭

©2009-2025 Movatter.jp