ICU 74.2 74.2

uiter.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4*******************************************************************************
5*
6* Copyright (C) 2002-2011 International Business Machines
7* Corporation and others. All Rights Reserved.
8*
9*******************************************************************************
10* file name: uiter.h
11* encoding: UTF-8
12* tab size: 8 (not used)
13* indentation:4
14*
15* created on: 2002jan18
16* created by: Markus W. Scherer
17*/
18
19#ifndef __UITER_H__
20#define __UITER_H__
21
29#include "unicode/utypes.h"
30
31#if U_SHOW_CPLUSPLUS_API
32 U_NAMESPACE_BEGIN
33
34 class CharacterIterator;
35 class Replaceable;
36
37 U_NAMESPACE_END
38#endif
39
40 U_CDECL_BEGIN
41
42 struct UCharIterator;
43 typedef struct UCharIterator UCharIterator;
51 typedef enum UCharIteratorOrigin {
52 UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH
53} UCharIteratorOrigin;
54
56 enum {
71 UITER_UNKNOWN_INDEX=-2
72};
73
74
86#define UITER_NO_STATE ((uint32_t)0xffffffff)
87
106 typedef int32_t U_CALLCONV
107 UCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin);
108
143 typedef int32_t U_CALLCONV
144 UCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin);
145
158 typedef UBool U_CALLCONV
159 UCharIteratorHasNext(UCharIterator *iter);
160
172 typedef UBool U_CALLCONV
173 UCharIteratorHasPrevious(UCharIterator *iter);
174
187 typedef UChar32 U_CALLCONV
188 UCharIteratorCurrent(UCharIterator *iter);
189
203 typedef UChar32 U_CALLCONV
204 UCharIteratorNext(UCharIterator *iter);
205
219 typedef UChar32 U_CALLCONV
220 UCharIteratorPrevious(UCharIterator *iter);
221
233 typedef int32_t U_CALLCONV
234 UCharIteratorReserved(UCharIterator *iter, int32_t something);
235
280 typedef uint32_t U_CALLCONV
281 UCharIteratorGetState(const UCharIterator *iter);
282
308 typedef void U_CALLCONV
309 UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
310
311
341 struct UCharIterator {
347 const void *context;
348
354 int32_t length;
355
361 int32_t start;
362
368 int32_t index;
369
375 int32_t limit;
376
381 int32_t reservedField;
382
390 UCharIteratorGetIndex *getIndex;
391
401 UCharIteratorMove *move;
402
410 UCharIteratorHasNext *hasNext;
411
418 UCharIteratorHasPrevious *hasPrevious;
419
427 UCharIteratorCurrent *current;
428
437 UCharIteratorNext *next;
438
447 UCharIteratorPrevious *previous;
448
455 UCharIteratorReserved *reservedFn;
456
464 UCharIteratorGetState *getState;
465
474 UCharIteratorSetState *setState;
475};
476
495 U_CAPI UChar32 U_EXPORT2
496 uiter_current32(UCharIterator *iter);
497
512 U_CAPI UChar32 U_EXPORT2
513 uiter_next32(UCharIterator *iter);
514
529 U_CAPI UChar32 U_EXPORT2
530 uiter_previous32(UCharIterator *iter);
531
550 U_CAPI uint32_t U_EXPORT2
551 uiter_getState(const UCharIterator *iter);
552
568 U_CAPI void U_EXPORT2
569 uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);
570
593 U_CAPI void U_EXPORT2
594 uiter_setString(UCharIterator *iter, const UChar *s, int32_t length);
595
616 U_CAPI void U_EXPORT2
617 uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);
618
652 U_CAPI void U_EXPORT2
653 uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);
654
655#if U_SHOW_CPLUSPLUS_API
656
677 U_CAPI void U_EXPORT2
678 uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter);
679
702 U_CAPI void U_EXPORT2
703 uiter_setReplaceable(UCharIterator *iter, const icu::Replaceable *rep);
704
705#endif
706
707 U_CDECL_END
708
709#endif
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition chariter.h:361
icu::Replaceable
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
Definition rep.h:77
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:866
UCharIterator
C API for code unit iteration.
Definition uiter.h:341
UCharIterator::move
UCharIteratorMove * move
(public) Moves the current position relative to the start or limit of the iteration range,...
Definition uiter.h:401
UCharIterator::index
int32_t index
(protected) Current index or similar.
Definition uiter.h:368
UCharIterator::context
const void * context
(protected) Pointer to string or wrapped object or similar.
Definition uiter.h:347
UCharIterator::getIndex
UCharIteratorGetIndex * getIndex
(public) Returns the current position or the start or limit index of the iteration range.
Definition uiter.h:390
UCharIterator::length
int32_t length
(protected) Length of string or similar.
Definition uiter.h:354
UCharIterator::hasPrevious
UCharIteratorHasPrevious * hasPrevious
(public) Check if previous() can still return another code unit.
Definition uiter.h:418
UCharIterator::reservedField
int32_t reservedField
(protected) Used by UTF-8 iterators and possibly others.
Definition uiter.h:381
UCharIterator::previous
UCharIteratorPrevious * previous
(public) Decrement the index and return the code unit from there (pre-decrement, like s[–i]),...
Definition uiter.h:447
UCharIterator::limit
int32_t limit
(protected) Limit index or similar.
Definition uiter.h:375
UCharIterator::reservedFn
UCharIteratorReserved * reservedFn
(public) Reserved for future use.
Definition uiter.h:455
UCharIterator::next
UCharIteratorNext * next
(public) Return the code unit at the current index and increment the index (post-increment,...
Definition uiter.h:437
UCharIterator::current
UCharIteratorCurrent * current
(public) Return the code unit at the current position, or U_SENTINEL if there is none (index is at th...
Definition uiter.h:427
UCharIterator::hasNext
UCharIteratorHasNext * hasNext
(public) Check if current() and next() can still return another code unit.
Definition uiter.h:410
UCharIterator::start
int32_t start
(protected) Start index or similar.
Definition uiter.h:361
UCharIterator::setState
UCharIteratorSetState * setState
(public) Restore the iterator state from the state word from a call to getState().
Definition uiter.h:474
UCharIterator::getState
UCharIteratorGetState * getState
(public) Return the state of the iterator, to be restored later with setState().
Definition uiter.h:464
uiter_setString
U_CAPI void uiter_setString(UCharIterator *iter, const UChar *s, int32_t length)
Set up a UCharIterator to iterate over a string.
uiter_next32
U_CAPI UChar32 uiter_next32(UCharIterator *iter)
Helper function for UCharIterator to get the next code point.
UCharIteratorSetState
void UCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode)
Function type declaration for UCharIterator.setState().
Definition uiter.h:309
uiter_setReplaceable
U_CAPI void uiter_setReplaceable(UCharIterator *iter, const icu::Replaceable *rep)
Set up a UCharIterator to iterate over a C++ Replaceable.
uiter_setUTF8
U_CAPI void uiter_setUTF8(UCharIterator *iter, const char *s, int32_t length)
Set up a UCharIterator to iterate over a UTF-8 string.
UCharIteratorCurrent
UChar32 UCharIteratorCurrent(UCharIterator *iter)
Function type declaration for UCharIterator.current().
Definition uiter.h:188
UCharIteratorHasPrevious
UBool UCharIteratorHasPrevious(UCharIterator *iter)
Function type declaration for UCharIterator.hasPrevious().
Definition uiter.h:173
UCharIteratorGetIndex
int32_t UCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin)
Function type declaration for UCharIterator.getIndex().
Definition uiter.h:107
UCharIteratorNext
UChar32 UCharIteratorNext(UCharIterator *iter)
Function type declaration for UCharIterator.next().
Definition uiter.h:204
uiter_setState
U_CAPI void uiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode)
Restore the "state" of the iterator using a state word from a getState() call.
uiter_previous32
U_CAPI UChar32 uiter_previous32(UCharIterator *iter)
Helper function for UCharIterator to get the previous code point.
uiter_getState
U_CAPI uint32_t uiter_getState(const UCharIterator *iter)
Get the "state" of the iterator in the form of a single 32-bit word.
UCharIteratorGetState
uint32_t UCharIteratorGetState(const UCharIterator *iter)
Function type declaration for UCharIterator.getState().
Definition uiter.h:281
UCharIteratorMove
int32_t UCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin)
Function type declaration for UCharIterator.move().
Definition uiter.h:144
UCharIteratorPrevious
UChar32 UCharIteratorPrevious(UCharIterator *iter)
Function type declaration for UCharIterator.previous().
Definition uiter.h:220
UCharIteratorHasNext
UBool UCharIteratorHasNext(UCharIterator *iter)
Function type declaration for UCharIterator.hasNext().
Definition uiter.h:159
UITER_UNKNOWN_INDEX
@ UITER_UNKNOWN_INDEX
Constant value that may be returned by UCharIteratorMove indicating that the final UTF-16 index is no...
Definition uiter.h:71
UCharIteratorReserved
int32_t UCharIteratorReserved(UCharIterator *iter, int32_t something)
Function type declaration for UCharIterator.reservedFn().
Definition uiter.h:234
UCharIteratorOrigin
UCharIteratorOrigin
Origin constants for UCharIterator.getIndex() and UCharIterator.move().
Definition uiter.h:51
uiter_setCharacterIterator
U_CAPI void uiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter)
Set up a UCharIterator to wrap around a C++ CharacterIterator.
uiter_setUTF16BE
U_CAPI void uiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length)
Set up a UCharIterator to iterate over a UTF-16BE string (byte vector with a big-endian pair of bytes...
uiter_current32
U_CAPI UChar32 uiter_current32(UCharIterator *iter)
Helper function for UCharIterator to get the code point at the current index.
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:435
U_CDECL_END
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition umachine.h:86
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:386
U_CDECL_BEGIN
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition umachine.h:85
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:415