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

TransliteratorIDParser::SingleID * TransliteratorIDParser::specsToSpecialInverse ( const Specs specs,
UErrorCode status 
) [static, private]

Given a Specs object, return a SingleID representing the special inverse of that ID. If there is no special inverse then return null.

Parameters:
specs the given Specs.
Returns:
a SingleID or null. Returned object always has 'filter' field of null.
Given a Specs object, return a SingleID representing the special inverse of that ID. If there is no special inverse then return NULL.
Returns:
a SingleID or NULL. Returned object always has 'filter' field of NULL.

Definition at line 850 of file tridpars.cpp.

References UnicodeString::append(), UnicodeString::caseCompare(), TransliteratorIDParser::Specs::filter, Hashtable::get(), init(), UnicodeString::length(), NULL, TransliteratorIDParser::Specs::sawSource, TransliteratorIDParser::Specs::source, TransliteratorIDParser::Specs::target, U_FOLD_CASE_DEFAULT, and TransliteratorIDParser::Specs::variant.

Referenced by parseSingleID().

                                                                                    {
    if (0!=specs.source.caseCompare(ANY, U_FOLD_CASE_DEFAULT)) {
        return NULL;
    }
    init(status);

    UnicodeString* inverseTarget;

    umtx_lock(&LOCK);
    inverseTarget = (UnicodeString*) SPECIAL_INVERSES->get(specs.target);
    umtx_unlock(&LOCK);

    if (inverseTarget != NULL) {
        // If the original ID contained "Any-" then make the
        // special inverse "Any-Foo"; otherwise make it "Foo".
        // So "Any-NFC" => "Any-NFD" but "NFC" => "NFD".
        UnicodeString buf;
        if (specs.filter.length() != 0) {
            buf.append(specs.filter);
        }
        if (specs.sawSource) {
            buf.append(ANY).append(TARGET_SEP);
        }
        buf.append(*inverseTarget);

        UnicodeString basicID(ANY);
        basicID.append(TARGET_SEP).append(*inverseTarget);

        if (specs.variant.length() != 0) {
            buf.append(VARIANT_SEP).append(specs.variant);
            basicID.append(VARIANT_SEP).append(specs.variant);
        }
        return new SingleID(buf, basicID);
    }
    return NULL;
}


Generated by  Doxygen 1.6.0   Back to index