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

Locale RuleBasedNumberFormat::getRuleSetDisplayNameLocale ( int32_t  index,
UErrorCode status 
) const [virtual]

Return the index'th display name locale.

Parameters:
index the index of the locale
status set to a failure code when this function fails
Returns:
the locale
See also:
getNumberOfRuleSetDisplayNameLocales ICU 3.2

Definition at line 962 of file rbnf.cpp.

References UnicodeString::kInvariant, NULL, TRUE, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, and U_MEMORY_ALLOCATION_ERROR.

                                                                                          {
    if (U_FAILURE(status)) {
        return Locale("");
    }
    if (localizations && index >= 0 && index < localizations->getNumberOfDisplayLocales()) {
        UnicodeString name(TRUE, localizations->getLocaleName(index), -1);
        char buffer[64];
        int32_t cap = name.length() + 1;
        char* bp = buffer;
        if (cap > 64) {
            bp = (char *)uprv_malloc(cap);
            if (bp == NULL) {
                status = U_MEMORY_ALLOCATION_ERROR;
                return Locale("");
            }
        }
        name.extract(0, name.length(), bp, cap, UnicodeString::kInvariant);
        Locale retLocale(bp);
        if (bp != buffer) {
            uprv_free(bp);
        }
        return retLocale;
    }
    status = U_ILLEGAL_ARGUMENT_ERROR;
    Locale retLocale;
    return retLocale;
}


Generated by  Doxygen 1.6.0   Back to index