/** Used by the unsafe code path. */
MicroPropsGenerator& MutablePatternModifier::addToChain(const MicroPropsGenerator* parent) {
fParent = parent; return *this;
}
void MutablePatternModifier::processQuantity(DecimalQuantity& fq, MicroProps& micros,
UErrorCode& status) const {
fParent->processQuantity(fq, micros, status);
micros.rounder.apply(fq, status); if (micros.modMiddle != nullptr) { return;
} // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. auto* nonConstThis = const_cast<MutablePatternModifier*>(this); if (needsPlurals()) {
StandardPlural::Form pluralForm = utils::getPluralSafe(micros.rounder, fRules, fq, status);
nonConstThis->setNumberProperties(fq.signum(), pluralForm);
} else {
nonConstThis->setNumberProperties(fq.signum(), StandardPlural::Form::COUNT);
}
micros.modMiddle = this;
}
int32_t MutablePatternModifier::apply(FormattedStringBuilder& output, int32_t leftIndex, int32_t rightIndex,
UErrorCode& status) const { // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
int32_t prefixLen = nonConstThis->insertPrefix(output, leftIndex, status);
int32_t suffixLen = nonConstThis->insertSuffix(output, rightIndex + prefixLen, status); // If the pattern had no decimal stem body (like #,##0.00), overwrite the value.
int32_t overwriteLen = 0; if (!fPatternInfo->hasBody()) {
overwriteLen = output.splice(
leftIndex + prefixLen,
rightIndex + prefixLen,
UnicodeString(),
0,
0,
kUndefinedField,
status);
}
CurrencySpacingEnabledModifier::applyCurrencySpacing(
output,
leftIndex,
prefixLen,
rightIndex + overwriteLen + prefixLen,
suffixLen,
*fSymbols,
status); return prefixLen + overwriteLen + suffixLen;
}
int32_t MutablePatternModifier::getPrefixLength() const { // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
// Enter and exit CharSequence Mode to get the length.
UErrorCode status = U_ZERO_ERROR; // status fails only with an iilegal argument exception
nonConstThis->prepareAffix(true); int result = AffixUtils::unescapedCodePointCount(currentAffix, *this, status); // prefix length return result;
}
int32_t MutablePatternModifier::getCodePointCount() const { // The unsafe code path performs self-mutation, so we need a const_cast. // This method needs to be const because it overrides a const method in the parent class. auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
// Render the affixes to get the length
UErrorCode status = U_ZERO_ERROR; // status fails only with an iilegal argument exception
nonConstThis->prepareAffix(true); int result = AffixUtils::unescapedCodePointCount(currentAffix, *this, status); // prefix length
nonConstThis->prepareAffix(false);
result += AffixUtils::unescapedCodePointCount(currentAffix, *this, status); // suffix length return result;
}
/** This method contains the heart of the logic for rendering LDML affix strings. */ void MutablePatternModifier::prepareAffix(bool isPrefix) {
PatternStringUtils::patternInfoToStringBuilder(
*fPatternInfo,
isPrefix,
PatternStringUtils::resolveSignDisplay(fSignDisplay, fSignum),
fApproximately,
fPlural,
fPerMilleReplacesPercent, false, // dropCurrencySymbols
currentAffix);
}
UnicodeString MutablePatternModifier::getSymbol(AffixPatternType type) const {
UErrorCode localStatus = U_ZERO_ERROR; switch (type) { case AffixPatternType::TYPE_MINUS_SIGN: return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kMinusSignSymbol); case AffixPatternType::TYPE_PLUS_SIGN: return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPlusSignSymbol); case AffixPatternType::TYPE_APPROXIMATELY_SIGN: return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kApproximatelySignSymbol); case AffixPatternType::TYPE_PERCENT: return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPercentSymbol); case AffixPatternType::TYPE_PERMILLE: return fSymbols->getSymbol(DecimalFormatSymbols::ENumberFormatSymbol::kPerMillSymbol); case AffixPatternType::TYPE_CURRENCY_SINGLE: return getCurrencySymbolForUnitWidth(localStatus); case AffixPatternType::TYPE_CURRENCY_DOUBLE: return fCurrencySymbols.getIntlCurrencySymbol(localStatus); case AffixPatternType::TYPE_CURRENCY_TRIPLE: // NOTE: This is the code path only for patterns containing "¤¤¤". // Plural currencies set via the API are formatted in LongNameHandler. // This code path is used by DecimalFormat via CurrencyPluralInfo.
U_ASSERT(fPlural != StandardPlural::Form::COUNT); return fCurrencySymbols.getPluralName(fPlural, localStatus); case AffixPatternType::TYPE_CURRENCY_QUAD: return UnicodeString(u"\uFFFD"); case AffixPatternType::TYPE_CURRENCY_QUINT: return UnicodeString(u"\uFFFD"); default:
UPRV_UNREACHABLE_EXIT;
}
}
UnicodeString MutablePatternModifier::getCurrencySymbolForUnitWidth(UErrorCode& status) const { switch (fUnitWidth) { case UNumberUnitWidth::UNUM_UNIT_WIDTH_NARROW: return fCurrencySymbols.getNarrowCurrencySymbol(status); case UNumberUnitWidth::UNUM_UNIT_WIDTH_SHORT: return fCurrencySymbols.getCurrencySymbol(status); case UNumberUnitWidth::UNUM_UNIT_WIDTH_ISO_CODE: return fCurrencySymbols.getIntlCurrencySymbol(status); case UNumberUnitWidth::UNUM_UNIT_WIDTH_FORMAL: return fCurrencySymbols.getFormalCurrencySymbol(status); case UNumberUnitWidth::UNUM_UNIT_WIDTH_VARIANT: return fCurrencySymbols.getVariantCurrencySymbol(status); case UNumberUnitWidth::UNUM_UNIT_WIDTH_HIDDEN: return {}; default: return fCurrencySymbols.getCurrencySymbol(status);
}
}
UnicodeString MutablePatternModifier::toUnicodeString() const { // Never called by AffixUtils
UPRV_UNREACHABLE_EXIT;
}
#endif/* #if !UCONFIG_NO_FORMATTING */
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
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.