2018-03-21 05:17:28 +00:00
|
|
|
// © 2018 and later: Unicode, Inc. and others.
|
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2018-04-23 23:02:26 +00:00
|
|
|
#if !UCONFIG_NO_FORMATTING
|
2018-03-21 05:17:28 +00:00
|
|
|
#ifndef __SOURCE_NUMPARSE_VALIDATORS_H__
|
|
|
|
#define __SOURCE_NUMPARSE_VALIDATORS_H__
|
|
|
|
|
|
|
|
#include "numparse_types.h"
|
2018-05-16 22:46:40 +00:00
|
|
|
#include "static_unicode_sets.h"
|
2018-03-21 05:17:28 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN namespace numparse {
|
|
|
|
namespace impl {
|
|
|
|
|
|
|
|
|
|
|
|
class ValidationMatcher : public NumberParseMatcher {
|
|
|
|
public:
|
|
|
|
bool match(StringSegment&, ParsedNumber&, UErrorCode&) const U_OVERRIDE {
|
|
|
|
// No-op
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-21 06:30:29 +00:00
|
|
|
bool smokeTest(const StringSegment&) const U_OVERRIDE {
|
2018-03-21 05:17:28 +00:00
|
|
|
// No-op
|
2018-03-21 06:30:29 +00:00
|
|
|
return false;
|
2018-03-21 05:17:28 +00:00
|
|
|
}
|
|
|
|
|
2018-03-21 06:30:29 +00:00
|
|
|
void postProcess(ParsedNumber& result) const U_OVERRIDE = 0;
|
2018-03-21 05:17:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RequireAffixValidator : public ValidationMatcher, public UMemory {
|
|
|
|
public:
|
|
|
|
void postProcess(ParsedNumber& result) const U_OVERRIDE;
|
|
|
|
|
|
|
|
UnicodeString toString() const U_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RequireCurrencyValidator : public ValidationMatcher, public UMemory {
|
|
|
|
public:
|
|
|
|
void postProcess(ParsedNumber& result) const U_OVERRIDE;
|
|
|
|
|
|
|
|
UnicodeString toString() const U_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RequireDecimalSeparatorValidator : public ValidationMatcher, public UMemory {
|
|
|
|
public:
|
|
|
|
RequireDecimalSeparatorValidator() = default; // leaves instance in valid but undefined state
|
|
|
|
|
|
|
|
RequireDecimalSeparatorValidator(bool patternHasDecimalSeparator);
|
|
|
|
|
|
|
|
void postProcess(ParsedNumber& result) const U_OVERRIDE;
|
|
|
|
|
|
|
|
UnicodeString toString() const U_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool fPatternHasDecimalSeparator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class RequireNumberValidator : public ValidationMatcher, public UMemory {
|
|
|
|
public:
|
|
|
|
void postProcess(ParsedNumber& result) const U_OVERRIDE;
|
|
|
|
|
|
|
|
UnicodeString toString() const U_OVERRIDE;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-04-03 04:38:16 +00:00
|
|
|
/**
|
|
|
|
* Wraps a {@link Multiplier} for use in the number parsing pipeline.
|
|
|
|
*/
|
|
|
|
class MultiplierParseHandler : public ValidationMatcher, public UMemory {
|
|
|
|
public:
|
|
|
|
MultiplierParseHandler() = default; // leaves instance in valid but undefined state
|
|
|
|
|
2018-04-14 09:45:39 +00:00
|
|
|
MultiplierParseHandler(::icu::number::Scale multiplier);
|
2018-04-03 04:38:16 +00:00
|
|
|
|
|
|
|
void postProcess(ParsedNumber& result) const U_OVERRIDE;
|
|
|
|
|
|
|
|
UnicodeString toString() const U_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
2018-04-14 09:45:39 +00:00
|
|
|
::icu::number::Scale fMultiplier;
|
2018-04-03 04:38:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-21 05:17:28 +00:00
|
|
|
} // namespace impl
|
|
|
|
} // namespace numparse
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif //__SOURCE_NUMPARSE_VALIDATORS_H__
|
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|