Logo Search packages:      
Sourcecode: icu version File versions

void DecimalFormat::addPadding ( UnicodeString appendTo,
FieldPositionHandler handler,
int32_t  prefixLen,
int32_t  suffixLen 
) const [private]

Inserts the character fPad as needed to expand result to fFormatWidth.

Parameters:
resultthe string to be padded

Definition at line 1518 of file decimfmt.cpp.

References UnicodeString::insert(), and UnicodeString::length().

Referenced by subformat().

{
    if (fFormatWidth > 0) {
        int32_t len = fFormatWidth - appendTo.length();
        if (len > 0) {
            UnicodeString padding;
            for (int32_t i=0; i<len; ++i) {
                padding += fPad;
            }
            switch (fPadPosition) {
            case kPadAfterPrefix:
                appendTo.insert(prefixLen, padding);
                break;
            case kPadBeforePrefix:
                appendTo.insert(0, padding);
                break;
            case kPadBeforeSuffix:
                appendTo.insert(appendTo.length() - suffixLen, padding);
                break;
            case kPadAfterSuffix:
                appendTo += padding;
                break;
            }
            if (fPadPosition == kPadBeforePrefix || fPadPosition == kPadAfterPrefix) {
                handler.shiftLast(len);
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index