intl/icu/source/common/unorm_it.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unorm_it.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,148 @@
     1.4 +/*
     1.5 +*******************************************************************************
     1.6 +*
     1.7 +*   Copyright (C) 2003, International Business Machines
     1.8 +*   Corporation and others.  All Rights Reserved.
     1.9 +*
    1.10 +*******************************************************************************
    1.11 +*   file name:  unorm_it.h
    1.12 +*   encoding:   US-ASCII
    1.13 +*   tab size:   8 (not used)
    1.14 +*   indentation:4
    1.15 +*
    1.16 +*   created on: 2003jan21
    1.17 +*   created by: Markus W. Scherer
    1.18 +*/
    1.19 +
    1.20 +#ifndef __UNORM_IT_H__
    1.21 +#define __UNORM_IT_H__
    1.22 +
    1.23 +#include "unicode/utypes.h"
    1.24 +
    1.25 +#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_NORMALIZATION
    1.26 +
    1.27 +#include "unicode/uiter.h"
    1.28 +#include "unicode/unorm.h"
    1.29 +
    1.30 +/**
    1.31 + * Normalizing UCharIterator wrapper.
    1.32 + * This internal API basically duplicates the functionality of the C++ Normalizer
    1.33 + * but
    1.34 + * - it actually implements a character iterator (UCharIterator)
    1.35 + *   with few restrictions (see unorm_setIter())
    1.36 + * - it supports UCharIterator getState()/setState()
    1.37 + * - it uses lower-level APIs and buffers more text and states,
    1.38 + *   hopefully resulting in higher performance
    1.39 + *
    1.40 + * Usage example:
    1.41 + * \code
    1.42 + * function(UCharIterator *srcIter) {
    1.43 + *     UNormIterator *uni;
    1.44 + *     UCharIterator *iter;
    1.45 + *     UErrorCode errorCode;
    1.46 + * 
    1.47 + *     errorCode=U_ZERO_ERROR;
    1.48 + *     uni=unorm_openIter(&errorCode);
    1.49 + *     if(U_FAILURE(errorCode)) {
    1.50 + *         // report error
    1.51 + *         return;
    1.52 + *     }
    1.53 + * 
    1.54 + *     iter=unorm_setIter(uni, srcIter, UNORM_FCD, &errorCode);
    1.55 + *     if(U_FAILURE(errorCode)) {
    1.56 + *         // report error
    1.57 + *     } else {
    1.58 + *         // use iter to iterate over the canonically ordered
    1.59 + *         // version of srcIter's text
    1.60 + *         uint32_t state;
    1.61 + * 
    1.62 + *         ...
    1.63 + * 
    1.64 + *         state=uiter_getState(iter);
    1.65 + *         if(state!=UITER_NO_STATE) {
    1.66 + *             // use valid state, store it, use iter some more
    1.67 + *             ...
    1.68 + * 
    1.69 + *             // later restore iter to the saved state:
    1.70 + *             uiter_setState(iter, state, &errorCode);
    1.71 + * 
    1.72 + *             ...
    1.73 + *         }
    1.74 + * 
    1.75 + *         ...
    1.76 + *     }
    1.77 + *     unorm_closeIter(uni);
    1.78 + * }
    1.79 + * \endcode
    1.80 + *
    1.81 + * See also the ICU test suites.
    1.82 + *
    1.83 + * @internal
    1.84 + */
    1.85 +struct UNormIterator;
    1.86 +typedef struct UNormIterator UNormIterator;
    1.87 +
    1.88 +/**
    1.89 + * Size of a stack buffer to hold a UNormIterator, see the stackMem parameter
    1.90 + * of unorm_openIter().
    1.91 + *
    1.92 + * @internal
    1.93 + */
    1.94 +#define UNORM_ITER_SIZE 1024
    1.95 +
    1.96 +/**
    1.97 + * Open a normalizing iterator. Must be closed later.
    1.98 + * Use unorm_setIter().
    1.99 + *
   1.100 + * @param stackMem Pointer to preallocated (stack-allocated) buffer to hold
   1.101 + *                 the UNormIterator if possible; can be NULL.
   1.102 + * @param stackMemSize Number of bytes at stackMem; can be 0,
   1.103 + *                     or should be >= UNORM_ITER_SIZE for a non-NULL stackMem.
   1.104 + * @param pErrorCode ICU error code
   1.105 + * @return an allocated and pre-initialized UNormIterator
   1.106 + * @internal
   1.107 + */
   1.108 +U_CAPI UNormIterator * U_EXPORT2
   1.109 +unorm_openIter(void *stackMem, int32_t stackMemSize, UErrorCode *pErrorCode);
   1.110 +
   1.111 +/**
   1.112 + * Close a normalizing iterator.
   1.113 + *
   1.114 + * @param uni UNormIterator from unorm_openIter()
   1.115 + * @internal
   1.116 + */
   1.117 +U_CAPI void U_EXPORT2
   1.118 +unorm_closeIter(UNormIterator *uni);
   1.119 +
   1.120 +/**
   1.121 + * Set a UCharIterator and a normalization mode for the normalizing iterator
   1.122 + * to wrap. The normalizing iterator will read from the character iterator,
   1.123 + * normalize the text, and in turn deliver it with its own wrapper UCharIterator
   1.124 + * interface which it returns.
   1.125 + *
   1.126 + * The source iterator remains at its current position through the unorm_setIter()
   1.127 + * call but will be used and moved as soon as the
   1.128 + * the returned normalizing iterator is.
   1.129 + *
   1.130 + * The returned interface pointer is valid for as long as the normalizing iterator
   1.131 + * is open and until another unorm_setIter() call is made on it.
   1.132 + *
   1.133 + * The normalizing iterator's UCharIterator interface has the following properties:
   1.134 + * - getIndex() and move() will almost always return UITER_UNKNOWN_INDEX
   1.135 + * - getState() will return UITER_NO_STATE for unknown states for positions
   1.136 + *              that are not at normalization boundaries
   1.137 + *
   1.138 + * @param uni UNormIterator from unorm_openIter()
   1.139 + * @param iter The source text UCharIterator to be wrapped. It is aliases into the normalizing iterator.
   1.140 + *             Must support getState() and setState().
   1.141 + * @param mode The normalization mode.
   1.142 + * @param pErrorCode ICU error code
   1.143 + * @return an alias to the normalizing iterator's UCharIterator interface
   1.144 + * @internal
   1.145 + */
   1.146 +U_CAPI UCharIterator * U_EXPORT2
   1.147 +unorm_setIter(UNormIterator *uni, UCharIterator *iter, UNormalizationMode mode, UErrorCode *pErrorCode);
   1.148 +
   1.149 +#endif /* uconfig.h switches */
   1.150 +
   1.151 +#endif

mercurial