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

Format * MessageFormat::getFormat ( const UnicodeString formatName,
UErrorCode status 
) [virtual]

Gets subformat pointer for given format name. This function supports both named and numbered arguments-- if numbered, the formatName is the corresponding UnicodeStrings (e.g. "0", "1", "2"...). The returned Format object should not be deleted by the caller, nor should the ponter of other object . The pointer and its contents remain valid only until the next call to any method of this class is made with this object.

Parameters:
formatName the name or number specifying a format
status output param set to success/failure code. ICU 4.0

Definition at line 986 of file msgfmt.cpp.

References isArgNumeric, NULL, subformats, U_ARGUMENT_TYPE_MISMATCH, and U_FAILURE.

                                                                            {

    if (U_FAILURE(status)) return NULL;
    
    if (isArgNumeric ) {
        int32_t argumentNumber = stou(formatName);
        if (argumentNumber<0) {
            status = U_ARGUMENT_TYPE_MISMATCH;
            return NULL; 
        }
        if (argumentNumber < 0 || argumentNumber >= subformatCount) {
            return subformats[argumentNumber].format;
        }
        else {
            return NULL;
        }
    }
    
    for (int32_t i=0; i<subformatCount; ++i) {
        if (formatName==*subformats[i].argName)
        {
            return subformats[i].format;
        }
    }
    return NULL;
}


Generated by  Doxygen 1.6.0   Back to index