Movatterモバイル変換


[0]ホーム

URL:


ICU 78.1  78.1
fmtable.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 * Copyright (C) 1997-2014, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
8 *
9 * File FMTABLE.H
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 02/29/97 aliu Creation.
15 ********************************************************************************
16 */
17 #ifndef FMTABLE_H
18 #define FMTABLE_H
19 
20 #include "unicode/utypes.h"
21 
22 #if U_SHOW_CPLUSPLUS_API
23 
29 #if !UCONFIG_NO_FORMATTING
30 
31 #include "unicode/unistr.h"
32 #include "unicode/stringpiece.h"
33 #include "unicode/uformattable.h"
34 
35 U_NAMESPACE_BEGIN
36 
37 classFixedString;
38 
39 namespacenumber::impl {
40 classDecimalQuantity;
41 }
42 
63 classU_I18N_APIFormattable :publicUObject {
64 public:
74 enumISDATE { kIsDate };
75 
80 Formattable();// Type kLong, value 0
81 
88 Formattable(UDate d,ISDATE flag);
89 
95 Formattable(double d);
96 
102 Formattable(int32_t l);
103 
109 Formattable(int64_t ll);
110 
111 #if !UCONFIG_NO_CONVERSION
118 Formattable(constchar* strToCopy);
119 #endif
120 
134 Formattable(StringPiece number,UErrorCode &status);
135 
141 Formattable(constUnicodeString& strToCopy);
142 
148 Formattable(UnicodeString* strToAdopt);
149 
156 Formattable(constFormattable* arrayToCopy, int32_t count);
157 
163 Formattable(UObject* objectToAdopt);
164 
169 Formattable(constFormattable&);
170 
176 Formattable&operator=(constFormattable &rhs);
177 
184 booloperator==(constFormattable &other)const;
185 
192 booloperator!=(constFormattable& other) const
193 {return !operator==(other); }
194 
199 virtual~Formattable();
200 
212 Formattable *clone()const;
213 
220 enumType {
226 kDate,
227 
233 kDouble,
234 
240 kLong,
241 
247 kString,
248 
254 kArray,
255 
261 kInt64,
262 
268  kObject
269  };
270 
276 TypegetType()const;
277 
284 UBoolisNumeric()const;
285 
292 doublegetDouble() const{return fValue.fDouble; }
293 
306 doublegetDouble(UErrorCode& status)const;
307 
314  int32_tgetLong() const{returnstatic_cast<int32_t>(fValue.fInt64); }
315 
332  int32_tgetLong(UErrorCode& status)const;
333 
340  int64_tgetInt64() const{return fValue.fInt64; }
341 
357  int64_tgetInt64(UErrorCode& status)const;
358 
365 UDategetDate() const{return fValue.fDate; }
366 
375 UDate getDate(UErrorCode& status)const;
376 
384 UnicodeString&getString(UnicodeString& result) const
385 { result=*fValue.fString;return result; }
386 
396 UnicodeString&getString(UnicodeString& result,UErrorCode& status)const;
397 
405 inlineconstUnicodeString& getString()const;
406 
415 constUnicodeString&getString(UErrorCode& status)const;
416 
423 inlineUnicodeString& getString();
424 
433 UnicodeString&getString(UErrorCode& status);
434 
442 constFormattable*getArray(int32_t& count) const
443 { count=fValue.fArrayAndCount.fCount;return fValue.fArrayAndCount.fArray; }
444 
454 constFormattable*getArray(int32_t& count,UErrorCode& status)const;
455 
464 Formattable&operator[](int32_t index) {return fValue.fArrayAndCount.fArray[index]; }
465 
472 constUObject*getObject()const;
473 
492 StringPiecegetDecimalNumber(UErrorCode &status);
493 
500 voidsetDouble(double d);
501 
508 voidsetLong(int32_t l);
509 
516 voidsetInt64(int64_t ll);
517 
524 voidsetDate(UDate d);
525 
532 voidsetString(constUnicodeString& stringToCopy);
533 
541 voidsetArray(constFormattable* array, int32_t count);
542 
549 voidadoptString(UnicodeString* stringToAdopt);
550 
556 voidadoptArray(Formattable* array, int32_t count);
557 
565 voidadoptObject(UObject* objectToAdopt);
566 
581 voidsetDecimalNumber(StringPiece numberString,
582 UErrorCode &status);
583 
589 virtualUClassIDgetDynamicClassID()const override;
590 
596 staticUClassID U_EXPORT2getStaticClassID();
597 
605 staticinlineFormattable *fromUFormattable(UFormattable *fmt);
606 
614 staticinlineconstFormattable *fromUFormattable(constUFormattable *fmt);
615 
622 inlineUFormattable *toUFormattable();
623 
630 inlineconstUFormattable *toUFormattable()const;
631 
632 #ifndef U_HIDE_DEPRECATED_API
639 inline int32_t getLong(UErrorCode* status)const;
640 #endif/* U_HIDE_DEPRECATED_API */
641 
642 #ifndef U_HIDE_INTERNAL_API
651  number::impl::DecimalQuantity *getDecimalQuantity() const{return fDecimalQuantity;}
652 
657 voidpopulateDecimalQuantity(number::impl::DecimalQuantity& output,UErrorCode& status)const;
658 
665 voidadoptDecimalQuantity(number::impl::DecimalQuantity *dq);
666 
673  FixedString *internalGetFixedString(UErrorCode &status);
674 
675 #endif/* U_HIDE_INTERNAL_API */
676 
677 private:
682 void dispose();
683 
687 void init();
688 
689 UnicodeString* getBogus()const;
690 
691 union{
692 UObject* fObject;
693 UnicodeString* fString;
694 double fDouble;
695  int64_t fInt64;
696 UDate fDate;
697 struct{
698 Formattable* fArray;
699  int32_t fCount;
700  } fArrayAndCount;
701  } fValue;
702 
703  FixedString* fDecimalStr;
704 
705  number::impl::DecimalQuantity *fDecimalQuantity;
706 
707  Type fType;
708  UnicodeString fBogus;// Bogus string when it's needed.
709 };
710 
711 inlineUDate Formattable::getDate(UErrorCode& status) const{
712 if (fType != kDate) {
713 if (U_SUCCESS(status)) {
714  status =U_INVALID_FORMAT_ERROR;
715  }
716 return 0;
717  }
718 return fValue.fDate;
719 }
720 
721 inlineconstUnicodeString& Formattable::getString() const{
722 return *fValue.fString;
723 }
724 
725 inlineUnicodeString& Formattable::getString() {
726 return *fValue.fString;
727 }
728 
729 #ifndef U_HIDE_DEPRECATED_API
730 inline int32_t Formattable::getLong(UErrorCode* status) const{
731 return getLong(*status);
732 }
733 #endif/* U_HIDE_DEPRECATED_API */
734 
735 inlineUFormattable* Formattable::toUFormattable() {
736 returnreinterpret_cast<UFormattable*>(this);
737 }
738 
739 inlineconstUFormattable* Formattable::toUFormattable() const{
740 returnreinterpret_cast<constUFormattable*>(this);
741 }
742 
743 inlineFormattable* Formattable::fromUFormattable(UFormattable *fmt) {
744 returnreinterpret_cast<Formattable *>(fmt);
745 }
746 
747 inlineconstFormattable* Formattable::fromUFormattable(constUFormattable *fmt) {
748 returnreinterpret_cast<constFormattable *>(fmt);
749 }
750 
751 U_NAMESPACE_END
752 
753 #endif/* #if !UCONFIG_NO_FORMATTING */
754 
755 #endif/* U_SHOW_CPLUSPLUS_API */
756 
757 #endif//_FMTABLE
758 //eof
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition:fmtable.h:63
icu::Formattable::setDecimalNumber
void setDecimalNumber(StringPiece numberString, UErrorCode &status)
Sets the numeric value from a decimal number string, and changes the type to to a numeric type approp...
icu::Formattable::Formattable
Formattable(StringPiece number, UErrorCode &status)
Creates a Formattable object of an appropriate numeric type from a a decimal number in string form.
icu::Formattable::operator=
Formattable & operator=(const Formattable &rhs)
Assignment operator.
icu::Formattable::Formattable
Formattable(UnicodeString *strToAdopt)
Creates a Formattable object with a UnicodeString object to adopt from.
icu::Formattable::clone
Formattable * clone() const
Clone this object.
icu::Formattable::getType
Type getType() const
Gets the data type of this Formattable object.
icu::Formattable::operator[]
Formattable & operator[](int32_t index)
Accesses the specified element in the array value of this Formattable object.
Definition:fmtable.h:464
icu::Formattable::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::Formattable::setArray
void setArray(const Formattable *array, int32_t count)
Sets the array value and count of this object and changes the type to kArray.
icu::Formattable::setString
void setString(const UnicodeString &stringToCopy)
Sets the string value of this object and changes the type to kString.
icu::Formattable::isNumeric
UBool isNumeric() const
Returns true if the data type of this Formattable object is kDouble, kLong, or kInt64.
icu::Formattable::getString
UnicodeString & getString(UErrorCode &status)
Gets a reference to the string value of this object.
icu::Formattable::adoptString
void adoptString(UnicodeString *stringToAdopt)
Sets and adopts the string value and count of this object and changes the type to kArray.
icu::Formattable::Formattable
Formattable(UObject *objectToAdopt)
Creates a Formattable object that adopts the given UObject.
icu::Formattable::getObject
const UObject * getObject() const
Returns a pointer to the UObject contained within this formattable, or nullptr if this object does no...
icu::Formattable::setInt64
void setInt64(int64_t ll)
Sets the int64 value of this object and changes the type to kInt64.
icu::Formattable::Formattable
Formattable(double d)
Creates a Formattable object with a double number.
icu::Formattable::getDecimalQuantity
number::impl::DecimalQuantity * getDecimalQuantity() const
Internal function, do not use.
Definition:fmtable.h:651
icu::Formattable::internalGetFixedString
FixedString * internalGetFixedString(UErrorCode &status)
Internal function to return the FixedString pointer.
icu::Formattable::Formattable
Formattable()
Default constructor.
icu::Formattable::setDouble
void setDouble(double d)
Sets the double value of this object and changes the type to kDouble.
icu::Formattable::getLong
int32_t getLong() const
Gets the long value of this object.
Definition:fmtable.h:314
icu::Formattable::Formattable
Formattable(const UnicodeString &strToCopy)
Creates a Formattable object with a UnicodeString object to copy from.
icu::Formattable::adoptDecimalQuantity
void adoptDecimalQuantity(number::impl::DecimalQuantity *dq)
Adopt, and set value from, a DecimalQuantity Internal Function, do not use.
icu::Formattable::setLong
void setLong(int32_t l)
Sets the long value of this object and changes the type to kLong.
icu::Formattable::Type
Type
Selector for flavor of data type contained within a Formattable object.
Definition:fmtable.h:220
icu::Formattable::kDouble
@ kDouble
Selector indicating a double value.
Definition:fmtable.h:233
icu::Formattable::kArray
@ kArray
Selector indicating an array of Formattables.
Definition:fmtable.h:254
icu::Formattable::kLong
@ kLong
Selector indicating a 32-bit integer value.
Definition:fmtable.h:240
icu::Formattable::kInt64
@ kInt64
Selector indicating a 64-bit integer value.
Definition:fmtable.h:261
icu::Formattable::kString
@ kString
Selector indicating a UnicodeString value.
Definition:fmtable.h:247
icu::Formattable::kDate
@ kDate
Selector indicating a UDate value.
Definition:fmtable.h:226
icu::Formattable::setDate
void setDate(UDate d)
Sets the Date value of this object and changes the type to kDate.
icu::Formattable::getArray
const Formattable * getArray(int32_t &count) const
Gets the array value and count of this object.
Definition:fmtable.h:442
icu::Formattable::getDouble
double getDouble(UErrorCode &status) const
Gets the double value of this object.
icu::Formattable::Formattable
Formattable(const char *strToCopy)
Creates a Formattable object with a char string pointer.
icu::Formattable::Formattable
Formattable(UDate d, ISDATE flag)
Creates a Formattable object with a UDate instance.
icu::Formattable::adoptArray
void adoptArray(Formattable *array, int32_t count)
Sets and adopts the array value and count of this object and changes the type to kArray.
icu::Formattable::adoptObject
void adoptObject(UObject *objectToAdopt)
Sets and adopts the UObject value of this object and changes the type to kObject.
icu::Formattable::operator==
bool operator==(const Formattable &other) const
Equality comparison.
icu::Formattable::getString
const UnicodeString & getString(UErrorCode &status) const
Gets a const reference to the string value of this object.
icu::Formattable::getDouble
double getDouble() const
Gets the double value of this object.
Definition:fmtable.h:292
icu::Formattable::getString
UnicodeString & getString(UnicodeString &result, UErrorCode &status) const
Gets the string value of this object.
icu::Formattable::Formattable
Formattable(const Formattable *arrayToCopy, int32_t count)
Creates a Formattable object with an array of Formattable objects.
icu::Formattable::getInt64
int64_t getInt64() const
Gets the int64 value of this object.
Definition:fmtable.h:340
icu::Formattable::Formattable
Formattable(const Formattable &)
Copy constructor.
icu::Formattable::Formattable
Formattable(int32_t l)
Creates a Formattable object with a long number.
icu::Formattable::getDecimalNumber
StringPiece getDecimalNumber(UErrorCode &status)
Returns a numeric string representation of the number contained within this formattable,...
icu::Formattable::getString
UnicodeString & getString(UnicodeString &result) const
Gets the string value of this object.
Definition:fmtable.h:384
icu::Formattable::~Formattable
virtual ~Formattable()
Destructor.
icu::Formattable::ISDATE
ISDATE
This enum is only used to let callers distinguish between the Formattable(UDate) constructor and the ...
Definition:fmtable.h:74
icu::Formattable::operator!=
bool operator!=(const Formattable &other) const
Equality operator.
Definition:fmtable.h:192
icu::Formattable::populateDecimalQuantity
void populateDecimalQuantity(number::impl::DecimalQuantity &output, UErrorCode &status) const
Export the value of this Formattable to a DecimalQuantity.
icu::Formattable::getDate
UDate getDate() const
Gets the Date value of this object.
Definition:fmtable.h:365
icu::Formattable::getLong
int32_t getLong(UErrorCode &status) const
Gets the long value of this object.
icu::Formattable::getArray
const Formattable * getArray(int32_t &count, UErrorCode &status) const
Gets the array value and count of this object.
icu::Formattable::Formattable
Formattable(int64_t ll)
Creates a Formattable object with an int64_t number.
icu::Formattable::getInt64
int64_t getInt64(UErrorCode &status) const
Gets the int64 value of this object.
icu::Formattable::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition:stringpiece.h:61
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition:uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition:unistr.h:303
icu::operator==
U_COMMON_API UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
uformattable.h
C API: UFormattable is a thin wrapper for primitive types used for formatting and parsing.
UFormattable
void * UFormattable
Opaque type representing various types of data which may be used for formatting and parsing operation...
Definition:uformattable.h:72
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition:umachine.h:269
unistr.h
C++ API: Unicode String.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition:uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition:utypes.h:509
U_INVALID_FORMAT_ERROR
@ U_INVALID_FORMAT_ERROR
Data format is not what is expected.
Definition:utypes.h:548
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition:utypes.h:822
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition:utypes.h:316
UDate
double UDate
Date and Time data type.
Definition:utypes.h:218

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

©2009-2025 Movatter.jp