2 *******************************************************************************
3 * Copyright (C) 2010, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
10 * Modification History:*
11 * Date Name Description
13 ********************************************************************************
20 * \def NUMSYS_NAME_CAPACITY
21 * Size of a numbering system name.
24 #define NUMSYS_NAME_CAPACITY 8
26 #include "unicode/utypes.h"
30 * \brief C++ API: NumberingSystem object
33 #if !UCONFIG_NO_FORMATTING
36 #include "unicode/format.h"
37 #include "unicode/uobject.h"
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 numbering
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 numerals.
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.
56 class U_I18N_API NumberingSystem
: public UObject
{
60 * Default Constructor.
70 NumberingSystem(const NumberingSystem
& other
);
76 virtual ~NumberingSystem();
79 * Create the default numbering system associated with the specified locale.
80 * @param inLocale The given locale.
81 * @param status ICU status
84 static NumberingSystem
* U_EXPORT2
createInstance(const Locale
& inLocale
, UErrorCode
& status
);
87 * Create the default numbering system associated with the default locale.
90 static NumberingSystem
* U_EXPORT2
createInstance(UErrorCode
& status
);
93 * Create a numbering system using the specified radix, type, and description.
94 * @param radix The radix (base) for this numbering system.
95 * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than 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
101 static NumberingSystem
* U_EXPORT2
createInstance(int32_t radix
, UBool isAlgorithmic
, const UnicodeString
& description
, UErrorCode
& status
);
104 * Return a StringEnumeration over all the names of numbering systems known to ICU.
108 static StringEnumeration
* U_EXPORT2
getAvailableNames(UErrorCode
& status
);
111 * Create a numbering system from one of the predefined numbering systems known to ICU.
112 * @param name The name of the numbering system.
113 * @param status ICU status
116 static NumberingSystem
* U_EXPORT2
createInstanceByName(const char* name
, UErrorCode
& status
);
120 * Returns the radix of this numbering system.
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.
130 const char * getName();
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.
138 virtual UnicodeString
getDescription();
143 * Returns TRUE if the given numbering system is algorithmic
145 * @return TRUE if the numbering system is algorithmic.
146 * Otherwise, return FALSE.
149 UBool
isAlgorithmic() const;
152 * ICU "poor man's RTTI", returns a UClassID for this class.
157 static UClassID U_EXPORT2
getStaticClassID(void);
160 * ICU "poor man's RTTI", returns a UClassID for the actual class.
164 virtual UClassID
getDynamicClassID() const;
171 char name
[NUMSYS_NAME_CAPACITY
+1];
173 void setRadix(int32_t radix
);
175 void setAlgorithmic(UBool algorithmic
);
177 void setDesc(UnicodeString desc
);
179 void setName(const char* name
);
181 static UBool
isValidDigitString(const UnicodeString
&str
);
183 UBool
hasContiguousDecimalDigits() const;
188 #endif /* #if !UCONFIG_NO_FORMATTING */