1 // © 2018 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 #include "unicode/utypes.h"
6 #if !UCONFIG_NO_FORMATTING
7 #ifndef __NUMPARSE_CURRENCY_H__
8 #define __NUMPARSE_CURRENCY_H__
10 #include "numparse_types.h"
11 #include "numparse_compositions.h"
13 #include "number_currencysymbols.h"
14 #include "unicode/uniset.h"
16 U_NAMESPACE_BEGIN
namespace numparse
{
19 using ::icu::number::impl::CurrencySymbols
;
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.
25 * Will match currency spacing either before or after the number depending on whether we are currently in
26 * the prefix or suffix.
28 * The implementation of this class is slightly different between J and C. See #13584 for a follow-up.
32 // Exported as U_I18N_API for tests
33 class U_I18N_API CombinedCurrencyMatcher
: public NumberParseMatcher
, public UMemory
{
35 CombinedCurrencyMatcher() = default; // WARNING: Leaves the object in an unusable state
37 CombinedCurrencyMatcher(const CurrencySymbols
& currencySymbols
, const DecimalFormatSymbols
& dfs
,
38 parse_flags_t parseFlags
, UErrorCode
& status
);
40 bool match(StringSegment
& segment
, ParsedNumber
& result
, UErrorCode
& status
) const override
;
42 bool smokeTest(const StringSegment
& segment
) const override
;
44 UnicodeString
toString() const override
;
47 UChar fCurrencyCode
[4];
48 UnicodeString fCurrency1
;
49 UnicodeString fCurrency2
;
51 bool fUseFullCurrencyData
;
52 bool fCurrencyTrails
; // Apple <rdar://problem/51938595>
53 UnicodeString fLocalLongNames
[StandardPlural::COUNT
];
55 UnicodeString afterPrefixInsert
;
56 UnicodeString beforeSuffixInsert
;
58 // We could use Locale instead of CharString here, but
59 // Locale has a non-trivial default constructor.
60 CharString fLocaleName
;
62 // TODO: See comments in constructor in numparse_currency.cpp
63 // UnicodeSet fLeadCodePoints;
65 /** Matches the currency string without concern for currency spacing. */
66 bool matchCurrency(StringSegment
& segment
, ParsedNumber
& result
, UErrorCode
& status
) const;
71 } // namespace numparse
74 #endif //__NUMPARSE_CURRENCY_H__
75 #endif /* #if !UCONFIG_NO_FORMATTING */