intl/icu/source/common/usc_impl.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/usc_impl.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 1999-2011, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*
    1.10 +* File USC_IMPL.H
    1.11 +*
    1.12 +* Modification History:
    1.13 +*
    1.14 +*   Date        Name        Description
    1.15 +*   07/08/2002  Eric Mader  Creation.
    1.16 +******************************************************************************
    1.17 +*/
    1.18 +
    1.19 +#ifndef USC_IMPL_H
    1.20 +#define USC_IMPL_H
    1.21 +#include "unicode/utypes.h"
    1.22 +#include "unicode/uscript.h"
    1.23 +
    1.24 +/**
    1.25 + * <code>UScriptRun</code> is used to find runs of characters in
    1.26 + * the same script. It implements a simple iterator over an array
    1.27 + * of characters. The iterator will resolve script-neutral characters
    1.28 + * like punctuation into the script of the surrounding characters.
    1.29 + *
    1.30 + * The iterator will try to match paired punctuation. If it sees an
    1.31 + * opening punctuation character, it will remember the script that
    1.32 + * was assigned to that character, and assign the same script to the
    1.33 + * matching closing punctuation.
    1.34 + *
    1.35 + * Scripts are chosen based on the <code>UScriptCode</code> enumeration.
    1.36 + * No attempt is made to combine related scripts into a single run. In
    1.37 + * particular, Hiragana, Katakana, and Han characters will appear in seperate
    1.38 + * runs.
    1.39 +
    1.40 + * Here is an example of how to iterate over script runs:
    1.41 + * <pre>
    1.42 + * \code
    1.43 + * void printScriptRuns(const UChar *text, int32_t length)
    1.44 + * {
    1.45 + *     UErrorCode error = U_ZERO_ERROR;
    1.46 + *     UScriptRun *scriptRun = uscript_openRun(text, testLength, &error);
    1.47 + *     int32_t start = 0, limit = 0;
    1.48 + *     UScriptCode code = USCRIPT_INVALID_CODE;
    1.49 + *
    1.50 + *     while (uscript_nextRun(&start, &limit, &code)) {
    1.51 + *         printf("Script '%s' from %d to %d.\n", uscript_getName(code), start, limit);
    1.52 + *     }
    1.53 + *
    1.54 + *     uscript_closeRun(scriptRun);
    1.55 + *  }
    1.56 + * </pre>
    1.57 + */
    1.58 +struct UScriptRun;
    1.59 +
    1.60 +typedef struct UScriptRun UScriptRun;
    1.61 +
    1.62 +/**
    1.63 + * Create a <code>UScriptRun</code> object for iterating over the given text. This object must
    1.64 + * be freed using <code>uscript_closeRun()</code>. Note that this object does not copy the source text,
    1.65 + * only the pointer to it. You must make sure that the pointer remains valid until you call
    1.66 + * <code>uscript_closeRun()</code> or <code>uscript_setRunText()</code>.
    1.67 + *
    1.68 + * @param src is the address of the array of characters over which to iterate.
    1.69 + *        if <code>src == NULL</code> and <code>length == 0</code>,
    1.70 + *        an empty <code>UScriptRun</code> object will be returned.
    1.71 + *
    1.72 + * @param length is the number of characters over which to iterate.
    1.73 + *
    1.74 + * @param pErrorCode is a pointer to a valid <code>UErrorCode</code> value. If this value
    1.75 + *        indicates a failure on entry, the function will immediately return.
    1.76 + *        On exit the value will indicate the success of the operation.
    1.77 + *
    1.78 + * @return the address of <code>UScriptRun</code> object which will iterate over the text,
    1.79 + *         or <code>NULL</code> if the operation failed.
    1.80 + */
    1.81 +U_CAPI UScriptRun * U_EXPORT2
    1.82 +uscript_openRun(const UChar *src, int32_t length, UErrorCode *pErrorCode);
    1.83 +
    1.84 +/**
    1.85 + * Frees the given <code>UScriptRun</code> object and any storage associated with it.
    1.86 + * On return, scriptRun no longer points to a valid <code>UScriptRun</code> object.
    1.87 + *
    1.88 + * @param scriptRun is the <code>UScriptRun</code> object which will be freed.
    1.89 + */
    1.90 +U_CAPI void U_EXPORT2
    1.91 +uscript_closeRun(UScriptRun *scriptRun);
    1.92 +
    1.93 +/**
    1.94 + * Reset the <code>UScriptRun</code> object so that it will start iterating from
    1.95 + * the beginning.
    1.96 + *
    1.97 + * @param scriptRun is the address of the <code>UScriptRun</code> object to be reset.
    1.98 + */
    1.99 +U_CAPI void U_EXPORT2
   1.100 +uscript_resetRun(UScriptRun *scriptRun);
   1.101 +
   1.102 +/**
   1.103 + * Change the text over which the given <code>UScriptRun</code> object iterates.
   1.104 + *
   1.105 + * @param scriptRun is the <code>UScriptRun</code> object which will be changed.
   1.106 + *
   1.107 + * @param src is the address of the new array of characters over which to iterate.
   1.108 + *        If <code>src == NULL</code> and <code>length == 0</code>,
   1.109 + *        the <code>UScriptRun</code> object will become empty.
   1.110 + *
   1.111 + * @param length is the new number of characters over which to iterate
   1.112 + *
   1.113 + * @param pErrorCode is a pointer to a valid <code>UErrorCode</code> value. If this value
   1.114 + *        indicates a failure on entry, the function will immediately return.
   1.115 + *        On exit the value will indicate the success of the operation.
   1.116 + */
   1.117 +U_CAPI void U_EXPORT2
   1.118 +uscript_setRunText(UScriptRun *scriptRun, const UChar *src, int32_t length, UErrorCode *pErrorCode);
   1.119 +
   1.120 +/**
   1.121 + * Advance the <code>UScriptRun</code> object to the next script run, return the start and limit
   1.122 + * offsets, and the script of the run.
   1.123 + *
   1.124 + * @param scriptRun is the address of the <code>UScriptRun</code> object.
   1.125 + *
   1.126 + * @param pRunStart is a pointer to the variable to receive the starting offset of the next run.
   1.127 + *        This pointer can be <code>NULL</code> if the value is not needed.
   1.128 + *
   1.129 + * @param pRunLimit is a pointer to the variable to receive the limit offset of the next run.
   1.130 + *        This pointer can be <code>NULL</code> if the value is not needed.
   1.131 + *
   1.132 + * @param pRunScript is a pointer to the variable to receive the UScriptCode for the
   1.133 + *        script of the current run. This pointer can be <code>NULL</code> if the value is not needed.
   1.134 + *
   1.135 + * @return true if there was another script run.
   1.136 + */
   1.137 +U_CAPI UBool U_EXPORT2
   1.138 +uscript_nextRun(UScriptRun *scriptRun, int32_t *pRunStart, int32_t *pRunLimit, UScriptCode *pRunScript);
   1.139 +
   1.140 +#endif

mercurial