Logo Search packages:      
Sourcecode: icu version File versions

void TransliteratorIDParser::IDtoSTV ( const UnicodeString id,
UnicodeString source,
UnicodeString target,
UnicodeString variant,
UBool &  isSourcePresent 
) [static]

Parse an ID into pieces. Take IDs of the form T, T/V, S-T, S-T/V, or S/V-T. If the source is missing, return a source of ANY.

Parameters:
id the id string, in any of several forms
Returns:
an array of 4 strings: source, target, variant, and isSourcePresent. If the source is not present, ANY will be given as the source, and isSourcePresent will be null. Otherwise isSourcePresent will be non-null. The target may be empty if the id is not well-formed. The variant may be empty.
Parse an ID into pieces. Take IDs of the form T, T/V, S-T, S-T/V, or S/V-T. If the source is missing, return a source of ANY.
Parameters:
id the id string, in any of several forms
Returns:
an array of 4 strings: source, target, variant, and isSourcePresent. If the source is not present, ANY will be given as the source, and isSourcePresent will be NULL. Otherwise isSourcePresent will be non-NULL. The target may be empty if the id is not well-formed. The variant may be empty.

Definition at line 531 of file tridpars.cpp.

References UnicodeString::length(), UnicodeString::remove(), and UnicodeString::truncate().

Referenced by TransliteratorRegistry::find(), Transliterator::getDisplayName(), TransliteratorRegistry::registerEntry(), and TransliteratorRegistry::remove().

                                                             {
    source = ANY;
    target.truncate(0);
    variant.truncate(0);

    int32_t sep = id.indexOf(TARGET_SEP);
    int32_t var = id.indexOf(VARIANT_SEP);
    if (var < 0) {
        var = id.length();
    }
    isSourcePresent = FALSE;

    if (sep < 0) {
        // Form: T/V or T (or /V)
        id.extractBetween(0, var, target);
        id.extractBetween(var, id.length(), variant);
    } else if (sep < var) {
        // Form: S-T/V or S-T (or -T/V or -T)
        if (sep > 0) {
            id.extractBetween(0, sep, source);
            isSourcePresent = TRUE;
        }
        id.extractBetween(++sep, var, target);
        id.extractBetween(var, id.length(), variant);
    } else {
        // Form: (S/V-T or /V-T)
        if (var > 0) {
            id.extractBetween(0, var, source);
            isSourcePresent = TRUE;
        }
        id.extractBetween(var, sep++, variant);
        id.extractBetween(sep, id.length(), target);
    }

    if (variant.length() > 0) {
        variant.remove(0, 1);
    }
}


Generated by  Doxygen 1.6.0   Back to index