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 __SOURCE_NUMPARSE_VALIDATORS_H__
8 #define __SOURCE_NUMPARSE_VALIDATORS_H__
10 #include "numparse_types.h"
11 #include "static_unicode_sets.h"
13 U_NAMESPACE_BEGIN
namespace numparse
{
17 class ValidationMatcher
: public NumberParseMatcher
{
19 bool match(StringSegment
&, ParsedNumber
&, UErrorCode
&) const U_OVERRIDE
{
24 bool smokeTest(const StringSegment
&) const U_OVERRIDE
{
29 void postProcess(ParsedNumber
& result
) const U_OVERRIDE
= 0;
33 class RequireAffixValidator
: public ValidationMatcher
, public UMemory
{
35 void postProcess(ParsedNumber
& result
) const U_OVERRIDE
;
37 UnicodeString
toString() const U_OVERRIDE
;
41 class RequireCurrencyValidator
: public ValidationMatcher
, public UMemory
{
43 void postProcess(ParsedNumber
& result
) const U_OVERRIDE
;
45 UnicodeString
toString() const U_OVERRIDE
;
49 class RequireDecimalSeparatorValidator
: public ValidationMatcher
, public UMemory
{
51 RequireDecimalSeparatorValidator() = default; // leaves instance in valid but undefined state
53 RequireDecimalSeparatorValidator(bool patternHasDecimalSeparator
);
55 void postProcess(ParsedNumber
& result
) const U_OVERRIDE
;
57 UnicodeString
toString() const U_OVERRIDE
;
60 bool fPatternHasDecimalSeparator
;
64 class RequireNumberValidator
: public ValidationMatcher
, public UMemory
{
66 void postProcess(ParsedNumber
& result
) const U_OVERRIDE
;
68 UnicodeString
toString() const U_OVERRIDE
;
73 * Wraps a {@link Multiplier} for use in the number parsing pipeline.
75 class MultiplierParseHandler
: public ValidationMatcher
, public UMemory
{
77 MultiplierParseHandler() = default; // leaves instance in valid but undefined state
79 MultiplierParseHandler(::icu::number::Scale multiplier
);
81 void postProcess(ParsedNumber
& result
) const U_OVERRIDE
;
83 UnicodeString
toString() const U_OVERRIDE
;
86 ::icu::number::Scale fMultiplier
;
91 } // namespace numparse
94 #endif //__SOURCE_NUMPARSE_VALIDATORS_H__
95 #endif /* #if !UCONFIG_NO_FORMATTING */