| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 ******************************************************************************* | |
| 3 * Copyright (C) 2010, International Business Machines Corporation and | |
| 4 * others. All Rights Reserved. | |
| 5 ******************************************************************************* | |
| 6 * | |
| 7 * | |
| 8 * File NUMSYS.H | |
| 9 * | |
| 10 * Modification History:* | |
| 11 * Date Name Description | |
| 12 * | |
| 13 ******************************************************************************** | |
| 14 */ | |
| 15 | |
| 16 #ifndef NUMSYS | |
| 17 #define NUMSYS | |
| 18 | |
| 19 /** | |
| 20 * \def NUMSYS_NAME_CAPACITY | |
| 21 * Size of a numbering system name. | |
| 22 * @internal | |
| 23 */ | |
| 24 #define NUMSYS_NAME_CAPACITY 8 | |
| 25 | |
| 26 #include "unicode/utypes.h" | |
| 27 | |
| 28 /** | |
| 29 * \file | |
| 30 * \brief C++ API: NumberingSystem object | |
| 31 */ | |
| 32 | |
| 33 #if !UCONFIG_NO_FORMATTING | |
| 34 | |
| 35 | |
| 36 #include "unicode/format.h" | |
| 37 #include "unicode/uobject.h" | |
| 38 | |
| 39 U_NAMESPACE_BEGIN | |
| 40 | |
| 41 /** | |
| 42 * Defines numbering systems. A numbering system describes the scheme by which | |
| 43 * numbers are to be presented to the end user. In its simplest form, a numberi
ng | |
| 44 * system describes the set of digit characters that are to be used to display | |
| 45 * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc. | |
| 46 * More complicated numbering systems are algorithmic in nature, and require use | |
| 47 * of an RBNF formatter ( rule based number formatter ), in order to calculate | |
| 48 * the characters to be displayed for a given number. Examples of algorithmic | |
| 49 * numbering systems include Roman numerals, Chinese numerals, and Hebrew numera
ls. | |
| 50 * Formatting rules for many commonly used numbering systems are included in | |
| 51 * the ICU package, based on the numbering system rules defined in CLDR. | |
| 52 * Alternate numbering systems can be specified to a locale by using the | |
| 53 * numbers locale keyword. | |
| 54 */ | |
| 55 | |
| 56 class U_I18N_API NumberingSystem : public UObject { | |
| 57 public: | |
| 58 | |
| 59 /** | |
| 60 * Default Constructor. | |
| 61 * | |
| 62 * @stable ICU 4.2 | |
| 63 */ | |
| 64 NumberingSystem(); | |
| 65 | |
| 66 /** | |
| 67 * Copy constructor. | |
| 68 * @stable ICU 4.2 | |
| 69 */ | |
| 70 NumberingSystem(const NumberingSystem& other); | |
| 71 | |
| 72 /** | |
| 73 * Destructor. | |
| 74 * @stable ICU 4.2 | |
| 75 */ | |
| 76 virtual ~NumberingSystem(); | |
| 77 | |
| 78 /** | |
| 79 * Create the default numbering system associated with the specified locale. | |
| 80 * @param inLocale The given locale. | |
| 81 * @param status ICU status | |
| 82 * @stable ICU 4.2 | |
| 83 */ | |
| 84 static NumberingSystem* U_EXPORT2 createInstance(const Locale & inLocale, UE
rrorCode& status); | |
| 85 | |
| 86 /** | |
| 87 * Create the default numbering system associated with the default locale. | |
| 88 * @stable ICU 4.2 | |
| 89 */ | |
| 90 static NumberingSystem* U_EXPORT2 createInstance(UErrorCode& status); | |
| 91 | |
| 92 /** | |
| 93 * Create a numbering system using the specified radix, type, and descriptio
n. | |
| 94 * @param radix The radix (base) for this numbering system. | |
| 95 * @param isAlgorithmic TRUE if the numbering system is algorithmic rather t
han numeric. | |
| 96 * @param description The string representing the set of digits used in a
numeric system, or the name of the RBNF | |
| 97 * ruleset to be used in an algorithmic system. | |
| 98 * @param status ICU status | |
| 99 * @stable ICU 4.2 | |
| 100 */ | |
| 101 static NumberingSystem* U_EXPORT2 createInstance(int32_t radix, UBool isAlgo
rithmic, const UnicodeString& description, UErrorCode& status ); | |
| 102 | |
| 103 /** | |
| 104 * Return a StringEnumeration over all the names of numbering systems known
to ICU. | |
| 105 * @stable ICU 4.2 | |
| 106 */ | |
| 107 | |
| 108 static StringEnumeration * U_EXPORT2 getAvailableNames(UErrorCode& status); | |
| 109 | |
| 110 /** | |
| 111 * Create a numbering system from one of the predefined numbering systems kn
own to ICU. | |
| 112 * @param name The name of the numbering system. | |
| 113 * @param status ICU status | |
| 114 * @stable ICU 4.2 | |
| 115 */ | |
| 116 static NumberingSystem* U_EXPORT2 createInstanceByName(const char* name, UEr
rorCode& status); | |
| 117 | |
| 118 | |
| 119 /** | |
| 120 * Returns the radix of this numbering system. | |
| 121 * @stable ICU 4.2 | |
| 122 */ | |
| 123 int32_t getRadix(); | |
| 124 | |
| 125 /** | |
| 126 * Returns the name of this numbering system if it was created using one of
the predefined names | |
| 127 * known to ICU. Otherwise, returns NULL. | |
| 128 * @draft ICU 4.6 | |
| 129 */ | |
| 130 const char * getName(); | |
| 131 | |
| 132 /** | |
| 133 * Returns the description string of this numbering system, which is either | |
| 134 * the string of digits in the case of simple systems, or the ruleset name | |
| 135 * in the case of algorithmic systems. | |
| 136 * @stable ICU 4.2 | |
| 137 */ | |
| 138 virtual UnicodeString getDescription(); | |
| 139 | |
| 140 | |
| 141 | |
| 142 /** | |
| 143 * Returns TRUE if the given numbering system is algorithmic | |
| 144 * | |
| 145 * @return TRUE if the numbering system is algorithmic. | |
| 146 * Otherwise, return FALSE. | |
| 147 * @stable ICU 4.2 | |
| 148 */ | |
| 149 UBool isAlgorithmic() const; | |
| 150 | |
| 151 /** | |
| 152 * ICU "poor man's RTTI", returns a UClassID for this class. | |
| 153 * | |
| 154 * @stable ICU 4.2 | |
| 155 * | |
| 156 */ | |
| 157 static UClassID U_EXPORT2 getStaticClassID(void); | |
| 158 | |
| 159 /** | |
| 160 * ICU "poor man's RTTI", returns a UClassID for the actual class. | |
| 161 * | |
| 162 * @stable ICU 4.2 | |
| 163 */ | |
| 164 virtual UClassID getDynamicClassID() const; | |
| 165 | |
| 166 | |
| 167 private: | |
| 168 UnicodeString desc; | |
| 169 int32_t radix; | |
| 170 UBool algorithmic; | |
| 171 char name[NUMSYS_NAME_CAPACITY+1]; | |
| 172 | |
| 173 void setRadix(int32_t radix); | |
| 174 | |
| 175 void setAlgorithmic(UBool algorithmic); | |
| 176 | |
| 177 void setDesc(UnicodeString desc); | |
| 178 | |
| 179 void setName(const char* name); | |
| 180 | |
| 181 static UBool isValidDigitString(const UnicodeString &str); | |
| 182 | |
| 183 UBool hasContiguousDecimalDigits() const; | |
| 184 }; | |
| 185 | |
| 186 U_NAMESPACE_END | |
| 187 | |
| 188 #endif /* #if !UCONFIG_NO_FORMATTING */ | |
| 189 | |
| 190 #endif // _NUMSYS | |
| 191 //eof | |
| OLD | NEW |