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

Transliterator *U_EXPORT2 Transliterator::createInstance ( const UnicodeString ID,
UTransDirection  dir,
UParseError parseError,
UErrorCode status 
) [static, inherited]

Returns a Transliterator object given its ID. The ID must be either a system transliterator ID or a ID registered using registerInstance().

Parameters:
ID a valid ID, as enumerated by getAvailableIDs()
dir either FORWARD or REVERSE.
parseError Struct to recieve information on position of error if an error is encountered
status Output param to filled in with a success or an error.
Returns:
A Transliterator object with the given ID
See also:
registerInstance

getAvailableIDs

getID ICU 2.0

Returns a Transliterator object given its ID. The ID must be either a system transliterator ID or a ID registered using registerInstance().

Parameters:
ID a valid ID, as enumerated by getAvailableIDs()
Returns:
A Transliterator object with the given ID
See also:
registerInstance

getAvailableIDs

getID

Definition at line 910 of file translit.cpp.

References UVector::elementAt(), UnicodeString::indexOf(), TransliteratorIDParser::instantiateList(), NULL, TransliteratorIDParser::parseCompoundID(), UVector::size(), U_FAILURE, U_INVALID_ID, U_MEMORY_ALLOCATION_ERROR, and U_SUCCESS.

Referenced by TransliteratorAlias::create(), Transliterator::createFromRules(), Transliterator::createInstance(), Transliterator::createInverse(), AnyTransliterator::getTransliterator(), TransliteratorTest::TestAliasInverseID(), TransliteratorTest::TestAny(), TransliteratorTest::TestAnyX(), TransliteratorTest::TestCaseMap(), TransliteratorTest::TestCompoundFilter(), TransliteratorTest::TestCompoundFilterID(), TransliteratorTest::TestCompoundHex(), TransliteratorTest::TestCompoundInverse(), TransliteratorTest::TestCompoundInverseID(), TransliteratorTest::TestCompoundKana(), TransliteratorTest::TestCompoundRBT(), TransliteratorTest::TestCreateInstance(), TransliteratorTest::TestDisplayName(), TransliteratorTest::TestEscape(), TransliteratorTest::TestFilterIDs(), TransliteratorTest::TestFiltering(), TransliteratorTest::TestGurmukhiDevanagari(), TransliteratorTest::TestHalfwidthFullwidth(), TransliteratorTest::TestHiraganaKatakana(), TransliteratorTest::TestIDForms(), TransliteratorTest::TestIncrementalProgress(), TransliteratorTest::TestInstantiation(), TransliteratorTest::TestInterIndic(), TransliteratorTest::TestJ243(), TransliteratorTest::TestJ277(), TransliteratorTest::TestLiberalizedID(), TransliteratorTest::TestLocaleInstantiation(), TransliteratorTest::TestLocaleResource(), TransliteratorTest::TestNameMap(), TransliteratorTest::TestNewEngine(), TransliteratorTest::TestNormalizationTransliterator(), TransliteratorTest::TestNullInverse(), JamoTest::TestPiecemeal(), TransliteratorTest::TestRegisterAlias(), TransliteratorTest::TestSpecialCases(), TransliteratorTest::TestSTV(), TransliteratorTest::TestThai(), TransliteratorTest::TestTitleAccents(), TransliteratorTest::TestUserFunction(), and utrans_openU().

{
    if (U_FAILURE(status)) {
        return 0;
    }

    UnicodeString canonID;
    UVector list(status);
    if (U_FAILURE(status)) {
        return NULL;
    }

    UnicodeSet* globalFilter;
    // TODO add code for parseError...currently unused, but
    // later may be used by parsing code...
    if (!TransliteratorIDParser::parseCompoundID(ID, dir, canonID, list, globalFilter)) {
        status = U_INVALID_ID;
        return NULL;
    }
    
    TransliteratorIDParser::instantiateList(list, status);
    if (U_FAILURE(status)) {
        return NULL;
    }
    
    U_ASSERT(list.size() > 0);
    Transliterator* t = NULL;
    
    if (list.size() > 1 || canonID.indexOf(ID_DELIM) >= 0) {
        // [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only
        // has one child transliterator.  This is so that toRules() will return the right thing
        // (without any inactive ID), but our main ID still comes out correct.  That is, if we
        // instantiate "(Lower);Latin-Greek;", we want the rules to come out as "::Latin-Greek;"
        // even though the ID is "(Lower);Latin-Greek;".
        t = new CompoundTransliterator(list, parseError, status);
    }
    else {
        t = (Transliterator*)list.elementAt(0);
    }
    // Check null pointer
    if (t != NULL) {
        t->setID(canonID);
        if (globalFilter != NULL) {
            t->adoptFilter(globalFilter);
        }
    }
    else if (U_SUCCESS(status)) {
        status = U_MEMORY_ALLOCATION_ERROR;
    }
    return t;
}


Generated by  Doxygen 1.6.0   Back to index