]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/numsys.h
ICU-491.11.2.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / numsys.h
1 /*
2 *******************************************************************************
3 * Copyright (C) 2010-2011, 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 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.
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, UErrorCode& 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 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
99 * @stable ICU 4.2
100 */
101 static NumberingSystem* U_EXPORT2 createInstance(int32_t radix, UBool isAlgorithmic, 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 known 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, UErrorCode& status);
117
118
119 /**
120 * Returns the radix of this numbering system.
121 * @stable ICU 4.2
122 */
123 int32_t getRadix();
124
125 #ifndef U_HIDE_DRAFT_API
126 /**
127 * Returns the name of this numbering system if it was created using one of the predefined names
128 * known to ICU. Otherwise, returns NULL.
129 * @draft ICU 4.6
130 */
131 const char * getName();
132 #endif /* U_HIDE_DRAFT_API */
133
134 /**
135 * Returns the description string of this numbering system, which is either
136 * the string of digits in the case of simple systems, or the ruleset name
137 * in the case of algorithmic systems.
138 * @stable ICU 4.2
139 */
140 virtual UnicodeString getDescription();
141
142
143
144 /**
145 * Returns TRUE if the given numbering system is algorithmic
146 *
147 * @return TRUE if the numbering system is algorithmic.
148 * Otherwise, return FALSE.
149 * @stable ICU 4.2
150 */
151 UBool isAlgorithmic() const;
152
153 /**
154 * ICU "poor man's RTTI", returns a UClassID for this class.
155 *
156 * @stable ICU 4.2
157 *
158 */
159 static UClassID U_EXPORT2 getStaticClassID(void);
160
161 /**
162 * ICU "poor man's RTTI", returns a UClassID for the actual class.
163 *
164 * @stable ICU 4.2
165 */
166 virtual UClassID getDynamicClassID() const;
167
168
169 private:
170 UnicodeString desc;
171 int32_t radix;
172 UBool algorithmic;
173 char name[NUMSYS_NAME_CAPACITY+1];
174
175 void setRadix(int32_t radix);
176
177 void setAlgorithmic(UBool algorithmic);
178
179 void setDesc(UnicodeString desc);
180
181 void setName(const char* name);
182
183 static UBool isValidDigitString(const UnicodeString &str);
184
185 UBool hasContiguousDecimalDigits() const;
186 };
187
188 U_NAMESPACE_END
189
190 #endif /* #if !UCONFIG_NO_FORMATTING */
191
192 #endif // _NUMSYS
193 //eof