Logo Search packages:      
Sourcecode: icu version File versions

TransliteratorIDParser::SingleID * TransliteratorIDParser::specsToSpecialInverse ( const Specs specs  )  [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.

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 794 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();
    Mutex lock(&LOCK);
    UnicodeString* inverseTarget = (UnicodeString*) SPECIAL_INVERSES->get(
        specs.target);
    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