]>
Commit | Line | Data |
---|---|---|
0f5d89e8 A |
1 | // © 2018 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
3 | ||
4 | #include "unicode/utypes.h" | |
5 | ||
6 | #if !UCONFIG_NO_FORMATTING | |
7 | #ifndef __NUMPARSE_CURRENCY_H__ | |
8 | #define __NUMPARSE_CURRENCY_H__ | |
9 | ||
10 | #include "numparse_types.h" | |
11 | #include "numparse_compositions.h" | |
12 | #include "charstr.h" | |
13 | #include "number_currencysymbols.h" | |
14 | #include "unicode/uniset.h" | |
15 | ||
16 | U_NAMESPACE_BEGIN namespace numparse { | |
17 | namespace impl { | |
18 | ||
19 | using ::icu::number::impl::CurrencySymbols; | |
20 | ||
21 | /** | |
22 | * Matches a currency, either a custom currency or one from the data bundle. The class is called | |
23 | * "combined" to emphasize that the currency string may come from one of multiple sources. | |
24 | * | |
25 | * Will match currency spacing either before or after the number depending on whether we are currently in | |
26 | * the prefix or suffix. | |
27 | * | |
28 | * The implementation of this class is slightly different between J and C. See #13584 for a follow-up. | |
29 | * | |
30 | * @author sffc | |
31 | */ | |
32 | // Exported as U_I18N_API for tests | |
33 | class U_I18N_API CombinedCurrencyMatcher : public NumberParseMatcher, public UMemory { | |
34 | public: | |
35 | CombinedCurrencyMatcher() = default; // WARNING: Leaves the object in an unusable state | |
36 | ||
37 | CombinedCurrencyMatcher(const CurrencySymbols& currencySymbols, const DecimalFormatSymbols& dfs, | |
38 | parse_flags_t parseFlags, UErrorCode& status); | |
39 | ||
40 | bool match(StringSegment& segment, ParsedNumber& result, UErrorCode& status) const override; | |
41 | ||
42 | bool smokeTest(const StringSegment& segment) const override; | |
43 | ||
44 | UnicodeString toString() const override; | |
45 | ||
46 | private: | |
47 | UChar fCurrencyCode[4]; | |
48 | UnicodeString fCurrency1; | |
49 | UnicodeString fCurrency2; | |
50 | ||
51 | bool fUseFullCurrencyData; | |
c5116b9f | 52 | bool fCurrencyTrails; // Apple <rdar://problem/51938595> |
0f5d89e8 A |
53 | UnicodeString fLocalLongNames[StandardPlural::COUNT]; |
54 | ||
55 | UnicodeString afterPrefixInsert; | |
56 | UnicodeString beforeSuffixInsert; | |
57 | ||
58 | // We could use Locale instead of CharString here, but | |
59 | // Locale has a non-trivial default constructor. | |
60 | CharString fLocaleName; | |
61 | ||
62 | // TODO: See comments in constructor in numparse_currency.cpp | |
63 | // UnicodeSet fLeadCodePoints; | |
64 | ||
65 | /** Matches the currency string without concern for currency spacing. */ | |
66 | bool matchCurrency(StringSegment& segment, ParsedNumber& result, UErrorCode& status) const; | |
67 | }; | |
68 | ||
69 | ||
70 | } // namespace impl | |
71 | } // namespace numparse | |
72 | U_NAMESPACE_END | |
73 | ||
74 | #endif //__NUMPARSE_CURRENCY_H__ | |
75 | #endif /* #if !UCONFIG_NO_FORMATTING */ |