Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1152)

Unified Diff: icu4c/source/i18n/numparse_impl.cpp

Issue 339290043: Adding currency names matcher to C++ number parsing code. Base URL: svn+icussh://source.icu-project.org/repos/icu/branches/shane/numberformat4/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: icu4c/source/i18n/numparse_impl.cpp
===================================================================
--- icu4c/source/i18n/numparse_impl.cpp (revision 40880)
+++ icu4c/source/i18n/numparse_impl.cpp (working copy)
@@ -58,7 +58,7 @@
parser->addMatcher(parser->fLocalMatchers.infinity = {symbols});
parser->addMatcher(parser->fLocalMatchers.padding = {u"@"});
parser->addMatcher(parser->fLocalMatchers.scientific = {symbols, grouper});
-// parser.addMatcher(CurrencyTrieMatcher.getInstance(locale));
+ parser->addMatcher(parser->fLocalMatchers.currencyNames = {locale, status});
// parser.addMatcher(new RequireNumberMatcher());
parser->freeze();
@@ -91,12 +91,26 @@
fMatchers[fNumMatchers] = &matcher;
if (fComputeLeads) {
- fLeads[fNumMatchers] = matcher.getLeadCodePoints();
+ addLeadCodePointsForMatcher(matcher);
}
fNumMatchers++;
}
+void NumberParserImpl::addLeadCodePointsForMatcher(const NumberParseMatcher& matcher) {
+ const UnicodeSet* leadCodePoints = matcher.getLeadCodePoints();
+ // TODO: Avoid the clone operation here.
+ if (0 != (fParseFlags & PARSE_FLAG_IGNORE_CASE)) {
+ UnicodeSet* copy = static_cast<UnicodeSet*>(leadCodePoints->cloneAsThawed());
+ delete leadCodePoints;
+ copy->closeOver(USET_ADD_CASE_MAPPINGS);
+ copy->freeze();
+ fLeads[fNumMatchers] = copy;
+ } else {
+ fLeads[fNumMatchers] = leadCodePoints;
+ }
+}
+
void NumberParserImpl::freeze() {
fFrozen = true;
}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b