#ifdef DEBUG_COLLATION_BUILDER
#include <stdio.h>
#endif
#include "unicode/utypes.h"
#if !UCONFIG_NO_COLLATION
#include "unicode/caniter.h"
#include "unicode/normalizer2.h"
#include "unicode/tblcoll.h"
#include "unicode/parseerr.h"
#include "unicode/uchar.h"
#include "unicode/ucol.h"
#include "unicode/unistr.h"
#include "unicode/usetiter.h"
#include "unicode/utf16.h"
#include "unicode/uversion.h"
#include "cmemory.h"
#include "collation.h"
#include "collationbuilder.h"
#include "collationdata.h"
#include "collationdatabuilder.h"
#include "collationfastlatin.h"
#include "collationroot.h"
#include "collationrootelements.h"
#include "collationruleparser.h"
#include "collationsettings.h"
#include "collationtailoring.h"
#include "collationweights.h"
#include "normalizer2impl.h"
#include "uassert.h"
#include "ucol_imp.h"
#include "utf16collationiterator.h"
U_NAMESPACE_BEGIN
namespace {
class BundleImporter : public CollationRuleParser::Importer { … };
BundleImporter::~BundleImporter() { … }
void
BundleImporter::getRules(
const char *localeID, const char *collationType,
UnicodeString &rules,
const char *& , UErrorCode &errorCode) { … }
}
RuleBasedCollator::RuleBasedCollator()
: … { … }
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules, UErrorCode &errorCode)
: … { … }
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules, ECollationStrength strength,
UErrorCode &errorCode)
: … { … }
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules,
UColAttributeValue decompositionMode,
UErrorCode &errorCode)
: … { … }
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules,
ECollationStrength strength,
UColAttributeValue decompositionMode,
UErrorCode &errorCode)
: … { … }
RuleBasedCollator::RuleBasedCollator(const UnicodeString &rules,
UParseError &parseError, UnicodeString &reason,
UErrorCode &errorCode)
: … { … }
void
RuleBasedCollator::internalBuildTailoring(const UnicodeString &rules,
int32_t strength,
UColAttributeValue decompositionMode,
UParseError *outParseError, UnicodeString *outReason,
UErrorCode &errorCode) { … }
CollationBuilder::CollationBuilder(const CollationTailoring *b, UBool icu4xMode, UErrorCode &errorCode)
: … { … }
CollationBuilder::CollationBuilder(const CollationTailoring *b, UErrorCode &errorCode)
: … { … }
CollationBuilder::~CollationBuilder() { … }
CollationTailoring *
CollationBuilder::parseAndBuild(const UnicodeString &ruleString,
const UVersionInfo rulesVersion,
CollationRuleParser::Importer *importer,
UParseError *outParseError,
UErrorCode &errorCode) { … }
void
CollationBuilder::addReset(int32_t strength, const UnicodeString &str,
const char *&parserErrorReason, UErrorCode &errorCode) { … }
uint32_t
CollationBuilder::getWeight16Before(int32_t index, int64_t node, int32_t level) { … }
int64_t
CollationBuilder::getSpecialResetPosition(const UnicodeString &str,
const char *&parserErrorReason, UErrorCode &errorCode) { … }
void
CollationBuilder::addRelation(int32_t strength, const UnicodeString &prefix,
const UnicodeString &str, const UnicodeString &extension,
const char *&parserErrorReason, UErrorCode &errorCode) { … }
int32_t
CollationBuilder::findOrInsertNodeForCEs(int32_t strength, const char *&parserErrorReason,
UErrorCode &errorCode) { … }
int32_t
CollationBuilder::findOrInsertNodeForRootCE(int64_t ce, int32_t strength, UErrorCode &errorCode) { … }
namespace {
int32_t
binarySearchForRootPrimaryNode(const int32_t *rootPrimaryIndexes, int32_t length,
const int64_t *nodes, uint32_t p) { … }
}
int32_t
CollationBuilder::findOrInsertNodeForPrimary(uint32_t p, UErrorCode &errorCode) { … }
int32_t
CollationBuilder::findOrInsertWeakNode(int32_t index, uint32_t weight16, int32_t level, UErrorCode &errorCode) { … }
int32_t
CollationBuilder::insertTailoredNodeAfter(int32_t index, int32_t strength, UErrorCode &errorCode) { … }
int32_t
CollationBuilder::insertNodeBetween(int32_t index, int32_t nextIndex, int64_t node,
UErrorCode &errorCode) { … }
int32_t
CollationBuilder::findCommonNode(int32_t index, int32_t strength) const { … }
void
CollationBuilder::setCaseBits(const UnicodeString &nfdString,
const char *&parserErrorReason, UErrorCode &errorCode) { … }
void
CollationBuilder::suppressContractions(const UnicodeSet &set, const char *&parserErrorReason,
UErrorCode &errorCode) { … }
void
CollationBuilder::optimize(const UnicodeSet &set, const char *& ,
UErrorCode &errorCode) { … }
uint32_t
CollationBuilder::addWithClosure(const UnicodeString &nfdPrefix, const UnicodeString &nfdString,
const int64_t newCEs[], int32_t newCEsLength, uint32_t ce32,
UErrorCode &errorCode) { … }
static constexpr int32_t kClosureLoopLimit = …;
uint32_t
CollationBuilder::addOnlyClosure(const UnicodeString &nfdPrefix, const UnicodeString &nfdString,
const int64_t newCEs[], int32_t newCEsLength, uint32_t ce32,
UErrorCode &errorCode) { … }
void
CollationBuilder::addTailComposites(const UnicodeString &nfdPrefix, const UnicodeString &nfdString,
UErrorCode &errorCode) { … }
UBool
CollationBuilder::mergeCompositeIntoString(const UnicodeString &nfdString,
int32_t indexAfterLastStarter,
UChar32 composite, const UnicodeString &decomp,
UnicodeString &newNFDString, UnicodeString &newString,
UErrorCode &errorCode) const { … }
UBool
CollationBuilder::ignorePrefix(const UnicodeString &s, UErrorCode &errorCode) const { … }
UBool
CollationBuilder::ignoreString(const UnicodeString &s, UErrorCode &errorCode) const { … }
UBool
CollationBuilder::isFCD(const UnicodeString &s, UErrorCode &errorCode) const { … }
void
CollationBuilder::closeOverComposites(UErrorCode &errorCode) { … }
uint32_t
CollationBuilder::addIfDifferent(const UnicodeString &prefix, const UnicodeString &str,
const int64_t newCEs[], int32_t newCEsLength, uint32_t ce32,
UErrorCode &errorCode) { … }
UBool
CollationBuilder::sameCEs(const int64_t ces1[], int32_t ces1Length,
const int64_t ces2[], int32_t ces2Length) { … }
#ifdef DEBUG_COLLATION_BUILDER
uint32_t
alignWeightRight(uint32_t w) {
if(w != 0) {
while((w & 0xff) == 0) { w >>= 8; }
}
return w;
}
#endif
void
CollationBuilder::makeTailoredCEs(UErrorCode &errorCode) { … }
int32_t
CollationBuilder::countTailoredNodes(const int64_t *nodesArray, int32_t i, int32_t strength) { … }
class CEFinalizer : public CollationDataBuilder::CEModifier { … };
CEFinalizer::~CEFinalizer() { … }
void
CollationBuilder::finalizeCEs(UErrorCode &errorCode) { … }
int32_t
CollationBuilder::ceStrength(int64_t ce) { … }
U_NAMESPACE_END
U_NAMESPACE_USE
U_CAPI UCollator * U_EXPORT2
ucol_openRules(const char16_t *rules, int32_t rulesLength,
UColAttributeValue normalizationMode, UCollationStrength strength,
UParseError *parseError, UErrorCode *pErrorCode) { … }
static const int32_t internalBufferSize = …;
U_CAPI int32_t U_EXPORT2
ucol_getUnsafeSet( const UCollator *coll,
USet *unsafe,
UErrorCode *status)
{ … }
#endif