2 *******************************************************************************
3 * Copyright (C) 2010-2014, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
10 * Modification History:*
11 * Date Name Description
13 ********************************************************************************
19 #include "unicode/utypes.h"
22 * \def NUMSYS_NAME_CAPACITY
23 * Size of a numbering system name.
26 #define NUMSYS_NAME_CAPACITY 8
31 * \brief C++ API: NumberingSystem object
34 #if !UCONFIG_NO_FORMATTING
37 #include "unicode/format.h"
38 #include "unicode/uobject.h"
43 * Defines numbering systems. A numbering system describes the scheme by which
44 * numbers are to be presented to the end user. In its simplest form, a numbering
45 * system describes the set of digit characters that are to be used to display
46 * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc., in a
47 * positional numbering system with a specified radix (typically 10).
48 * More complicated numbering systems are algorithmic in nature, and require use
49 * of an RBNF formatter ( rule based number formatter ), in order to calculate
50 * the characters to be displayed for a given number. Examples of algorithmic
51 * numbering systems include Roman numerals, Chinese numerals, and Hebrew numerals.
52 * Formatting rules for many commonly used numbering systems are included in
53 * the ICU package, based on the numbering system rules defined in CLDR.
54 * Alternate numbering systems can be specified to a locale by using the
55 * numbers locale keyword.
58 class U_I18N_API NumberingSystem
: public UObject
{
62 * Default Constructor.
72 NumberingSystem(const NumberingSystem
& other
);
78 virtual ~NumberingSystem();
81 * Create the default numbering system associated with the specified locale.
82 * @param inLocale The given locale.
83 * @param status ICU status
86 static NumberingSystem
* U_EXPORT2
createInstance(const Locale
& inLocale
, UErrorCode
& status
);
89 * Create the default numbering system associated with the default locale.
92 static NumberingSystem
* U_EXPORT2
createInstance(UErrorCode
& status
);
95 * Create a numbering system using the specified radix, type, and description.
96 * @param radix The radix (base) for this numbering system.
97 * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric.
98 * @param description The string representing the set of digits used in a numeric system, or the name of the RBNF
99 * ruleset to be used in an algorithmic system.
100 * @param status ICU status
103 static NumberingSystem
* U_EXPORT2
createInstance(int32_t radix
, UBool isAlgorithmic
, const UnicodeString
& description
, UErrorCode
& status
);
106 * Return a StringEnumeration over all the names of numbering systems known to ICU.
110 static StringEnumeration
* U_EXPORT2
getAvailableNames(UErrorCode
& status
);
113 * Create a numbering system from one of the predefined numbering systems specified
114 * by CLDR and known to ICU, such as "latn", "arabext", or "hanidec"; the full list
115 * is returned by unumsys_openAvailableNames. Note that some of the names listed at
116 * http://unicode.org/repos/cldr/tags/latest/common/bcp47/number.xml - e.g.
117 * default, native, traditional, finance - do not identify specific numbering systems,
118 * but rather key values that may only be used as part of a locale, which in turn
119 * defines how they are mapped to a specific numbering system such as "latn" or "hant".
120 * @param name The name of the numbering system.
121 * @param status ICU status
124 static NumberingSystem
* U_EXPORT2
createInstanceByName(const char* name
, UErrorCode
& status
);
128 * Returns the radix of this numbering system. Simple positional numbering systems
129 * typically have radix 10, but might have a radix of e.g. 16 for hexadecimal. The
130 * radix is less well-defined for non-positional algorithmic systems.
133 int32_t getRadix() const;
136 * Returns the name of this numbering system if it was created using one of the predefined names
137 * known to ICU. Otherwise, returns NULL.
138 * The predefined names are identical to the numbering system names as defined by
139 * the BCP47 definition in Unicode CLDR.
140 * See also, http://www.unicode.org/repos/cldr/tags/latest/common/bcp47/number.xml
143 const char * getName() const;
146 * Returns the description string of this numbering system. For simple
147 * positional systems this is the ordered string of digits (with length matching
148 * the radix), e.g. "\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D"
149 * for "hanidec"; it would be "0123456789ABCDEF" for hexadecimal. For
150 * algorithmic systems this is the name of the RBNF ruleset used for formatting,
151 * e.g. "zh/SpelloutRules/%spellout-cardinal" for "hans" or "%greek-upper" for
155 virtual UnicodeString
getDescription() const;
160 * Returns TRUE if the given numbering system is algorithmic
162 * @return TRUE if the numbering system is algorithmic.
163 * Otherwise, return FALSE.
166 UBool
isAlgorithmic() const;
169 * ICU "poor man's RTTI", returns a UClassID for this class.
174 static UClassID U_EXPORT2
getStaticClassID(void);
177 * ICU "poor man's RTTI", returns a UClassID for the actual class.
181 virtual UClassID
getDynamicClassID() const;
188 char name
[NUMSYS_NAME_CAPACITY
+1];
190 void setRadix(int32_t radix
);
192 void setAlgorithmic(UBool algorithmic
);
194 void setDesc(UnicodeString desc
);
196 void setName(const char* name
);
198 static UBool
isValidDigitString(const UnicodeString
&str
);
200 UBool
hasContiguousDecimalDigits() const;
205 #endif /* #if !UCONFIG_NO_FORMATTING */