1/*
2*******************************************************************************
3* Copyright (C) 2010-2013, 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#include "unicode/utypes.h"
20
21#ifndef U_HIDE_INTERNAL_API
22/**
23 * \def NUMSYS_NAME_CAPACITY
24 * Size of a numbering system name.
25 * @internal
26 */
27#define NUMSYS_NAME_CAPACITY 8
28#endif  /* U_HIDE_INTERNAL_API */
29
30
31/**
32 * \file
33 * \brief C++ API: NumberingSystem object
34 */
35
36#if !UCONFIG_NO_FORMATTING
37
38
39#include "unicode/format.h"
40#include "unicode/uobject.h"
41
42U_NAMESPACE_BEGIN
43
44/**
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.
57 */
58
59class U_I18N_API NumberingSystem : public UObject {
60public:
61
62    /**
63     * Default Constructor.
64     *
65     * @stable ICU 4.2
66     */
67    NumberingSystem();
68
69    /**
70     * Copy constructor.
71     * @stable ICU 4.2
72     */
73    NumberingSystem(const NumberingSystem& other);
74
75    /**
76     * Destructor.
77     * @stable ICU 4.2
78     */
79    virtual ~NumberingSystem();
80
81    /**
82     * Create the default numbering system associated with the specified locale.
83     * @param inLocale The given locale.
84     * @param status ICU status
85     * @stable ICU 4.2
86     */
87    static NumberingSystem* U_EXPORT2 createInstance(const Locale & inLocale, UErrorCode& status);
88
89    /**
90     * Create the default numbering system associated with the default locale.
91     * @stable ICU 4.2
92     */
93    static NumberingSystem* U_EXPORT2 createInstance(UErrorCode& status);
94
95    /**
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
102     * @stable ICU 4.2
103     */
104    static NumberingSystem* U_EXPORT2 createInstance(int32_t radix, UBool isAlgorithmic, const UnicodeString& description, UErrorCode& status );
105
106    /**
107     * Return a StringEnumeration over all the names of numbering systems known to ICU.
108     * @stable ICU 4.2
109     */
110
111     static StringEnumeration * U_EXPORT2 getAvailableNames(UErrorCode& status);
112
113    /**
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
117     * @stable ICU 4.2
118     */
119    static NumberingSystem* U_EXPORT2 createInstanceByName(const char* name, UErrorCode& status);
120
121
122    /**
123     * Returns the radix of this numbering system.
124     * @stable ICU 4.2
125     */
126    int32_t getRadix();
127
128    /**
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.
131     * @stable ICU 4.6
132     */
133    const char * getName();
134
135    /**
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.
139     * @stable ICU 4.2
140     */
141    virtual UnicodeString getDescription();
142
143
144
145    /**
146     * Returns TRUE if the given numbering system is algorithmic
147     *
148     * @return         TRUE if the numbering system is algorithmic.
149     *                 Otherwise, return FALSE.
150     * @stable ICU 4.2
151     */
152    UBool isAlgorithmic() const;
153
154    /**
155     * ICU "poor man's RTTI", returns a UClassID for this class.
156     *
157     * @stable ICU 4.2
158     *
159    */
160    static UClassID U_EXPORT2 getStaticClassID(void);
161
162    /**
163     * ICU "poor man's RTTI", returns a UClassID for the actual class.
164     *
165     * @stable ICU 4.2
166     */
167    virtual UClassID getDynamicClassID() const;
168
169
170private:
171    UnicodeString   desc;
172    int32_t         radix;
173    UBool           algorithmic;
174    char            name[NUMSYS_NAME_CAPACITY+1];
175
176    void setRadix(int32_t radix);
177
178    void setAlgorithmic(UBool algorithmic);
179
180    void setDesc(UnicodeString desc);
181
182    void setName(const char* name);
183
184    static UBool isValidDigitString(const UnicodeString &str);
185
186    UBool hasContiguousDecimalDigits() const;
187};
188
189U_NAMESPACE_END
190
191#endif /* #if !UCONFIG_NO_FORMATTING */
192
193#endif // _NUMSYS
194//eof
195