LEFT | RIGHT |
1 // © 2018 and later: Unicode, Inc. and others. | 1 // © 2018 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 | 3 |
4 // This file is in common instead of i18n because it is needed by ucurr.cpp. | 4 // This file is in common instead of i18n because it is needed by ucurr.cpp. |
5 | 5 |
6 #include "unicode/utypes.h" | 6 #include "unicode/utypes.h" |
7 | 7 |
8 #if !UCONFIG_NO_FORMATTING | 8 #if !UCONFIG_NO_FORMATTING |
9 #ifndef __STATIC_UNICODE_SETS_H__ | 9 #ifndef __STATIC_UNICODE_SETS_H__ |
10 #define __STATIC_UNICODE_SETS_H__ | 10 #define __STATIC_UNICODE_SETS_H__ |
11 | 11 |
12 #include "unicode/uniset.h" | 12 #include "unicode/uniset.h" |
13 #include "unicode/unistr.h" | 13 #include "unicode/unistr.h" |
14 | 14 |
15 U_NAMESPACE_BEGIN | 15 U_NAMESPACE_BEGIN |
16 namespace unisets { | 16 namespace unisets { |
17 | 17 |
18 enum Key { | 18 enum Key { |
19 EMPTY, | 19 // NONE is used to indicate null in chooseFrom(). |
| 20 // EMPTY is used to get an empty UnicodeSet. |
| 21 NONE = -1, |
| 22 EMPTY = 0, |
20 | 23 |
21 // Ignorables | 24 // Ignorables |
22 DEFAULT_IGNORABLES, | 25 DEFAULT_IGNORABLES, |
23 STRICT_IGNORABLES, | 26 STRICT_IGNORABLES, |
24 | 27 |
25 // Separators | 28 // Separators |
26 // Notes: | 29 // Notes: |
27 // - COMMA is a superset of STRICT_COMMA | 30 // - COMMA is a superset of STRICT_COMMA |
28 // - PERIOD is a superset of SCRICT_PERIOD | 31 // - PERIOD is a superset of SCRICT_PERIOD |
29 // - ALL_SEPARATORS is the union of COMMA, PERIOD, and OTHER_GROUPING_SEPARA
TORS | 32 // - ALL_SEPARATORS is the union of COMMA, PERIOD, and OTHER_GROUPING_SEPARA
TORS |
(...skipping 20 matching lines...) Expand all Loading... |
50 YEN_SIGN, // not in CLDR data, but Currency.java wants it | 53 YEN_SIGN, // not in CLDR data, but Currency.java wants it |
51 | 54 |
52 // Other | 55 // Other |
53 DIGITS, | 56 DIGITS, |
54 | 57 |
55 // Combined Separators with Digits (for lead code points) | 58 // Combined Separators with Digits (for lead code points) |
56 DIGITS_OR_ALL_SEPARATORS, | 59 DIGITS_OR_ALL_SEPARATORS, |
57 DIGITS_OR_STRICT_ALL_SEPARATORS, | 60 DIGITS_OR_STRICT_ALL_SEPARATORS, |
58 | 61 |
59 // The number of elements in the enum. | 62 // The number of elements in the enum. |
60 // Also used to indicate null in chooseFrom(). | |
61 COUNT | 63 COUNT |
62 }; | 64 }; |
63 | 65 |
64 /** | 66 /** |
65 * Gets the static-allocated UnicodeSet according to the provided key. The | 67 * Gets the static-allocated UnicodeSet according to the provided key. The |
66 * pointer will be deleted during u_cleanup(); the caller should NOT delete it. | 68 * pointer will be deleted during u_cleanup(); the caller should NOT delete it. |
67 * | 69 * |
68 * Exported as U_COMMON_API for ucurr.cpp | 70 * Exported as U_COMMON_API for ucurr.cpp |
69 * | 71 * |
70 * @param key The desired UnicodeSet according to the enum in this file. | 72 * @param key The desired UnicodeSet according to the enum in this file. |
71 * @return The requested UnicodeSet. Guaranteed to be frozen and non-null, but | 73 * @return The requested UnicodeSet. Guaranteed to be frozen and non-null, but |
72 * may be empty if an error occurred during data loading. | 74 * may be empty if an error occurred during data loading. |
73 */ | 75 */ |
74 U_COMMON_API const UnicodeSet* get(Key key); | 76 U_COMMON_API const UnicodeSet* get(Key key); |
75 | 77 |
76 /** | 78 /** |
77 * Checks if the UnicodeSet given by key1 contains the given string. | 79 * Checks if the UnicodeSet given by key1 contains the given string. |
78 * | 80 * |
79 * Exported as U_COMMON_API for numparse_decimal.cpp | 81 * Exported as U_COMMON_API for numparse_decimal.cpp |
80 * | 82 * |
81 * @param str The string to check. | 83 * @param str The string to check. |
82 * @param key1 The set to check. | 84 * @param key1 The set to check. |
83 * @return key1 if the set contains str, or COUNT if not. | 85 * @return key1 if the set contains str, or NONE if not. |
84 */ | 86 */ |
85 U_COMMON_API Key chooseFrom(UnicodeString str, Key key1); | 87 U_COMMON_API Key chooseFrom(UnicodeString str, Key key1); |
86 | 88 |
87 /** | 89 /** |
88 * Checks if the UnicodeSet given by either key1 or key2 contains the string. | 90 * Checks if the UnicodeSet given by either key1 or key2 contains the string. |
89 * | 91 * |
90 * Exported as U_COMMON_API for numparse_decimal.cpp | 92 * Exported as U_COMMON_API for numparse_decimal.cpp |
91 * | 93 * |
92 * @param str The string to check. | 94 * @param str The string to check. |
93 * @param key1 The first set to check. | 95 * @param key1 The first set to check. |
94 * @param key2 The second set to check. | 96 * @param key2 The second set to check. |
95 * @return key1 if that set contains str; key2 if that set contains str; or | 97 * @return key1 if that set contains str; key2 if that set contains str; or |
96 * COUNT if neither set contains str. | 98 * NONE if neither set contains str. |
97 */ | 99 */ |
98 U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2); | 100 U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2); |
99 | 101 |
100 // Unused in C++: | 102 // Unused in C++: |
101 // Key chooseCurrency(UnicodeString str); | 103 // Key chooseCurrency(UnicodeString str); |
102 // Used instead: | 104 // Used instead: |
103 static const struct { | 105 static const struct { |
104 Key key; | 106 Key key; |
105 UChar32 exemplar; | 107 UChar32 exemplar; |
106 } kCurrencyEntries[] = { | 108 } kCurrencyEntries[] = { |
107 {DOLLAR_SIGN, u'$'}, | 109 {DOLLAR_SIGN, u'$'}, |
108 {POUND_SIGN, u'£'}, | 110 {POUND_SIGN, u'£'}, |
109 {RUPEE_SIGN, u'₨'}, | 111 {RUPEE_SIGN, u'₨'}, |
110 {YEN_SIGN, u'¥'}, | 112 {YEN_SIGN, u'¥'}, |
111 }; | 113 }; |
112 | 114 |
113 } // namespace unisets | 115 } // namespace unisets |
114 U_NAMESPACE_END | 116 U_NAMESPACE_END |
115 | 117 |
116 #endif //__STATIC_UNICODE_SETS_H__ | 118 #endif //__STATIC_UNICODE_SETS_H__ |
117 #endif /* #if !UCONFIG_NO_FORMATTING */ | 119 #endif /* #if !UCONFIG_NO_FORMATTING */ |
LEFT | RIGHT |