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 UnicodeString fLocalLongNames
[StandardPlural::COUNT
];
54 UnicodeString afterPrefixInsert
;
55 UnicodeString beforeSuffixInsert
;
57 // We could use Locale instead of CharString here, but
58 // Locale has a non-trivial default constructor.
59 CharString fLocaleName
;
61 // TODO: See comments in constructor in numparse_currency.cpp
62 // UnicodeSet fLeadCodePoints;
64 /** Matches the currency string without concern for currency spacing. */
65 bool matchCurrency(StringSegment
& segment
, ParsedNumber
& result
, UErrorCode
& status
) const;
70 } // namespace numparse
73 #endif //__NUMPARSE_CURRENCY_H__
74 #endif /* #if !UCONFIG_NO_FORMATTING */