]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/numparse_validators.h
ICU-64243.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / numparse_validators.h
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 __SOURCE_NUMPARSE_VALIDATORS_H__
8 #define __SOURCE_NUMPARSE_VALIDATORS_H__
9
10 #include "numparse_types.h"
11 #include "static_unicode_sets.h"
12
13 U_NAMESPACE_BEGIN namespace numparse {
14 namespace impl {
15
16
17 class ValidationMatcher : public NumberParseMatcher {
18 public:
19 bool match(StringSegment&, ParsedNumber&, UErrorCode&) const U_OVERRIDE {
20 // No-op
21 return false;
22 }
23
24 bool smokeTest(const StringSegment&) const U_OVERRIDE {
25 // No-op
26 return false;
27 }
28
29 void postProcess(ParsedNumber& result) const U_OVERRIDE = 0;
30 };
31
32
33 class RequireAffixValidator : public ValidationMatcher, public UMemory {
34 public:
35 void postProcess(ParsedNumber& result) const U_OVERRIDE;
36
37 UnicodeString toString() const U_OVERRIDE;
38 };
39
40
41 class RequireCurrencyValidator : public ValidationMatcher, public UMemory {
42 public:
43 void postProcess(ParsedNumber& result) const U_OVERRIDE;
44
45 UnicodeString toString() const U_OVERRIDE;
46 };
47
48
49 class RequireDecimalSeparatorValidator : public ValidationMatcher, public UMemory {
50 public:
51 RequireDecimalSeparatorValidator() = default; // leaves instance in valid but undefined state
52
53 RequireDecimalSeparatorValidator(bool patternHasDecimalSeparator);
54
55 void postProcess(ParsedNumber& result) const U_OVERRIDE;
56
57 UnicodeString toString() const U_OVERRIDE;
58
59 private:
60 bool fPatternHasDecimalSeparator;
61 };
62
63
64 class RequireNumberValidator : public ValidationMatcher, public UMemory {
65 public:
66 void postProcess(ParsedNumber& result) const U_OVERRIDE;
67
68 UnicodeString toString() const U_OVERRIDE;
69 };
70
71
72 /**
73 * Wraps a {@link Multiplier} for use in the number parsing pipeline.
74 */
75 class MultiplierParseHandler : public ValidationMatcher, public UMemory {
76 public:
77 MultiplierParseHandler() = default; // leaves instance in valid but undefined state
78
79 MultiplierParseHandler(::icu::number::Scale multiplier);
80
81 void postProcess(ParsedNumber& result) const U_OVERRIDE;
82
83 UnicodeString toString() const U_OVERRIDE;
84
85 private:
86 ::icu::number::Scale fMultiplier;
87 };
88
89
90 } // namespace impl
91 } // namespace numparse
92 U_NAMESPACE_END
93
94 #endif //__SOURCE_NUMPARSE_VALIDATORS_H__
95 #endif /* #if !UCONFIG_NO_FORMATTING */