void RuleBasedTransliterator::_construct(const UnicodeString& rules, UTransDirection direction, UParseError& parseError, UErrorCode& status) { fData = 0; isDataOwned = TRUE; if (U_FAILURE(status)) { return; } TransliteratorParser parser(status); parser.parse(rules, direction, parseError, status); if (U_FAILURE(status)) { return; } if (parser.idBlockVector.size() != 0 || parser.compoundFilter != NULL || parser.dataVector.size() == 0) { status = U_INVALID_RBT_SYNTAX; // ::ID blocks disallowed in RBT return; } fData = (TransliterationRuleData*)parser.dataVector.orphanElementAt(0); setMaximumContextLength(fData->ruleSet.getMaximumContextLength()); }
TitlecaseTransliterator::TitlecaseTransliterator(const Locale& theLoc) : Transliterator(_ID, 0), loc(theLoc), buffer(0) { buffer = (UChar *)uprv_malloc(u_getMaxCaseExpansion()*sizeof(buffer[0])); // Need to look back 2 characters in the case of "can't" setMaximumContextLength(2); umtx_lock(NULL); UBool f = (SKIP == NULL); umtx_unlock(NULL); if (f) { UErrorCode ec = U_ZERO_ERROR; UnicodeSet* skip = new UnicodeSet(UNICODE_STRING_SIMPLE("[\\u00AD \\u2019 \\' [:Mn:] [:Me:] [:Cf:] [:Lm:] [:Sk:]]"), ec); UnicodeSet* cased = new UnicodeSet(UNICODE_STRING_SIMPLE("[[:Lu:] [:Ll:] [:Lt:]]"), ec); if (skip != NULL && cased != NULL && U_SUCCESS(ec)) { umtx_lock(NULL); if (SKIP == NULL) { SKIP = skip; CASED = cased; skip = cased = NULL; } umtx_unlock(NULL); } delete skip; delete cased; ucln_i18n_registerCleanup(); } }
/** * Internal constructor. */ RuleBasedTransliterator::RuleBasedTransliterator(const UnicodeString& id, TransliterationRuleData* theData, UBool isDataAdopted) : Transliterator(id, 0), fData(theData), isDataOwned(isDataAdopted) { setMaximumContextLength(fData->ruleSet.getMaximumContextLength()); }
RuleBasedTransliterator::RuleBasedTransliterator(const UnicodeString& id, const TransliterationRuleData* theData, UnicodeFilter* adoptedFilter) : Transliterator(id, adoptedFilter), fData((TransliterationRuleData*)theData), // cast away const isDataOwned(FALSE) { setMaximumContextLength(fData->ruleSet.getMaximumContextLength()); }
/** * Sets the length of the longest context required by this transliterator. * This is <em>preceding</em> context. */ void CompoundTransliterator::computeMaximumContextLength(void) { int32_t max = 0; for (int32_t i=0; i<count; ++i) { int32_t len = trans[i]->getMaximumContextLength(); if (len > max) { max = len; } } setMaximumContextLength(max); }
TitlecaseTransliterator::TitlecaseTransliterator() : CaseMapTransliterator(UNICODE_STRING("Any-Title", 9), NULL) { // Need to look back 2 characters in the case of "can't" setMaximumContextLength(2); }