Logo Search packages:      
Sourcecode: icu version File versions

void DecimalFormat::appendAffixPattern ( UnicodeString appendTo,
const UnicodeString affixPattern,
const UnicodeString expAffix,
UBool  localized 
) const [private]

Appends an affix pattern to the given StringBuffer, quoting special characters as needed. Uses the internal affix pattern, if that exists, or the literal affix, if the internal affix pattern is null. The appended string will generate the same affix pattern (or literal affix) when passed to toPattern().

Parameters:
appendTothe affix string is appended to this
affixPatterna pattern such as fPosPrefixPattern; may be null
expAffixa corresponding expanded affix, such as fPositivePrefix. Ignored unless affixPattern is null. If affixPattern is null, then expAffix is appended as a literal affix.
localizedtrue if the appended pattern should contain localized pattern characters; otherwise, non-localized pattern chars are appended

Definition at line 3502 of file decimfmt.cpp.

References UnicodeString::append(), appendAffixPattern(), UnicodeString::char32At(), UnicodeString::extractBetween(), getConstSymbol(), UnicodeString::indexOf(), DecimalFormatSymbols::kMinusSignSymbol, DecimalFormatSymbols::kPercentSymbol, DecimalFormatSymbols::kPerMillSymbol, DecimalFormatSymbols::kPlusSignSymbol, and UnicodeString::length().

                                                              {
    if (affixPattern == 0) {
        appendAffixPattern(appendTo, expAffix, localized);
    } else {
        int i;
        for (int pos=0; pos<affixPattern->length(); pos=i) {
            i = affixPattern->indexOf(kQuote, pos);
            if (i < 0) {
                UnicodeString s;
                affixPattern->extractBetween(pos, affixPattern->length(), s);
                appendAffixPattern(appendTo, s, localized);
                break;
            }
            if (i > pos) {
                UnicodeString s;
                affixPattern->extractBetween(pos, i, s);
                appendAffixPattern(appendTo, s, localized);
            }
            UChar32 c = affixPattern->char32At(++i);
            ++i;
            if (c == kQuote) {
                appendTo.append(c).append(c);
                // Fall through and append another kQuote below
            } else if (c == kCurrencySign &&
                       i<affixPattern->length() &&
                       affixPattern->char32At(i) == kCurrencySign) {
                ++i;
                appendTo.append(c).append(c);
            } else if (localized) {
                switch (c) {
                case kPatternPercent:
                    appendTo += getConstSymbol(DecimalFormatSymbols::kPercentSymbol);
                    break;
                case kPatternPerMill:
                    appendTo += getConstSymbol(DecimalFormatSymbols::kPerMillSymbol);
                    break;
                case kPatternPlus:
                    appendTo += getConstSymbol(DecimalFormatSymbols::kPlusSignSymbol);
                    break;
                case kPatternMinus:
                    appendTo += getConstSymbol(DecimalFormatSymbols::kMinusSignSymbol);
                    break;
                default:
                    appendTo.append(c);
                }
            } else {
                appendTo.append(c);
            }
        }
    }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index