// Allow implicit conversion from char16_t* to UnicodeString for this file: // Helpful in toString methods and elsewhere. #define UNISTR_FROM_STRING_EXPLICIT
int32_t initialOffset = segment.getOffset(); bool maybeMore = true; for (constauto* it = begin(); it < end();) { const NumberParseMatcher* matcher = *it; int matcherOffset = segment.getOffset(); if (segment.length() != 0) {
maybeMore = matcher->match(segment, result, status);
} else { // Nothing for this matcher to match; ask for more.
maybeMore = true;
}
bool success = (segment.getOffset() != matcherOffset); bool isFlexible = matcher->isFlexible(); if (success && isFlexible) { // Match succeeded, and this is a flexible matcher. Re-run it.
} elseif (success) { // Match succeeded, and this is NOT a flexible matcher. Proceed to the next matcher.
it++; // Small hack: if there is another matcher coming, do not accept trailing weak chars. // Needed for proper handling of currency spacing. if (it < end() && segment.getOffset() != result.charEnd && result.charEnd > matcherOffset) {
segment.setOffset(result.charEnd);
}
} elseif (isFlexible) { // Match failed, and this is a flexible matcher. Try again with the next matcher.
it++;
} else { // Match failed, and this is NOT a flexible matcher. Exit.
segment.setOffset(initialOffset);
result = backup; return maybeMore;
}
}
// All matchers in the series succeeded. return maybeMore;
}
bool SeriesMatcher::smokeTest(const StringSegment& segment) const { // NOTE: The range-based for loop calls the virtual begin() and end() methods. // NOTE: We only want the first element. Use the for loop for boundary checking. for (constauto& matcher : *this) { // SeriesMatchers are never allowed to start with a Flexible matcher.
U_ASSERT(!matcher->isFlexible()); return matcher->smokeTest(segment);
} returnfalse;
}
void SeriesMatcher::postProcess(ParsedNumber& result) const { // NOTE: The range-based for loop calls the virtual begin() and end() methods. for (constauto* matcher : *this) {
matcher->postProcess(result);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.