]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/uiter.h
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / uiter.h
index b69f008718d171b6514feb8ab4cb6201495dbf1a..9792095e00092bf5630bb15dcc408bca1f7c5bf0 100644 (file)
@@ -1,12 +1,14 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2002-2003, International Business Machines
+*   Copyright (C) 2002-2011 International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
 *   file name:  uiter.h
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
 
 #include "unicode/utypes.h"
 
-#ifdef XP_CPLUSPLUS
+#if U_SHOW_CPLUSPLUS_API
     U_NAMESPACE_BEGIN
 
     class CharacterIterator;
     class Replaceable;
 
     U_NAMESPACE_END
-#endif
+#endif // U_SHOW_CPLUSPLUS_API
 
 U_CDECL_BEGIN
 
@@ -50,7 +52,7 @@ typedef enum UCharIteratorOrigin {
     UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH
 } UCharIteratorOrigin;
 
-/** Constants for UCharIterator. @draft ICU 2.6 */
+/** Constants for UCharIterator. @stable ICU 2.6 */
 enum {
     /**
      * Constant value that may be returned by UCharIteratorMove
@@ -64,11 +66,12 @@ enum {
      * The actual index can be determined with getIndex(UITER_CURRENT)
      * which will count the UChars if necessary.
      *
-     * @draft ICU 2.6
+     * @stable ICU 2.6
      */
     UITER_UNKNOWN_INDEX=-2
 };
 
+
 /**
  * Constant for UCharIterator getState() indicating an error or
  * an unknown state.
@@ -78,7 +81,7 @@ enum {
  * a valid state for each position. This will be clearly documented
  * for each such iterator (none of the public ones here).
  *
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
 #define UITER_NO_STATE ((uint32_t)0xffffffff)
 
@@ -242,6 +245,10 @@ UCharIteratorReserved(UCharIterator *iter, int32_t something);
  * to save and restore the iterator position more efficiently than with
  * getIndex()/move().
  *
+ * The iterator state is defined as a uint32_t value because it is designed
+ * for use in ucol_nextSortKeyPart() which provides 32 bits to store the state
+ * of the character iterator.
+ *
  * With some UCharIterator implementations (e.g., UTF-8),
  * getting and setting the UTF-16 index with existing functions
  * (getIndex(UITER_CURRENT) followed by move(pos, UITER_ZERO)) is possible but
@@ -268,7 +275,7 @@ UCharIteratorReserved(UCharIterator *iter, int32_t something);
  * @see UCharIterator
  * @see UCharIteratorSetState
  * @see UITER_NO_STATE
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
 typedef uint32_t U_CALLCONV
 UCharIteratorGetState(const UCharIterator *iter);
@@ -296,7 +303,7 @@ UCharIteratorGetState(const UCharIterator *iter);
  *
  * @see UCharIterator
  * @see UCharIteratorGetState
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
 typedef void U_CALLCONV
 UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
@@ -317,6 +324,15 @@ UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCod
  * they only use the "public" function pointers and never access the "protected"
  * fields directly.
  *
+ * The current() and next() functions only check the current index against the
+ * limit, and previous() only checks the current index against the start,
+ * to see if the iterator already reached the end of the iteration range.
+ *
+ * The assumption - in all iterators - is that the index is moved via the API,
+ * which means it won't go out of bounds, or the index is modified by
+ * user code that knows enough about the iterator implementation to set valid
+ * index values.
+ *
  * UCharIterator functions return code unit values 0..0xffff,
  * or U_SENTINEL if the iteration bounds are reached.
  *
@@ -443,7 +459,7 @@ struct UCharIterator {
      * This function pointer is NULL if the iterator does not implement it.
      *
      * @see UCharIteratorGet
-     * @draft ICU 2.6
+     * @stable ICU 2.6
      */
     UCharIteratorGetState *getState;
 
@@ -453,7 +469,7 @@ struct UCharIterator {
      * This function pointer is NULL if the iterator does not implement it.
      *
      * @see UCharIteratorSet
-     * @draft ICU 2.6
+     * @stable ICU 2.6
      */
     UCharIteratorSetState *setState;
 };
@@ -476,7 +492,7 @@ struct UCharIterator {
  * @see UnicodeString::char32At()
  * @stable ICU 2.1
  */
-U_CAPI UChar32 U_EXPORT2
+U_STABLE UChar32 U_EXPORT2
 uiter_current32(UCharIterator *iter);
 
 /**
@@ -493,7 +509,7 @@ uiter_current32(UCharIterator *iter);
  * @see U16_NEXT
  * @stable ICU 2.1
  */
-U_CAPI UChar32 U_EXPORT2
+U_STABLE UChar32 U_EXPORT2
 uiter_next32(UCharIterator *iter);
 
 /**
@@ -510,7 +526,7 @@ uiter_next32(UCharIterator *iter);
  * @see U16_PREV
  * @stable ICU 2.1
  */
-U_CAPI UChar32 U_EXPORT2
+U_STABLE UChar32 U_EXPORT2
 uiter_previous32(UCharIterator *iter);
 
 /**
@@ -529,9 +545,9 @@ uiter_previous32(UCharIterator *iter);
  * @see UCharIterator
  * @see UCharIteratorGetState
  * @see UITER_NO_STATE
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
-U_CAPI uint32_t U_EXPORT2
+U_STABLE uint32_t U_EXPORT2
 uiter_getState(const UCharIterator *iter);
 
 /**
@@ -547,9 +563,9 @@ uiter_getState(const UCharIterator *iter);
  *
  * @see UCharIterator
  * @see UCharIteratorSetState
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
-U_CAPI void U_EXPORT2
+U_STABLE void U_EXPORT2
 uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
 
 /**
@@ -574,7 +590,7 @@ uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
  * @see UCharIterator
  * @stable ICU 2.1
  */
-U_CAPI void U_EXPORT2
+U_STABLE void U_EXPORT2
 uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
 
 /**
@@ -595,9 +611,9 @@ uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
  *
  * @see UCharIterator
  * @see uiter_setString
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
-U_CAPI void U_EXPORT2
+U_STABLE void U_EXPORT2
 uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
 
 /**
@@ -631,12 +647,12 @@ uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
  * @param length Length of s in bytes, or -1 if NUL-terminated
  *
  * @see UCharIterator
- * @draft ICU 2.6
+ * @stable ICU 2.6
  */
-U_CAPI void U_EXPORT2
+U_STABLE void U_EXPORT2
 uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
 
-#ifdef XP_CPLUSPLUS
+#if U_SHOW_CPLUSPLUS_API
 
 /**
  * Set up a UCharIterator to wrap around a C++ CharacterIterator.
@@ -658,8 +674,8 @@ uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
  * @see UCharIterator
  * @stable ICU 2.1
  */
-U_CAPI void U_EXPORT2
-uiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter);
+U_STABLE void U_EXPORT2
+uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter);
 
 /**
  * Set up a UCharIterator to iterate over a C++ Replaceable.
@@ -683,10 +699,10 @@ uiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter);
  * @see UCharIterator
  * @stable ICU 2.1
  */
-U_CAPI void U_EXPORT2
-uiter_setReplaceable(UCharIterator *iter, const Replaceable *rep);
+U_STABLE void U_EXPORT2
+uiter_setReplaceable(UCharIterator *iter, const icu::Replaceable *rep);
 
-#endif
+#endif // U_SHOW_CPLUSPLUS_API
 
 U_CDECL_END