]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/ucharstriebuilder.h
ICU-62123.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / ucharstriebuilder.h
index f1ffc4ce4b0540e12eecc459bd627b84c0b71deb..e8e7390bdc50a631dffeb8688328dd38619a04fe 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-2016, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  ucharstriebuilder.h
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  ucharstriebuilder.h
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -25,6 +27,7 @@
  * \brief C++ API: Builder for icu::UCharsTrie
  */
 
  * \brief C++ API: Builder for icu::UCharsTrie
  */
 
+#if U_SHOW_CPLUSPLUS_API
 U_NAMESPACE_BEGIN
 
 class UCharsTrieElement;
 U_NAMESPACE_BEGIN
 
 class UCharsTrieElement;
@@ -70,6 +73,9 @@ public:
      * Builds a UCharsTrie for the add()ed data.
      * Once built, no further data can be add()ed until clear() is called.
      *
      * Builds a UCharsTrie for the add()ed data.
      * Once built, no further data can be add()ed until clear() is called.
      *
+     * A UCharsTrie cannot be empty. At least one (string, value) pair
+     * must have been add()ed.
+     *
      * This method passes ownership of the builder's internal result array to the new trie object.
      * Another call to any build() variant will re-serialize the trie.
      * After clear() has been called, a new array will be used as well.
      * This method passes ownership of the builder's internal result array to the new trie object.
      * Another call to any build() variant will re-serialize the trie.
      * After clear() has been called, a new array will be used as well.
@@ -84,18 +90,21 @@ public:
     UCharsTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
 
     /**
     UCharsTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
 
     /**
-     * Builds a UCharsTrie for the add()ed data and UChar-serializes it.
+     * Builds a UCharsTrie for the add()ed data and char16_t-serializes it.
      * Once built, no further data can be add()ed until clear() is called.
      *
      * Once built, no further data can be add()ed until clear() is called.
      *
+     * A UCharsTrie cannot be empty. At least one (string, value) pair
+     * must have been add()ed.
+     *
      * Multiple calls to buildUnicodeString() set the UnicodeStrings to the
      * Multiple calls to buildUnicodeString() set the UnicodeStrings to the
-     * builder's same UChar array, without rebuilding.
+     * builder's same char16_t array, without rebuilding.
      * If buildUnicodeString() is called after build(), the trie will be
      * re-serialized into a new array.
      * If build() is called after buildUnicodeString(), the trie object will become
      * the owner of the previously returned array.
      * After clear() has been called, a new array will be used as well.
      * @param buildOption Build option, see UStringTrieBuildOption.
      * If buildUnicodeString() is called after build(), the trie will be
      * re-serialized into a new array.
      * If build() is called after buildUnicodeString(), the trie object will become
      * the owner of the previously returned array.
      * After clear() has been called, a new array will be used as well.
      * @param buildOption Build option, see UStringTrieBuildOption.
-     * @param result A UnicodeString which will be set to the UChar-serialized
+     * @param result A UnicodeString which will be set to the char16_t-serialized
      *               UCharsTrie for the add()ed data.
      * @param errorCode Standard ICU error code. Its input value must
      *                  pass the U_SUCCESS() test, or else the function returns
      *               UCharsTrie for the add()ed data.
      * @param errorCode Standard ICU error code. Its input value must
      *                  pass the U_SUCCESS() test, or else the function returns
@@ -127,14 +136,14 @@ private:
     void buildUChars(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
 
     virtual int32_t getElementStringLength(int32_t i) const;
     void buildUChars(UStringTrieBuildOption buildOption, UErrorCode &errorCode);
 
     virtual int32_t getElementStringLength(int32_t i) const;
-    virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const;
+    virtual char16_t getElementUnit(int32_t i, int32_t unitIndex) const;
     virtual int32_t getElementValue(int32_t i) const;
 
     virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const;
 
     virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const;
     virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
     virtual int32_t getElementValue(int32_t i) const;
 
     virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const;
 
     virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const;
     virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;
-    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const;
+    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, char16_t unit) const;
 
     virtual UBool matchNodesCanHaveValues() const { return TRUE; }
 
 
     virtual UBool matchNodesCanHaveValues() const { return TRUE; }
 
@@ -142,23 +151,21 @@ private:
     virtual int32_t getMinLinearMatch() const { return UCharsTrie::kMinLinearMatch; }
     virtual int32_t getMaxLinearMatchLength() const { return UCharsTrie::kMaxLinearMatchLength; }
 
     virtual int32_t getMinLinearMatch() const { return UCharsTrie::kMinLinearMatch; }
     virtual int32_t getMaxLinearMatchLength() const { return UCharsTrie::kMaxLinearMatchLength; }
 
-#ifndef U_HIDE_INTERNAL_API
     class UCTLinearMatchNode : public LinearMatchNode {
     public:
     class UCTLinearMatchNode : public LinearMatchNode {
     public:
-        UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode);
+        UCTLinearMatchNode(const char16_t *units, int32_t len, Node *nextNode);
         virtual UBool operator==(const Node &other) const;
         virtual void write(StringTrieBuilder &builder);
     private:
         virtual UBool operator==(const Node &other) const;
         virtual void write(StringTrieBuilder &builder);
     private:
-        const UChar *s;
+        const char16_t *s;
     };
     };
-#endif
 
     virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,
                                         Node *nextNode) const;
 
     UBool ensureCapacity(int32_t length);
     virtual int32_t write(int32_t unit);
 
     virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,
                                         Node *nextNode) const;
 
     UBool ensureCapacity(int32_t length);
     virtual int32_t write(int32_t unit);
-    int32_t write(const UChar *s, int32_t length);
+    int32_t write(const char16_t *s, int32_t length);
     virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length);
     virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
     virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
     virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length);
     virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);
     virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);
@@ -169,13 +176,14 @@ private:
     int32_t elementsCapacity;
     int32_t elementsLength;
 
     int32_t elementsCapacity;
     int32_t elementsLength;
 
-    // UChar serialization of the trie.
+    // char16_t serialization of the trie.
     // Grows from the back: ucharsLength measures from the end of the buffer!
     // Grows from the back: ucharsLength measures from the end of the buffer!
-    UChar *uchars;
+    char16_t *uchars;
     int32_t ucharsCapacity;
     int32_t ucharsLength;
 };
 
 U_NAMESPACE_END
     int32_t ucharsCapacity;
     int32_t ucharsLength;
 };
 
 U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
 
 #endif  // __UCHARSTRIEBUILDER_H__
 
 #endif  // __UCHARSTRIEBUILDER_H__