1999-11-20 00:40:50 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
|
|
|
* Copyright (C) 1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 11/17/99 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
#include "rbt_data.h"
|
2000-03-28 22:12:14 +00:00
|
|
|
#include "hash.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/unistr.h"
|
2000-05-20 04:40:29 +00:00
|
|
|
#include "unicode/uniset.h"
|
1999-11-20 00:40:50 +00:00
|
|
|
|
|
|
|
TransliterationRuleData::TransliterationRuleData(UErrorCode& status) :
|
|
|
|
variableNames(0), setVariables(0) {
|
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
return;
|
|
|
|
}
|
2000-03-28 22:12:14 +00:00
|
|
|
variableNames = new Hashtable(status);
|
2000-05-20 04:40:29 +00:00
|
|
|
if (U_SUCCESS(status)) {
|
|
|
|
variableNames->setValueDeleter(uhash_deleteUnicodeString);
|
|
|
|
}
|
2000-02-08 02:49:15 +00:00
|
|
|
setVariables = 0;
|
|
|
|
setVariablesLength = 0;
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TransliterationRuleData::~TransliterationRuleData() {
|
2000-03-28 22:12:14 +00:00
|
|
|
delete variableNames;
|
2000-05-20 04:40:29 +00:00
|
|
|
if (setVariables != 0) {
|
|
|
|
for (int32_t i=0; i<setVariablesLength; ++i) {
|
|
|
|
delete setVariables[i];
|
|
|
|
}
|
|
|
|
delete[] setVariables;
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-08 02:49:15 +00:00
|
|
|
const UnicodeSet*
|
1999-11-20 00:40:50 +00:00
|
|
|
TransliterationRuleData::lookupSet(UChar standIn) const {
|
2000-02-08 02:49:15 +00:00
|
|
|
int32_t i = standIn - setVariablesBase;
|
|
|
|
return (i >= 0 && i < setVariablesLength) ? setVariables[i] : 0;
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|
|
|
|
|
2000-05-20 04:40:29 +00:00
|
|
|
int32_t
|
|
|
|
TransliterationRuleData::lookupSegmentReference(UChar c) const {
|
|
|
|
int32_t i = c - segmentBase;
|
|
|
|
return (i >= 0 && i < 9) ? i : -1;
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|