intl/icu/source/common/unorm_it.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2003, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 * file name: unorm_it.h
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * created on: 2003jan21
michael@0 14 * created by: Markus W. Scherer
michael@0 15 */
michael@0 16
michael@0 17 #ifndef __UNORM_IT_H__
michael@0 18 #define __UNORM_IT_H__
michael@0 19
michael@0 20 #include "unicode/utypes.h"
michael@0 21
michael@0 22 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_NORMALIZATION
michael@0 23
michael@0 24 #include "unicode/uiter.h"
michael@0 25 #include "unicode/unorm.h"
michael@0 26
michael@0 27 /**
michael@0 28 * Normalizing UCharIterator wrapper.
michael@0 29 * This internal API basically duplicates the functionality of the C++ Normalizer
michael@0 30 * but
michael@0 31 * - it actually implements a character iterator (UCharIterator)
michael@0 32 * with few restrictions (see unorm_setIter())
michael@0 33 * - it supports UCharIterator getState()/setState()
michael@0 34 * - it uses lower-level APIs and buffers more text and states,
michael@0 35 * hopefully resulting in higher performance
michael@0 36 *
michael@0 37 * Usage example:
michael@0 38 * \code
michael@0 39 * function(UCharIterator *srcIter) {
michael@0 40 * UNormIterator *uni;
michael@0 41 * UCharIterator *iter;
michael@0 42 * UErrorCode errorCode;
michael@0 43 *
michael@0 44 * errorCode=U_ZERO_ERROR;
michael@0 45 * uni=unorm_openIter(&errorCode);
michael@0 46 * if(U_FAILURE(errorCode)) {
michael@0 47 * // report error
michael@0 48 * return;
michael@0 49 * }
michael@0 50 *
michael@0 51 * iter=unorm_setIter(uni, srcIter, UNORM_FCD, &errorCode);
michael@0 52 * if(U_FAILURE(errorCode)) {
michael@0 53 * // report error
michael@0 54 * } else {
michael@0 55 * // use iter to iterate over the canonically ordered
michael@0 56 * // version of srcIter's text
michael@0 57 * uint32_t state;
michael@0 58 *
michael@0 59 * ...
michael@0 60 *
michael@0 61 * state=uiter_getState(iter);
michael@0 62 * if(state!=UITER_NO_STATE) {
michael@0 63 * // use valid state, store it, use iter some more
michael@0 64 * ...
michael@0 65 *
michael@0 66 * // later restore iter to the saved state:
michael@0 67 * uiter_setState(iter, state, &errorCode);
michael@0 68 *
michael@0 69 * ...
michael@0 70 * }
michael@0 71 *
michael@0 72 * ...
michael@0 73 * }
michael@0 74 * unorm_closeIter(uni);
michael@0 75 * }
michael@0 76 * \endcode
michael@0 77 *
michael@0 78 * See also the ICU test suites.
michael@0 79 *
michael@0 80 * @internal
michael@0 81 */
michael@0 82 struct UNormIterator;
michael@0 83 typedef struct UNormIterator UNormIterator;
michael@0 84
michael@0 85 /**
michael@0 86 * Size of a stack buffer to hold a UNormIterator, see the stackMem parameter
michael@0 87 * of unorm_openIter().
michael@0 88 *
michael@0 89 * @internal
michael@0 90 */
michael@0 91 #define UNORM_ITER_SIZE 1024
michael@0 92
michael@0 93 /**
michael@0 94 * Open a normalizing iterator. Must be closed later.
michael@0 95 * Use unorm_setIter().
michael@0 96 *
michael@0 97 * @param stackMem Pointer to preallocated (stack-allocated) buffer to hold
michael@0 98 * the UNormIterator if possible; can be NULL.
michael@0 99 * @param stackMemSize Number of bytes at stackMem; can be 0,
michael@0 100 * or should be >= UNORM_ITER_SIZE for a non-NULL stackMem.
michael@0 101 * @param pErrorCode ICU error code
michael@0 102 * @return an allocated and pre-initialized UNormIterator
michael@0 103 * @internal
michael@0 104 */
michael@0 105 U_CAPI UNormIterator * U_EXPORT2
michael@0 106 unorm_openIter(void *stackMem, int32_t stackMemSize, UErrorCode *pErrorCode);
michael@0 107
michael@0 108 /**
michael@0 109 * Close a normalizing iterator.
michael@0 110 *
michael@0 111 * @param uni UNormIterator from unorm_openIter()
michael@0 112 * @internal
michael@0 113 */
michael@0 114 U_CAPI void U_EXPORT2
michael@0 115 unorm_closeIter(UNormIterator *uni);
michael@0 116
michael@0 117 /**
michael@0 118 * Set a UCharIterator and a normalization mode for the normalizing iterator
michael@0 119 * to wrap. The normalizing iterator will read from the character iterator,
michael@0 120 * normalize the text, and in turn deliver it with its own wrapper UCharIterator
michael@0 121 * interface which it returns.
michael@0 122 *
michael@0 123 * The source iterator remains at its current position through the unorm_setIter()
michael@0 124 * call but will be used and moved as soon as the
michael@0 125 * the returned normalizing iterator is.
michael@0 126 *
michael@0 127 * The returned interface pointer is valid for as long as the normalizing iterator
michael@0 128 * is open and until another unorm_setIter() call is made on it.
michael@0 129 *
michael@0 130 * The normalizing iterator's UCharIterator interface has the following properties:
michael@0 131 * - getIndex() and move() will almost always return UITER_UNKNOWN_INDEX
michael@0 132 * - getState() will return UITER_NO_STATE for unknown states for positions
michael@0 133 * that are not at normalization boundaries
michael@0 134 *
michael@0 135 * @param uni UNormIterator from unorm_openIter()
michael@0 136 * @param iter The source text UCharIterator to be wrapped. It is aliases into the normalizing iterator.
michael@0 137 * Must support getState() and setState().
michael@0 138 * @param mode The normalization mode.
michael@0 139 * @param pErrorCode ICU error code
michael@0 140 * @return an alias to the normalizing iterator's UCharIterator interface
michael@0 141 * @internal
michael@0 142 */
michael@0 143 U_CAPI UCharIterator * U_EXPORT2
michael@0 144 unorm_setIter(UNormIterator *uni, UCharIterator *iter, UNormalizationMode mode, UErrorCode *pErrorCode);
michael@0 145
michael@0 146 #endif /* uconfig.h switches */
michael@0 147
michael@0 148 #endif

mercurial