ICU-59173.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / appendable.h
index a6a83b15cf97193b2dc691f90cbcaa91928ddb7f..e6f7276bb8724f6d8d54fff0ed7fc8fb5f42447f 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) 2011-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  appendable.h
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
 
 /**
  * \file
- * \brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (UChars).
+ * \brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (char16_ts).
  */
 
 #include "unicode/utypes.h"
 #include "unicode/uobject.h"
 
+#if U_SHOW_CPLUSPLUS_API
 U_NAMESPACE_BEGIN
 
 class UnicodeString;
@@ -32,10 +35,10 @@ class UnicodeString;
  * Combines elements of Java Appendable and ICU4C ByteSink.
  *
  * This class can be used in APIs where it does not matter whether the actual destination is
- * a UnicodeString, a UChar[] array, a UnicodeSet, or any other object
+ * a UnicodeString, a char16_t[] array, a UnicodeSet, or any other object
  * that receives and processes characters and/or strings.
  *
- * Implementation classes must implement at least appendCodeUnit(UChar).
+ * Implementation classes must implement at least appendCodeUnit(char16_t).
  * The base class provides default implementations for the other methods.
  *
  * The methods do not take UErrorCode parameters.
@@ -60,11 +63,11 @@ public:
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
      */
-    virtual UBool appendCodeUnit(UChar c) = 0;
+    virtual UBool appendCodeUnit(char16_t c) = 0;
 
     /**
      * Appends a code point.
-     * The default implementation calls appendCodeUnit(UChar) once or twice.
+     * The default implementation calls appendCodeUnit(char16_t) once or twice.
      * @param c code point 0..0x10ffff
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
@@ -73,20 +76,20 @@ public:
 
     /**
      * Appends a string.
-     * The default implementation calls appendCodeUnit(UChar) for each code unit.
+     * The default implementation calls appendCodeUnit(char16_t) for each code unit.
      * @param s string, must not be NULL if length!=0
      * @param length string length, or -1 if NUL-terminated
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
      */
-    virtual UBool appendString(const UChar *s, int32_t length);
+    virtual UBool appendString(const char16_t *s, int32_t length);
 
     /**
      * Tells the object that the caller is going to append roughly
-     * appendCapacity UChars. A subclass might use this to pre-allocate
+     * appendCapacity char16_ts. A subclass might use this to pre-allocate
      * a larger buffer if necessary.
      * The default implementation does nothing. (It always returns TRUE.)
-     * @param appendCapacity estimated number of UChars that will be appended
+     * @param appendCapacity estimated number of char16_ts that will be appended
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
      */
@@ -100,19 +103,19 @@ public:
      * The returned buffer is only valid until the next operation
      * on this Appendable.
      *
-     * After writing at most *resultCapacity UChars, call appendString() with the
-     * pointer returned from this function and the number of UChars written.
-     * Many appendString() implementations will avoid copying UChars if this function
+     * After writing at most *resultCapacity char16_ts, call appendString() with the
+     * pointer returned from this function and the number of char16_ts written.
+     * Many appendString() implementations will avoid copying char16_ts if this function
      * returned an internal buffer.
      *
      * Partial usage example:
      * \code
      *  int32_t capacity;
-     *  UChar* buffer = app.getAppendBuffer(..., &capacity);
-     *  ... Write n UChars into buffer, with n <= capacity.
+     *  char16_t* buffer = app.getAppendBuffer(..., &capacity);
+     *  ... Write n char16_ts into buffer, with n <= capacity.
      *  app.appendString(buffer, n);
      * \endcode
-     * In many implementations, that call to append will avoid copying UChars.
+     * In many implementations, that call to append will avoid copying char16_ts.
      *
      * If the Appendable allocates or reallocates an internal buffer, it should use
      * the desiredCapacityHint if appropriate.
@@ -136,9 +139,9 @@ public:
      * @return a buffer with *resultCapacity>=minCapacity
      * @stable ICU 4.8
      */
-    virtual UChar *getAppendBuffer(int32_t minCapacity,
+    virtual char16_t *getAppendBuffer(int32_t minCapacity,
                                    int32_t desiredCapacityHint,
-                                   UChar *scratch, int32_t scratchCapacity,
+                                   char16_t *scratch, int32_t scratchCapacity,
                                    int32_t *resultCapacity);
 };
 
@@ -169,7 +172,7 @@ public:
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
      */
-    virtual UBool appendCodeUnit(UChar c);
+    virtual UBool appendCodeUnit(char16_t c);
 
     /**
      * Appends a code point to the string.
@@ -186,12 +189,12 @@ public:
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
      */
-    virtual UBool appendString(const UChar *s, int32_t length);
+    virtual UBool appendString(const char16_t *s, int32_t length);
 
     /**
      * Tells the UnicodeString that the caller is going to append roughly
-     * appendCapacity UChars.
-     * @param appendCapacity estimated number of UChars that will be appended
+     * appendCapacity char16_ts.
+     * @param appendCapacity estimated number of char16_ts that will be appended
      * @return TRUE if the operation succeeded
      * @stable ICU 4.8
      */
@@ -218,9 +221,9 @@ public:
      * @return a buffer with *resultCapacity>=minCapacity
      * @stable ICU 4.8
      */
-    virtual UChar *getAppendBuffer(int32_t minCapacity,
+    virtual char16_t *getAppendBuffer(int32_t minCapacity,
                                    int32_t desiredCapacityHint,
-                                   UChar *scratch, int32_t scratchCapacity,
+                                   char16_t *scratch, int32_t scratchCapacity,
                                    int32_t *resultCapacity);
 
 private:
@@ -228,5 +231,6 @@ private:
 };
 
 U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
 
 #endif  // __APPENDABLE_H__