2 *******************************************************************************
3 * Copyright (C) 2010-2013, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
10 * Modification History:*
11 * Date Name Description
13 ********************************************************************************
19 #include "unicode/utypes.h"
21 #ifndef U_HIDE_INTERNAL_API
23 * \def NUMSYS_NAME_CAPACITY
24 * Size of a numbering system name.
27 #define NUMSYS_NAME_CAPACITY 8
28 #endif /* U_HIDE_INTERNAL_API */
33 * \brief C++ API: NumberingSystem object
36 #if !UCONFIG_NO_FORMATTING
39 #include "unicode/format.h"
40 #include "unicode/uobject.h"
45 * Defines numbering systems. A numbering system describes the scheme by which
46 * numbers are to be presented to the end user. In its simplest form, a numbering
47 * system describes the set of digit characters that are to be used to display
48 * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc.
49 * More complicated numbering systems are algorithmic in nature, and require use
50 * of an RBNF formatter ( rule based number formatter ), in order to calculate
51 * the characters to be displayed for a given number. Examples of algorithmic
52 * numbering systems include Roman numerals, Chinese numerals, and Hebrew numerals.
53 * Formatting rules for many commonly used numbering systems are included in
54 * the ICU package, based on the numbering system rules defined in CLDR.
55 * Alternate numbering systems can be specified to a locale by using the
56 * numbers locale keyword.
59 class U_I18N_API NumberingSystem
: public UObject
{
63 * Default Constructor.
73 NumberingSystem(const NumberingSystem
& other
);
79 virtual ~NumberingSystem();
82 * Create the default numbering system associated with the specified locale.
83 * @param inLocale The given locale.
84 * @param status ICU status
87 static NumberingSystem
* U_EXPORT2
createInstance(const Locale
& inLocale
, UErrorCode
& status
);
90 * Create the default numbering system associated with the default locale.
93 static NumberingSystem
* U_EXPORT2
createInstance(UErrorCode
& status
);
96 * Create a numbering system using the specified radix, type, and description.
97 * @param radix The radix (base) for this numbering system.
98 * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric.
99 * @param description The string representing the set of digits used in a numeric system, or the name of the RBNF
100 * ruleset to be used in an algorithmic system.
101 * @param status ICU status
104 static NumberingSystem
* U_EXPORT2
createInstance(int32_t radix
, UBool isAlgorithmic
, const UnicodeString
& description
, UErrorCode
& status
);
107 * Return a StringEnumeration over all the names of numbering systems known to ICU.
111 static StringEnumeration
* U_EXPORT2
getAvailableNames(UErrorCode
& status
);
114 * Create a numbering system from one of the predefined numbering systems known to ICU.
115 * @param name The name of the numbering system.
116 * @param status ICU status
119 static NumberingSystem
* U_EXPORT2
createInstanceByName(const char* name
, UErrorCode
& status
);
123 * Returns the radix of this numbering system.
129 * Returns the name of this numbering system if it was created using one of the predefined names
130 * known to ICU. Otherwise, returns NULL.
133 const char * getName();
136 * Returns the description string of this numbering system, which is either
137 * the string of digits in the case of simple systems, or the ruleset name
138 * in the case of algorithmic systems.
141 virtual UnicodeString
getDescription();
146 * Returns TRUE if the given numbering system is algorithmic
148 * @return TRUE if the numbering system is algorithmic.
149 * Otherwise, return FALSE.
152 UBool
isAlgorithmic() const;
155 * ICU "poor man's RTTI", returns a UClassID for this class.
160 static UClassID U_EXPORT2
getStaticClassID(void);
163 * ICU "poor man's RTTI", returns a UClassID for the actual class.
167 virtual UClassID
getDynamicClassID() const;
174 char name
[NUMSYS_NAME_CAPACITY
+1];
176 void setRadix(int32_t radix
);
178 void setAlgorithmic(UBool algorithmic
);
180 void setDesc(UnicodeString desc
);
182 void setName(const char* name
);
184 static UBool
isValidDigitString(const UnicodeString
&str
);
186 UBool
hasContiguousDecimalDigits() const;
191 #endif /* #if !UCONFIG_NO_FORMATTING */