]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/stringtriebuilder.h
ICU-59152.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / stringtriebuilder.h
index 05fa6e7b5160dd35ef9ce077b7b40d1381f29ca3..423290484b9cd0122138e2e4838fc82f35533356 100644 (file)
@@ -1,10 +1,12 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 /*
 *******************************************************************************
-*   Copyright (C) 2010-2012, International Business Machines
+*   Copyright (C) 2010-2012,2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  stringtriebuilder.h
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  stringtriebuilder.h
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -50,6 +52,7 @@ enum UStringTrieBuildOption {
     USTRINGTRIE_BUILD_SMALL
 };
 
     USTRINGTRIE_BUILD_SMALL
 };
 
+#if U_SHOW_CPLUSPLUS_API
 U_NAMESPACE_BEGIN
 
 /**
 U_NAMESPACE_BEGIN
 
 /**
@@ -103,7 +106,7 @@ protected:
     /** @internal */
     virtual int32_t getElementStringLength(int32_t i) const = 0;
     /** @internal */
     /** @internal */
     virtual int32_t getElementStringLength(int32_t i) const = 0;
     /** @internal */
-    virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const = 0;
+    virtual char16_t getElementUnit(int32_t i, int32_t unitIndex) const = 0;
     /** @internal */
     virtual int32_t getElementValue(int32_t i) const = 0;
 
     /** @internal */
     virtual int32_t getElementValue(int32_t i) const = 0;
 
@@ -118,7 +121,7 @@ protected:
     /** @internal */
     virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const = 0;
     /** @internal */
     /** @internal */
     virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const = 0;
     /** @internal */
-    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const = 0;
+    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const = 0;
 
     /** @internal */
     virtual UBool matchNodesCanHaveValues() const = 0;
 
     /** @internal */
     virtual UBool matchNodesCanHaveValues() const = 0;
@@ -135,7 +138,7 @@ protected:
     /** @internal */
     static const int32_t kMaxBranchLinearSubNodeLength=5;
 
     /** @internal */
     static const int32_t kMaxBranchLinearSubNodeLength=5;
 
-    // Maximum number of nested split-branch levels for a branch on all 2^16 possible UChar units.
+    // Maximum number of nested split-branch levels for a branch on all 2^16 possible char16_t units.
     // log2(2^16/kMaxBranchLinearSubNodeLength) rounded up.
     /** @internal */
     static const int32_t kMaxSplitBranchLevels=14;
     // log2(2^16/kMaxBranchLinearSubNodeLength) rounded up.
     /** @internal */
     static const int32_t kMaxSplitBranchLevels=14;
@@ -162,6 +165,7 @@ protected:
      * @internal
      */
     Node *registerFinalValue(int32_t value, UErrorCode &errorCode);
      * @internal
      */
     Node *registerFinalValue(int32_t value, UErrorCode &errorCode);
+#endif  /* U_HIDE_INTERNAL_API */
 
     /*
      * C++ note:
 
     /*
      * C++ note:
@@ -183,6 +187,8 @@ protected:
     /** @internal */
     UHashtable *nodes;
 
     /** @internal */
     UHashtable *nodes;
 
+    // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
+    // it is needed for layout of other objects.
     /** @internal */
     class Node : public UObject {
     public:
     /** @internal */
     class Node : public UObject {
     public:
@@ -241,6 +247,7 @@ protected:
         int32_t offset;
     };
 
         int32_t offset;
     };
 
+#ifndef U_HIDE_INTERNAL_API
     // This class should not be overridden because
     // registerFinalValue() compares a stack-allocated FinalValueNode
     // (stack-allocated so that we don't unnecessarily create lots of duplicate nodes)
     // This class should not be overridden because
     // registerFinalValue() compares a stack-allocated FinalValueNode
     // (stack-allocated so that we don't unnecessarily create lots of duplicate nodes)
@@ -256,7 +263,10 @@ protected:
     protected:
         int32_t value;
     };
     protected:
         int32_t value;
     };
+#endif  /* U_HIDE_INTERNAL_API */
 
 
+    // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
+    // it is needed for layout of other objects.
     /**
      * @internal 
      */
     /**
      * @internal 
      */
@@ -274,6 +284,7 @@ protected:
         int32_t value;
     };
 
         int32_t value;
     };
 
+#ifndef U_HIDE_INTERNAL_API
     /** 
      * @internal 
      */
     /** 
      * @internal 
      */
@@ -287,7 +298,10 @@ protected:
     protected:
         Node *next;
     };
     protected:
         Node *next;
     };
+#endif  /* U_HIDE_INTERNAL_API */
 
 
+    // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API,
+    // it is needed for layout of other objects.
     /**
      * @internal 
      */
     /**
      * @internal 
      */
@@ -303,6 +317,7 @@ protected:
         Node *next;
     };
 
         Node *next;
     };
 
+#ifndef U_HIDE_INTERNAL_API
     /**
      * @internal 
      */
     /**
      * @internal 
      */
@@ -324,7 +339,7 @@ protected:
         virtual void write(StringTrieBuilder &builder);
         // Adds a unit with a final value.
         void add(int32_t c, int32_t value) {
         virtual void write(StringTrieBuilder &builder);
         // Adds a unit with a final value.
         void add(int32_t c, int32_t value) {
-            units[length]=(UChar)c;
+            units[length]=(char16_t)c;
             equal[length]=NULL;
             values[length]=value;
             ++length;
             equal[length]=NULL;
             values[length]=value;
             ++length;
@@ -332,7 +347,7 @@ protected:
         }
         // Adds a unit which leads to another match node.
         void add(int32_t c, Node *node) {
         }
         // Adds a unit which leads to another match node.
         void add(int32_t c, Node *node) {
-            units[length]=(UChar)c;
+            units[length]=(char16_t)c;
             equal[length]=node;
             values[length]=0;
             ++length;
             equal[length]=node;
             values[length]=0;
             ++length;
@@ -342,7 +357,7 @@ protected:
         Node *equal[kMaxBranchLinearSubNodeLength];  // NULL means "has final value".
         int32_t length;
         int32_t values[kMaxBranchLinearSubNodeLength];
         Node *equal[kMaxBranchLinearSubNodeLength];  // NULL means "has final value".
         int32_t length;
         int32_t values[kMaxBranchLinearSubNodeLength];
-        UChar units[kMaxBranchLinearSubNodeLength];
+        char16_t units[kMaxBranchLinearSubNodeLength];
     };
 
     /**
     };
 
     /**
@@ -350,7 +365,7 @@ protected:
      */
     class SplitBranchNode : public BranchNode {
     public:
      */
     class SplitBranchNode : public BranchNode {
     public:
-        SplitBranchNode(UChar middleUnit, Node *lessThanNode, Node *greaterOrEqualNode)
+        SplitBranchNode(char16_t middleUnit, Node *lessThanNode, Node *greaterOrEqualNode)
                 : BranchNode(((0x555555*37+middleUnit)*37+
                               hashCode(lessThanNode))*37+hashCode(greaterOrEqualNode)),
                   unit(middleUnit), lessThan(lessThanNode), greaterOrEqual(greaterOrEqualNode) {}
                 : BranchNode(((0x555555*37+middleUnit)*37+
                               hashCode(lessThanNode))*37+hashCode(greaterOrEqualNode)),
                   unit(middleUnit), lessThan(lessThanNode), greaterOrEqual(greaterOrEqualNode) {}
@@ -358,7 +373,7 @@ protected:
         virtual int32_t markRightEdgesFirst(int32_t edgeNumber);
         virtual void write(StringTrieBuilder &builder);
     protected:
         virtual int32_t markRightEdgesFirst(int32_t edgeNumber);
         virtual void write(StringTrieBuilder &builder);
     protected:
-        UChar unit;
+        char16_t unit;
         Node *lessThan;
         Node *greaterOrEqual;
     };
         Node *lessThan;
         Node *greaterOrEqual;
     };
@@ -396,5 +411,6 @@ protected:
 };
 
 U_NAMESPACE_END
 };
 
 U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
 
 #endif  // __STRINGTRIEBUILDER_H__
 
 #endif  // __STRINGTRIEBUILDER_H__