annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/numsys.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // © 2016 and later: Unicode, Inc. and others.
jpayne@69 2 // License & terms of use: http://www.unicode.org/copyright.html
jpayne@69 3 /*
jpayne@69 4 *******************************************************************************
jpayne@69 5 * Copyright (C) 2010-2014, International Business Machines Corporation and
jpayne@69 6 * others. All Rights Reserved.
jpayne@69 7 *******************************************************************************
jpayne@69 8 *
jpayne@69 9 *
jpayne@69 10 * File NUMSYS.H
jpayne@69 11 *
jpayne@69 12 * Modification History:*
jpayne@69 13 * Date Name Description
jpayne@69 14 *
jpayne@69 15 ********************************************************************************
jpayne@69 16 */
jpayne@69 17
jpayne@69 18 #ifndef NUMSYS
jpayne@69 19 #define NUMSYS
jpayne@69 20
jpayne@69 21 #include "unicode/utypes.h"
jpayne@69 22
jpayne@69 23 #if U_SHOW_CPLUSPLUS_API
jpayne@69 24
jpayne@69 25 /**
jpayne@69 26 * \file
jpayne@69 27 * \brief C++ API: NumberingSystem object
jpayne@69 28 */
jpayne@69 29
jpayne@69 30 #if !UCONFIG_NO_FORMATTING
jpayne@69 31
jpayne@69 32 #include "unicode/format.h"
jpayne@69 33 #include "unicode/uobject.h"
jpayne@69 34
jpayne@69 35 U_NAMESPACE_BEGIN
jpayne@69 36
jpayne@69 37 // can't be #ifndef U_HIDE_INTERNAL_API; needed for char[] field size
jpayne@69 38 /**
jpayne@69 39 * Size of a numbering system name.
jpayne@69 40 * @internal
jpayne@69 41 */
jpayne@69 42 constexpr const size_t kInternalNumSysNameCapacity = 8;
jpayne@69 43
jpayne@69 44 /**
jpayne@69 45 * Defines numbering systems. A numbering system describes the scheme by which
jpayne@69 46 * numbers are to be presented to the end user. In its simplest form, a numbering
jpayne@69 47 * system describes the set of digit characters that are to be used to display
jpayne@69 48 * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc., in a
jpayne@69 49 * positional numbering system with a specified radix (typically 10).
jpayne@69 50 * More complicated numbering systems are algorithmic in nature, and require use
jpayne@69 51 * of an RBNF formatter ( rule based number formatter ), in order to calculate
jpayne@69 52 * the characters to be displayed for a given number. Examples of algorithmic
jpayne@69 53 * numbering systems include Roman numerals, Chinese numerals, and Hebrew numerals.
jpayne@69 54 * Formatting rules for many commonly used numbering systems are included in
jpayne@69 55 * the ICU package, based on the numbering system rules defined in CLDR.
jpayne@69 56 * Alternate numbering systems can be specified to a locale by using the
jpayne@69 57 * numbers locale keyword.
jpayne@69 58 */
jpayne@69 59
jpayne@69 60 class U_I18N_API NumberingSystem : public UObject {
jpayne@69 61 public:
jpayne@69 62
jpayne@69 63 /**
jpayne@69 64 * Default Constructor.
jpayne@69 65 *
jpayne@69 66 * @stable ICU 4.2
jpayne@69 67 */
jpayne@69 68 NumberingSystem();
jpayne@69 69
jpayne@69 70 /**
jpayne@69 71 * Copy constructor.
jpayne@69 72 * @stable ICU 4.2
jpayne@69 73 */
jpayne@69 74 NumberingSystem(const NumberingSystem& other);
jpayne@69 75
jpayne@69 76 /**
jpayne@69 77 * Copy assignment.
jpayne@69 78 * @stable ICU 4.2
jpayne@69 79 */
jpayne@69 80 NumberingSystem& operator=(const NumberingSystem& other) = default;
jpayne@69 81
jpayne@69 82 /**
jpayne@69 83 * Destructor.
jpayne@69 84 * @stable ICU 4.2
jpayne@69 85 */
jpayne@69 86 virtual ~NumberingSystem();
jpayne@69 87
jpayne@69 88 /**
jpayne@69 89 * Create the default numbering system associated with the specified locale.
jpayne@69 90 * @param inLocale The given locale.
jpayne@69 91 * @param status ICU status
jpayne@69 92 * @stable ICU 4.2
jpayne@69 93 */
jpayne@69 94 static NumberingSystem* U_EXPORT2 createInstance(const Locale & inLocale, UErrorCode& status);
jpayne@69 95
jpayne@69 96 /**
jpayne@69 97 * Create the default numbering system associated with the default locale.
jpayne@69 98 * @stable ICU 4.2
jpayne@69 99 */
jpayne@69 100 static NumberingSystem* U_EXPORT2 createInstance(UErrorCode& status);
jpayne@69 101
jpayne@69 102 /**
jpayne@69 103 * Create a numbering system using the specified radix, type, and description.
jpayne@69 104 * @param radix The radix (base) for this numbering system.
jpayne@69 105 * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric.
jpayne@69 106 * @param description The string representing the set of digits used in a numeric system, or the name of the RBNF
jpayne@69 107 * ruleset to be used in an algorithmic system.
jpayne@69 108 * @param status ICU status
jpayne@69 109 * @stable ICU 4.2
jpayne@69 110 */
jpayne@69 111 static NumberingSystem* U_EXPORT2 createInstance(int32_t radix, UBool isAlgorithmic, const UnicodeString& description, UErrorCode& status );
jpayne@69 112
jpayne@69 113 /**
jpayne@69 114 * Return a StringEnumeration over all the names of numbering systems known to ICU.
jpayne@69 115 * The numbering system names will be in alphabetical (invariant) order.
jpayne@69 116 *
jpayne@69 117 * The returned StringEnumeration is owned by the caller, who must delete it when
jpayne@69 118 * finished with it.
jpayne@69 119 *
jpayne@69 120 * @stable ICU 4.2
jpayne@69 121 */
jpayne@69 122 static StringEnumeration * U_EXPORT2 getAvailableNames(UErrorCode& status);
jpayne@69 123
jpayne@69 124 /**
jpayne@69 125 * Create a numbering system from one of the predefined numbering systems specified
jpayne@69 126 * by CLDR and known to ICU, such as "latn", "arabext", or "hanidec"; the full list
jpayne@69 127 * is returned by unumsys_openAvailableNames. Note that some of the names listed at
jpayne@69 128 * http://unicode.org/repos/cldr/tags/latest/common/bcp47/number.xml - e.g.
jpayne@69 129 * default, native, traditional, finance - do not identify specific numbering systems,
jpayne@69 130 * but rather key values that may only be used as part of a locale, which in turn
jpayne@69 131 * defines how they are mapped to a specific numbering system such as "latn" or "hant".
jpayne@69 132 *
jpayne@69 133 * @param name The name of the numbering system.
jpayne@69 134 * @param status ICU status; set to U_UNSUPPORTED_ERROR if numbering system not found.
jpayne@69 135 * @return The NumberingSystem instance, or nullptr if not found.
jpayne@69 136 * @stable ICU 4.2
jpayne@69 137 */
jpayne@69 138 static NumberingSystem* U_EXPORT2 createInstanceByName(const char* name, UErrorCode& status);
jpayne@69 139
jpayne@69 140
jpayne@69 141 /**
jpayne@69 142 * Returns the radix of this numbering system. Simple positional numbering systems
jpayne@69 143 * typically have radix 10, but might have a radix of e.g. 16 for hexadecimal. The
jpayne@69 144 * radix is less well-defined for non-positional algorithmic systems.
jpayne@69 145 * @stable ICU 4.2
jpayne@69 146 */
jpayne@69 147 int32_t getRadix() const;
jpayne@69 148
jpayne@69 149 /**
jpayne@69 150 * Returns the name of this numbering system if it was created using one of the predefined names
jpayne@69 151 * known to ICU. Otherwise, returns NULL.
jpayne@69 152 * The predefined names are identical to the numbering system names as defined by
jpayne@69 153 * the BCP47 definition in Unicode CLDR.
jpayne@69 154 * See also, http://www.unicode.org/repos/cldr/tags/latest/common/bcp47/number.xml
jpayne@69 155 * @stable ICU 4.6
jpayne@69 156 */
jpayne@69 157 const char * getName() const;
jpayne@69 158
jpayne@69 159 /**
jpayne@69 160 * Returns the description string of this numbering system. For simple
jpayne@69 161 * positional systems this is the ordered string of digits (with length matching
jpayne@69 162 * the radix), e.g. "\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D"
jpayne@69 163 * for "hanidec"; it would be "0123456789ABCDEF" for hexadecimal. For
jpayne@69 164 * algorithmic systems this is the name of the RBNF ruleset used for formatting,
jpayne@69 165 * e.g. "zh/SpelloutRules/%spellout-cardinal" for "hans" or "%greek-upper" for
jpayne@69 166 * "grek".
jpayne@69 167 * @stable ICU 4.2
jpayne@69 168 */
jpayne@69 169 virtual UnicodeString getDescription() const;
jpayne@69 170
jpayne@69 171
jpayne@69 172
jpayne@69 173 /**
jpayne@69 174 * Returns TRUE if the given numbering system is algorithmic
jpayne@69 175 *
jpayne@69 176 * @return TRUE if the numbering system is algorithmic.
jpayne@69 177 * Otherwise, return FALSE.
jpayne@69 178 * @stable ICU 4.2
jpayne@69 179 */
jpayne@69 180 UBool isAlgorithmic() const;
jpayne@69 181
jpayne@69 182 /**
jpayne@69 183 * ICU "poor man's RTTI", returns a UClassID for this class.
jpayne@69 184 *
jpayne@69 185 * @stable ICU 4.2
jpayne@69 186 *
jpayne@69 187 */
jpayne@69 188 static UClassID U_EXPORT2 getStaticClassID(void);
jpayne@69 189
jpayne@69 190 /**
jpayne@69 191 * ICU "poor man's RTTI", returns a UClassID for the actual class.
jpayne@69 192 *
jpayne@69 193 * @stable ICU 4.2
jpayne@69 194 */
jpayne@69 195 virtual UClassID getDynamicClassID() const;
jpayne@69 196
jpayne@69 197
jpayne@69 198 private:
jpayne@69 199 UnicodeString desc;
jpayne@69 200 int32_t radix;
jpayne@69 201 UBool algorithmic;
jpayne@69 202 char name[kInternalNumSysNameCapacity+1];
jpayne@69 203
jpayne@69 204 void setRadix(int32_t radix);
jpayne@69 205
jpayne@69 206 void setAlgorithmic(UBool algorithmic);
jpayne@69 207
jpayne@69 208 void setDesc(const UnicodeString &desc);
jpayne@69 209
jpayne@69 210 void setName(const char* name);
jpayne@69 211
jpayne@69 212 static UBool isValidDigitString(const UnicodeString &str);
jpayne@69 213
jpayne@69 214 UBool hasContiguousDecimalDigits() const;
jpayne@69 215 };
jpayne@69 216
jpayne@69 217 U_NAMESPACE_END
jpayne@69 218
jpayne@69 219 #endif /* #if !UCONFIG_NO_FORMATTING */
jpayne@69 220
jpayne@69 221 #endif /* U_SHOW_CPLUSPLUS_API */
jpayne@69 222
jpayne@69 223 #endif // _NUMSYS
jpayne@69 224 //eof