Reorder functions in number_usageprefs.cpp for consistency.

This commit is contained in:
Hugo van der Merwe 2020-08-26 12:59:34 +02:00
parent 12efd77d64
commit e57d4a93f8
2 changed files with 20 additions and 21 deletions

View file

@ -22,25 +22,6 @@ using namespace icu::number;
using namespace icu::number::impl;
using icu::StringSegment;
// TODO: Move down.
Precision UsagePrefsHandler::parseSkeletonToPrecision(icu::UnicodeString precisionSkeleton,
UErrorCode status) {
if (U_FAILURE(status)) {
return {};
}
constexpr int32_t kSkelPrefixLen = 20;
if (!precisionSkeleton.startsWith(UNICODE_STRING_SIMPLE("precision-increment/"))) {
status = U_INVALID_FORMAT_ERROR;
return {};
}
U_ASSERT(precisionSkeleton[kSkelPrefixLen - 1] == u'/');
StringSegment segment(precisionSkeleton, false);
segment.adjustOffset(kSkelPrefixLen);
MacroProps macros;
blueprint_helpers::parseIncrementOption(segment, macros, status);
return macros.precision;
}
// Copy constructor
Usage::Usage(const Usage &other) : fUsage(nullptr), fLength(other.fLength), fError(other.fError) {
if (other.fUsage != nullptr) {
@ -141,4 +122,24 @@ void UsagePrefsHandler::processQuantity(DecimalQuantity &quantity, MicroProps &m
}
}
Precision UsagePrefsHandler::parseSkeletonToPrecision(icu::UnicodeString precisionSkeleton,
UErrorCode status) {
if (U_FAILURE(status)) {
// As a member of UsagePrefsHandler, which is a friend of Precision, we
// get access to the default constructor.
return {};
}
constexpr int32_t kSkelPrefixLen = 20;
if (!precisionSkeleton.startsWith(UNICODE_STRING_SIMPLE("precision-increment/"))) {
status = U_INVALID_FORMAT_ERROR;
return {};
}
U_ASSERT(precisionSkeleton[kSkelPrefixLen - 1] == u'/');
StringSegment segment(precisionSkeleton, false);
segment.adjustOffset(kSkelPrefixLen);
MacroProps macros;
blueprint_helpers::parseIncrementOption(segment, macros, status);
return macros.precision;
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -53,8 +53,6 @@ class U_I18N_API UsagePrefsHandler : public MicroPropsGenerator, public UMemory
UnitsRouter fUnitsRouter;
const MicroPropsGenerator *fParent;
// As a friend class, parseSkeletonToPrecision has access to Precision's
// default constructor (producing bogus instances).
static Precision parseSkeletonToPrecision(icu::UnicodeString precisionSkeleton, UErrorCode status);
};