Logo Search packages:      
Sourcecode: icu version File versions  Download package

UnicodeString & ChoiceFormat::format ( const Formattable objs,
int32_t  cnt,
UnicodeString appendTo,
FieldPosition pos,
UErrorCode success 
) const [virtual]

Format an array of objects using this object's choices.

objs The array of objects to be formatted.
cnt The size of objs.
appendTo Output parameter to receive result. Result is appended to existing contents.
pos On input: an alignment field, if desired. On output: the offsets of the alignment field.
success Output param set to success/failure code on exit.
Reference to 'appendTo' parameter. ICU 2.0

Definition at line 673 of file choicfmt.cpp.

References format(), Formattable::getDouble(), UnicodeString::remove(), U_ILLEGAL_ARGUMENT_ERROR, and U_SUCCESS.

    if(cnt < 0) {
        status = U_ILLEGAL_ARGUMENT_ERROR;
        return appendTo;

    UnicodeString buffer;
    for (int32_t i = 0; i < cnt; i++) {
        double objDouble = objs[i].getDouble(status);
        if (U_SUCCESS(status)) {
            appendTo += format(objDouble, buffer, pos);

    return appendTo;

Generated by  Doxygen 1.6.0   Back to index