18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*******************************************************************************
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   Copyright (C) 2002-2004, International Business Machines
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   Corporation and others.  All Rights Reserved.
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*******************************************************************************
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   file name:  uiter.h
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   encoding:   US-ASCII
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   tab size:   8 (not used)
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   indentation:4
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   created on: 2002jan18
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*   created by: Markus W. Scherer
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project*/
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef __UITER_H__
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define __UITER_H__
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * \file
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * \brief C API: Unicode Character Iteration
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "unicode/utypes.h"
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifdef XP_CPLUSPLUS
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    U_NAMESPACE_BEGIN
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class CharacterIterator;
338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    class Replaceable;
348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    U_NAMESPACE_END
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_CDECL_BEGIN
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectstruct UCharIterator;
418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef struct UCharIterator UCharIterator; /**< C typedef for struct UCharIterator. @stable ICU 2.1 */
428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Origin constants for UCharIterator.getIndex() and UCharIterator.move().
458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorMove
468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef enum UCharIteratorOrigin {
508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH
518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} UCharIteratorOrigin;
528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/** Constants for UCharIterator. @stable ICU 2.6 */
548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectenum {
558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * Constant value that may be returned by UCharIteratorMove
578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * indicating that the final UTF-16 index is not known, but that the move succeeded.
588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * This can occur when moving relative to limit or length, or
598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * when moving relative to the current index after a setState()
608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * when the current UTF-16 index is not known.
618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * It would be very inefficient to have to count from the beginning of the text
638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * just to get the current/limit/length index after moving relative to it.
648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * The actual index can be determined with getIndex(UITER_CURRENT)
658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * which will count the UChars if necessary.
668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.6
688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UITER_UNKNOWN_INDEX=-2
708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project};
718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Constant for UCharIterator getState() indicating an error or
758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * an unknown state.
768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Returned by uiter_getState()/UCharIteratorGetState
778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * when an error occurs.
788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Also, some UCharIterator implementations may not be able to return
798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * a valid state for each position. This will be clearly documented
808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * for each such iterator (none of the public ones here).
818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define UITER_NO_STATE ((uint32_t)0xffffffff)
858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.getIndex().
888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Gets the current position, or the start or limit of the
908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * iteration range.
918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This function may perform slowly for UITER_CURRENT after setState() was called,
938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or for UITER_LENGTH, because an iterator implementation may have to count
948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * UChars if the underlying storage is not UTF-16.
958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param origin get the 0, start, limit, length, or current index
988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the requested index, or U_SENTINEL in an error condition
998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorOrigin
1018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef int32_t U_CALLCONV
1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin);
1068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.move().
1098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Use iter->move(iter, index, UITER_ZERO) like CharacterIterator::setIndex(index).
1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Moves the current position relative to the start or limit of the
1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * iteration range, or relative to the current position itself.
1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The movement is expressed in numbers of code units forward
1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or backward by specifying a positive or negative delta.
1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Out of bounds movement will be pinned to the start or limit.
1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This function may perform slowly for moving relative to UITER_LENGTH
1198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * because an iterator implementation may have to count the rest of the
1208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * UChars if the native storage is not UTF-16.
1218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * When moving relative to the limit or length, or
1238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * relative to the current position after setState() was called,
1248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move() may return UITER_UNKNOWN_INDEX (-2) to avoid an inefficient
1258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * determination of the actual UTF-16 index.
1268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The actual index can be determined with getIndex(UITER_CURRENT)
1278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * which will count the UChars if necessary.
1288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * See UITER_UNKNOWN_INDEX for details.
1298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
1318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param delta can be positive, zero, or negative
1328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param origin move relative to the 0, start, limit, length, or current index
1338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the new index, or U_SENTINEL on an error condition,
1348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *         or UITER_UNKNOWN_INDEX when the index is not known.
1358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorOrigin
1378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
1388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UITER_UNKNOWN_INDEX
1398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
1408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef int32_t U_CALLCONV
1428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin);
1438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.hasNext().
1468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Check if current() and next() can still
1488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * return another code unit.
1498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
1518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return boolean value for whether current() and next() can still return another code unit
1528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
1548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
1558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef UBool U_CALLCONV
1578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorHasNext(UCharIterator *iter);
1588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.hasPrevious().
1618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Check if previous() can still return another code unit.
1638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
1658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return boolean value for whether previous() can still return another code unit
1668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
1688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
1698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef UBool U_CALLCONV
1718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorHasPrevious(UCharIterator *iter);
1728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.current().
1758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Return the code unit at the current position,
1778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or U_SENTINEL if there is none (index is at the limit).
1788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
1808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the current code unit
1818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
1838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
1848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef UChar32 U_CALLCONV
1868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorCurrent(UCharIterator *iter);
1878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.next().
1908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Return the code unit at the current index and increment
1928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the index (post-increment, like s[i++]),
1938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or return U_SENTINEL if there is none (index is at the limit).
1948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
1968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the current code unit (and post-increment the current index)
1978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
1998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
2008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
2018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef UChar32 U_CALLCONV
2028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorNext(UCharIterator *iter);
2038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
2048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
2058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.previous().
2068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Decrement the index and return the code unit from there
2088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (pre-decrement, like s[--i]),
2098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or return U_SENTINEL if there is none (index is at the start).
2108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
2128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the previous code unit (after pre-decrementing the current index)
2138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
2158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
2168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
2178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef UChar32 U_CALLCONV
2188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorPrevious(UCharIterator *iter);
2198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
2208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
2218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.reservedFn().
2228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Reserved for future use.
2238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
2258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param something some integer argument
2268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return some integer
2278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
2298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
2308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
2318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef int32_t U_CALLCONV
2328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorReserved(UCharIterator *iter, int32_t something);
2338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
2348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
2358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.getState().
2368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Get the "state" of the iterator in the form of a single 32-bit word.
2388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * It is recommended that the state value be calculated to be as small as
2398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * is feasible. For strings with limited lengths, fewer than 32 bits may
2408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * be sufficient.
2418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This is used together with setState()/UCharIteratorSetState
2438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * to save and restore the iterator position more efficiently than with
2448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getIndex()/move().
2458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The iterator state is defined as a uint32_t value because it is designed
2478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * for use in ucol_nextSortKeyPart() which provides 32 bits to store the state
2488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * of the character iterator.
2498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * With some UCharIterator implementations (e.g., UTF-8),
2518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getting and setting the UTF-16 index with existing functions
2528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (getIndex(UITER_CURRENT) followed by move(pos, UITER_ZERO)) is possible but
2538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * relatively slow because the iterator has to "walk" from a known index
2548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * to the requested one.
2558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This takes more time the farther it needs to go.
2568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * An opaque state value allows an iterator implementation to provide
2588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * an internal index (UTF-8: the source byte array index) for
2598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * fast, constant-time restoration.
2608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * After calling setState(), a getIndex(UITER_CURRENT) may be slow because
2628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the UTF-16 index may not be restored as well, but the iterator can deliver
2638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the correct text contents and move relative to the current position
2648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * without performance degradation.
2658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Some UCharIterator implementations may not be able to return
2678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * a valid state for each position, in which case they return UITER_NO_STATE instead.
2688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This will be clearly documented for each such iterator (none of the public ones here).
2698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
2718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the state word
2728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
2748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorSetState
2758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UITER_NO_STATE
2768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
2778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
2788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef uint32_t U_CALLCONV
2798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorGetState(const UCharIterator *iter);
2808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
2818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
2828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Function type declaration for UCharIterator.setState().
2838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Restore the "state" of the iterator using a state word from a getState() call.
2858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The iterator object need not be the same one as for which getState() was called,
2868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * but it must be of the same type (set up using the same uiter_setXYZ function)
2878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and it must iterate over the same string
2888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (binary identical regardless of memory address).
2898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * For more about the state word see UCharIteratorGetState.
2908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * After calling setState(), a getIndex(UITER_CURRENT) may be slow because
2928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the UTF-16 index may not be restored as well, but the iterator can deliver
2938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the correct text contents and move relative to the current position
2948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * without performance degradation.
2958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
2978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param state the state word from a getState() call
2988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *              on a same-type, same-string iterator
2998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param pErrorCode Must be a valid pointer to an error code value,
3008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                   which must not indicate a failure before the function call.
3018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
3038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorGetState
3048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
3058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
3068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef void U_CALLCONV
3078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectUCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
3088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
3118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * C API for code unit iteration.
3128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This can be used as a C wrapper around
3138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CharacterIterator, Replaceable, or implemented using simple strings, etc.
3148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * There are two roles for using UCharIterator:
3168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * A "provider" sets the necessary function pointers and controls the "protected"
3188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * fields of the UCharIterator structure. A "provider" passes a UCharIterator
3198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * into C APIs that need a UCharIterator as an abstract, flexible string interface.
3208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Implementations of such C APIs are "callers" of UCharIterator functions;
3228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * they only use the "public" function pointers and never access the "protected"
3238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * fields directly.
3248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The current() and next() functions only check the current index against the
3268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * limit, and previous() only checks the current index against the start,
3278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * to see if the iterator already reached the end of the iteration range.
3288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The assumption - in all iterators - is that the index is moved via the API,
3308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * which means it won't go out of bounds, or the index is modified by
3318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * user code that knows enough about the iterator implementation to set valid
3328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * index values.
3338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * UCharIterator functions return code unit values 0..0xffff,
3358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or U_SENTINEL if the iteration bounds are reached.
3368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
3378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
3388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
3398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectstruct UCharIterator {
3408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (protected) Pointer to string or wrapped object or similar.
3428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * Not used by caller.
3438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    const void *context;
3468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (protected) Length of string or similar.
3498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * Not used by caller.
3508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int32_t length;
3538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (protected) Start index or similar.
3568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * Not used by caller.
3578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int32_t start;
3608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (protected) Current index or similar.
3638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * Not used by caller.
3648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int32_t index;
3678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (protected) Limit index or similar.
3708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * Not used by caller.
3718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int32_t limit;
3748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (protected) Used by UTF-8 iterators and possibly others.
3778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    int32_t reservedField;
3808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Returns the current position or the
3838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * start or limit index of the iteration range.
3848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
3858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorGetIndex
3868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorGetIndex *getIndex;
3898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
3918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Moves the current position relative to the start or limit of the
3928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * iteration range, or relative to the current position itself.
3938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * The movement is expressed in numbers of code units forward
3948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * or backward by specifying a positive or negative delta.
3958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
3968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorMove
3978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
3988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
3998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorMove *move;
4008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Check if current() and next() can still
4038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * return another code unit.
4048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorHasNext
4068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
4078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorHasNext *hasNext;
4098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Check if previous() can still return another code unit.
4128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorHasPrevious
4148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
4158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorHasPrevious *hasPrevious;
4178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Return the code unit at the current position,
4208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * or U_SENTINEL if there is none (index is at the limit).
4218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorCurrent
4238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
4248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorCurrent *current;
4268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Return the code unit at the current index and increment
4298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * the index (post-increment, like s[i++]),
4308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * or return U_SENTINEL if there is none (index is at the limit).
4318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorNext
4338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
4348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorNext *next;
4368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Decrement the index and return the code unit from there
4398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (pre-decrement, like s[--i]),
4408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * or return U_SENTINEL if there is none (index is at the start).
4418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorPrevious
4438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
4448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorPrevious *previous;
4468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Reserved for future use. Currently NULL.
4498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorReserved
4518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.1
4528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorReserved *reservedFn;
4548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Return the state of the iterator, to be restored later with setState().
4578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * This function pointer is NULL if the iterator does not implement it.
4588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorGet
4608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.6
4618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorGetState *getState;
4638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    /**
4658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * (public) Restore the iterator state from the state word from a call
4668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * to getState().
4678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * This function pointer is NULL if the iterator does not implement it.
4688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     *
4698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @see UCharIteratorSet
4708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     * @stable ICU 2.6
4718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project     */
4728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project    UCharIteratorSetState *setState;
4738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project};
4748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
4768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Helper function for UCharIterator to get the code point
4778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * at the current index.
4788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
4798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Return the code point that includes the code unit at the current position,
4808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or U_SENTINEL if there is none (index is at the limit).
4818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * If the current code unit is a lead or trail surrogate,
4828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * then the following or preceding surrogate is used to form
4838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the code point value.
4848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
4858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
4868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the current code point
4878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
4888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
4898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see U16_GET
4908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UnicodeString::char32At()
4918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
4928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
4938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE UChar32 U_EXPORT2
4948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_current32(UCharIterator *iter);
4958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
4968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
4978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Helper function for UCharIterator to get the next code point.
4988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
4998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Return the code point at the current index and increment
5008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * the index (post-increment, like s[i++]),
5018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or return U_SENTINEL if there is none (index is at the limit).
5028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
5048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the current code point (and post-increment the current index)
5058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
5078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see U16_NEXT
5088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
5098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
5108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE UChar32 U_EXPORT2
5118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_next32(UCharIterator *iter);
5128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
5138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
5148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Helper function for UCharIterator to get the previous code point.
5158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Decrement the index and return the code point from there
5178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (pre-decrement, like s[--i]),
5188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or return U_SENTINEL if there is none (index is at the start).
5198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
5218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the previous code point (after pre-decrementing the current index)
5228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
5248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see U16_PREV
5258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
5268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
5278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE UChar32 U_EXPORT2
5288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_previous32(UCharIterator *iter);
5298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
5308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
5318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Get the "state" of the iterator in the form of a single 32-bit word.
5328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This is a convenience function that calls iter->getState(iter)
5338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * if iter->getState is not NULL;
5348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * if it is NULL or any other error occurs, then UITER_NO_STATE is returned.
5358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Some UCharIterator implementations may not be able to return
5378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * a valid state for each position, in which case they return UITER_NO_STATE instead.
5388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This will be clearly documented for each such iterator (none of the public ones here).
5398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
5418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return the state word
5428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
5448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorGetState
5458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UITER_NO_STATE
5468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
5478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
5488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE uint32_t U_EXPORT2
5498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_getState(const UCharIterator *iter);
5508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
5518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
5528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Restore the "state" of the iterator using a state word from a getState() call.
5538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This is a convenience function that calls iter->setState(iter, state, pErrorCode)
5548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * if iter->setState is not NULL; if it is NULL, then U_UNSUPPORTED_ERROR is set.
5558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter the UCharIterator structure ("this pointer")
5578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param state the state word from a getState() call
5588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *              on a same-type, same-string iterator
5598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param pErrorCode Must be a valid pointer to an error code value,
5608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                   which must not indicate a failure before the function call.
5618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
5638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIteratorSetState
5648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
5658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
5668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE void U_EXPORT2
5678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
5688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
5698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
5708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Set up a UCharIterator to iterate over a string.
5718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Sets the UCharIterator function pointers for iteration over the string s
5738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * with iteration boundaries start=index=0 and length=limit=string length.
5748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The "provider" may set the start, index, and limit values at any time
5758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * within the range 0..length.
5768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The length field will be ignored.
5778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The string pointer s is set into UCharIterator.context without copying
5798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or reallocating the string contents.
5808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getState() simply returns the current index.
5828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move() will always return the final index.
5838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter UCharIterator structure to be set for iteration
5858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param s String to iterate over
5868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param length Length of s, or -1 if NUL-terminated
5878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
5898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
5908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
5918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE void U_EXPORT2
5928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
5938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
5948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
5958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Set up a UCharIterator to iterate over a UTF-16BE string
5968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (byte vector with a big-endian pair of bytes per UChar).
5978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
5988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Everything works just like with a normal UChar iterator (uiter_setString),
5998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * except that UChars are assembled from byte pairs,
6008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and that the length argument here indicates an even number of bytes.
6018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getState() simply returns the current index.
6038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move() will always return the final index.
6048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter UCharIterator structure to be set for iteration
6068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param s UTF-16BE string to iterate over
6078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param length Length of s as an even number of bytes, or -1 if NUL-terminated
6088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *               (NUL means pair of 0 bytes at even index from s)
6098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
6118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see uiter_setString
6128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
6138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
6148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE void U_EXPORT2
6158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
6168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
6178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
6188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Set up a UCharIterator to iterate over a UTF-8 string.
6198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Sets the UCharIterator function pointers for iteration over the UTF-8 string s
6218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * with UTF-8 iteration boundaries 0 and length.
6228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The implementation counts the UTF-16 index on the fly and
6238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * lazily evaluates the UTF-16 length of the text.
6248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The start field is used as the UTF-8 offset, the limit field as the UTF-8 length.
6268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * When the reservedField is not 0, then it contains a supplementary code point
6278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and the UTF-16 index is between the two corresponding surrogates.
6288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * At that point, the UTF-8 index is behind that code point.
6298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The UTF-8 string pointer s is set into UCharIterator.context without copying
6318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or reallocating the string contents.
6328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getState() returns a state value consisting of
6348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * - the current UTF-8 source byte index (bits 31..1)
6358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * - a flag (bit 0) that indicates whether the UChar position is in the middle
6368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   of a surrogate pair
6378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   (from a 4-byte UTF-8 sequence for the corresponding supplementary code point)
6388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getState() cannot also encode the UTF-16 index in the state value.
6408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move(relative to limit or length), or
6418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move(relative to current) after setState(), may return UITER_UNKNOWN_INDEX.
6428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter UCharIterator structure to be set for iteration
6448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param s UTF-8 string to iterate over
6458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param length Length of s in bytes, or -1 if NUL-terminated
6468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
6488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
6498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
6508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE void U_EXPORT2
6518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
6528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
6538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifdef XP_CPLUSPLUS
6548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
6558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
6568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Set up a UCharIterator to wrap around a C++ CharacterIterator.
6578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Sets the UCharIterator function pointers for iteration using the
6598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CharacterIterator charIter.
6608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The CharacterIterator pointer charIter is set into UCharIterator.context
6628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * without copying or cloning the CharacterIterator object.
6638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The other "protected" UCharIterator fields are set to 0 and will be ignored.
6648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The iteration index and boundaries are controlled by the CharacterIterator.
6658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getState() simply returns the current index.
6678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move() will always return the final index.
6688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter UCharIterator structure to be set for iteration
6708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param charIter CharacterIterator to wrap
6718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
6738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
6748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
6758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE void U_EXPORT2
6768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_setCharacterIterator(UCharIterator *iter, CharacterIterator *charIter);
6778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
6788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
6798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Set up a UCharIterator to iterate over a C++ Replaceable.
6808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Sets the UCharIterator function pointers for iteration over the
6828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Replaceable rep with iteration boundaries start=index=0 and
6838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * length=limit=rep->length().
6848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The "provider" may set the start, index, and limit values at any time
6858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * within the range 0..length=rep->length().
6868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The length field will be ignored.
6878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The Replaceable pointer rep is set into UCharIterator.context without copying
6898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * or cloning/reallocating the Replaceable object.
6908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * getState() simply returns the current index.
6928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * move() will always return the final index.
6938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param iter UCharIterator structure to be set for iteration
6958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param rep Replaceable to iterate over
6968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
6978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see UCharIterator
6988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.1
6998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
7008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE void U_EXPORT2
7018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuiter_setReplaceable(UCharIterator *iter, const Replaceable *rep);
7028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
7038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif
7048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
7058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_CDECL_END
7068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
7078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif
708