intl/icu/source/i18n/unicode/numsys.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     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 */
    16 #ifndef NUMSYS
    17 #define NUMSYS
    19 #include "unicode/utypes.h"
    21 /**
    22  * \def NUMSYS_NAME_CAPACITY
    23  * Size of a numbering system name.
    24  * @internal
    25  */
    26 #define NUMSYS_NAME_CAPACITY 8
    29 /**
    30  * \file
    31  * \brief C++ API: NumberingSystem object
    32  */
    34 #if !UCONFIG_NO_FORMATTING
    37 #include "unicode/format.h"
    38 #include "unicode/uobject.h"
    40 U_NAMESPACE_BEGIN
    42 /**
    43  * Defines numbering systems. A numbering system describes the scheme by which 
    44  * numbers are to be presented to the end user.  In its simplest form, a numbering
    45  * system describes the set of digit characters that are to be used to display
    46  * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc., in a
    47  * positional numbering system with a specified radix (typically 10).
    48  * More complicated numbering systems are algorithmic in nature, and require use
    49  * of an RBNF formatter ( rule based number formatter ), in order to calculate
    50  * the characters to be displayed for a given number.  Examples of algorithmic
    51  * numbering systems include Roman numerals, Chinese numerals, and Hebrew numerals.
    52  * Formatting rules for many commonly used numbering systems are included in
    53  * the ICU package, based on the numbering system rules defined in CLDR.
    54  * Alternate numbering systems can be specified to a locale by using the
    55  * numbers locale keyword.
    56  */
    58 class U_I18N_API NumberingSystem : public UObject {
    59 public:
    61     /**
    62      * Default Constructor.
    63      *
    64      * @stable ICU 4.2
    65      */
    66     NumberingSystem();
    68     /**
    69      * Copy constructor.
    70      * @stable ICU 4.2
    71      */
    72     NumberingSystem(const NumberingSystem& other);
    74     /**
    75      * Destructor.
    76      * @stable ICU 4.2
    77      */
    78     virtual ~NumberingSystem();
    80     /**
    81      * Create the default numbering system associated with the specified locale.
    82      * @param inLocale The given locale.
    83      * @param status ICU status
    84      * @stable ICU 4.2
    85      */
    86     static NumberingSystem* U_EXPORT2 createInstance(const Locale & inLocale, UErrorCode& status);
    88     /**
    89      * Create the default numbering system associated with the default locale.
    90      * @stable ICU 4.2
    91      */
    92     static NumberingSystem* U_EXPORT2 createInstance(UErrorCode& status);
    94     /**
    95      * Create a numbering system using the specified radix, type, and description. 
    96      * @param radix         The radix (base) for this numbering system.
    97      * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric.
    98      * @param description   The string representing the set of digits used in a numeric system, or the name of the RBNF
    99      *                      ruleset to be used in an algorithmic system.
   100      * @param status ICU status
   101      * @stable ICU 4.2
   102      */
   103     static NumberingSystem* U_EXPORT2 createInstance(int32_t radix, UBool isAlgorithmic, const UnicodeString& description, UErrorCode& status );
   105     /**
   106      * Return a StringEnumeration over all the names of numbering systems known to ICU.
   107      * @stable ICU 4.2
   108      */
   110      static StringEnumeration * U_EXPORT2 getAvailableNames(UErrorCode& status);
   112     /**
   113      * Create a numbering system from one of the predefined numbering systems specified
   114      * by CLDR and known to ICU, such as "latn", "arabext", or "hanidec"; the full list
   115      * is returned by unumsys_openAvailableNames. Note that some of the names listed at
   116      * http://unicode.org/repos/cldr/tags/latest/common/bcp47/number.xml - e.g.
   117      * default, native, traditional, finance - do not identify specific numbering systems,
   118      * but rather key values that may only be used as part of a locale, which in turn
   119      * defines how they are mapped to a specific numbering system such as "latn" or "hant".
   120      * @param name   The name of the numbering system.
   121      * @param status ICU status
   122      * @stable ICU 4.2
   123      */
   124     static NumberingSystem* U_EXPORT2 createInstanceByName(const char* name, UErrorCode& status);
   127     /**
   128      * Returns the radix of this numbering system. Simple positional numbering systems
   129      * typically have radix 10, but might have a radix of e.g. 16 for hexadecimal. The
   130      * radix is less well-defined for non-positional algorithmic systems.
   131      * @stable ICU 4.2
   132      */
   133     int32_t getRadix() const;
   135     /**
   136      * Returns the name of this numbering system if it was created using one of the predefined names
   137      * known to ICU.  Otherwise, returns NULL.
   138      * @stable ICU 4.6
   139      */
   140     const char * getName() const;
   142     /**
   143      * Returns the description string of this numbering system. For simple
   144      * positional systems this is the ordered string of digits (with length matching
   145      * the radix), e.g. "\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D"
   146      * for "hanidec"; it would be "0123456789ABCDEF" for hexadecimal. For
   147      * algorithmic systems this is the name of the RBNF ruleset used for formatting,
   148      * e.g. "zh/SpelloutRules/%spellout-cardinal" for "hans" or "%greek-upper" for
   149      * "grek".
   150      * @stable ICU 4.2
   151      */
   152     virtual UnicodeString getDescription() const;
   156     /**
   157      * Returns TRUE if the given numbering system is algorithmic
   158      *
   159      * @return         TRUE if the numbering system is algorithmic.
   160      *                 Otherwise, return FALSE.
   161      * @stable ICU 4.2
   162      */
   163     UBool isAlgorithmic() const;
   165     /**
   166      * ICU "poor man's RTTI", returns a UClassID for this class.
   167      *
   168      * @stable ICU 4.2
   169      *
   170     */
   171     static UClassID U_EXPORT2 getStaticClassID(void);
   173     /**
   174      * ICU "poor man's RTTI", returns a UClassID for the actual class.
   175      *
   176      * @stable ICU 4.2
   177      */
   178     virtual UClassID getDynamicClassID() const;
   181 private:
   182     UnicodeString   desc;
   183     int32_t         radix;
   184     UBool           algorithmic;
   185     char            name[NUMSYS_NAME_CAPACITY+1];
   187     void setRadix(int32_t radix);
   189     void setAlgorithmic(UBool algorithmic);
   191     void setDesc(UnicodeString desc);
   193     void setName(const char* name);
   195     static UBool isValidDigitString(const UnicodeString &str);
   197     UBool hasContiguousDecimalDigits() const;
   198 };
   200 U_NAMESPACE_END
   202 #endif /* #if !UCONFIG_NO_FORMATTING */
   204 #endif // _NUMSYS
   205 //eof

mercurial