os/textandloc/fontservices/textshaperplugin/IcuSource/common/usc_impl.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/usc_impl.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,149 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 1999-2002, 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 + * @draft ICU 2.2
    1.59 + */
    1.60 +struct UScriptRun;
    1.61 +
    1.62 +typedef struct UScriptRun UScriptRun;
    1.63 +
    1.64 +/**
    1.65 + * Create a <code>UScriptRun</code> object for iterating over the given text. This object must
    1.66 + * be freed using <code>uscript_closeRun()</code>. Note that this object does not copy the source text,
    1.67 + * only the pointer to it. You must make sure that the pointer remains valid until you call
    1.68 + * <code>uscript_closeRun()</code> or <code>uscript_setRunText()</code>.
    1.69 + *
    1.70 + * @param src is the address of the array of characters over which to iterate.
    1.71 + *        if <code>src == NULL</code> and <code>length == 0</code>,
    1.72 + *        an empty <code>UScriptRun</code> object will be returned.
    1.73 + *
    1.74 + * @param length is the number of characters over which to iterate.
    1.75 + *
    1.76 + * @param pErrorCode is a pointer to a valid <code>UErrorCode</code> value. If this value
    1.77 + *        indicates a failure on entry, the function will immediately return.
    1.78 + *        On exit the value will indicate the success of the operation.
    1.79 + *
    1.80 + * @return the address of <code>UScriptRun</code> object which will iterate over the text,
    1.81 + *         or <code>NULL</code> if the operation failed.
    1.82 + *
    1.83 + * @draft ICU 2.2
    1.84 + */
    1.85 +U_CAPI UScriptRun * U_EXPORT2
    1.86 +uscript_openRun(const UChar *src, int32_t length, UErrorCode *pErrorCode);
    1.87 +
    1.88 +/**
    1.89 + * Frees the given <code>UScriptRun</code> object and any storage associated with it.
    1.90 + * On return, scriptRun no longer points to a valid <code>UScriptRun</code> object.
    1.91 + *
    1.92 + * @param scriptRun is the <code>UScriptRun</code> object which will be freed.
    1.93 + *
    1.94 + * @draft ICU 2.2
    1.95 + */
    1.96 +U_CAPI void U_EXPORT2
    1.97 +uscript_closeRun(UScriptRun *scriptRun);
    1.98 +
    1.99 +/**
   1.100 + * Reset the <code>UScriptRun</code> object so that it will start iterating from
   1.101 + * the beginning.
   1.102 + *
   1.103 + * @param scriptRun is the address of the <code>UScriptRun</code> object to be reset.
   1.104 + *
   1.105 + * @draft ICU 2.2
   1.106 + */
   1.107 +U_CAPI void U_EXPORT2
   1.108 +uscript_resetRun(UScriptRun *scriptRun);
   1.109 +
   1.110 +/**
   1.111 + * Change the text over which the given <code>UScriptRun</code> object iterates.
   1.112 + *
   1.113 + * @param scriptRun is the <code>UScriptRun</code> object which will be changed.
   1.114 + *
   1.115 + * @param src is the address of the new array of characters over which to iterate.
   1.116 + *        If <code>src == NULL</code> and <code>length == 0</code>,
   1.117 + *        the <code>UScriptRun</code> object will become empty.
   1.118 + *
   1.119 + * @param length is the new number of characters over which to iterate
   1.120 + *
   1.121 + * @param pErrorCode is a pointer to a valid <code>UErrorCode</code> value. If this value
   1.122 + *        indicates a failure on entry, the function will immediately return.
   1.123 + *        On exit the value will indicate the success of the operation.
   1.124 + *
   1.125 + * @draft ICU 2.2
   1.126 + */
   1.127 +U_CAPI void U_EXPORT2
   1.128 +uscript_setRunText(UScriptRun *scriptRun, const UChar *src, int32_t length, UErrorCode *pErrorCode);
   1.129 +
   1.130 +/**
   1.131 + * Advance the <code>UScriptRun</code> object to the next script run, return the start and limit
   1.132 + * offsets, and the script of the run.
   1.133 + *
   1.134 + * @param scriptRun is the address of the <code>UScriptRun</code> object.
   1.135 + *
   1.136 + * @param pRunStart is a pointer to the variable to receive the starting offset of the next run.
   1.137 + *        This pointer can be <code>NULL</code> if the value is not needed.
   1.138 + *
   1.139 + * @param pRunLimit is a pointer to the variable to receive the limit offset of the next run.
   1.140 + *        This pointer can be <code>NULL</code> if the value is not needed.
   1.141 + *
   1.142 + * @param pRunScript is a pointer to the variable to receive the UScriptCode for the
   1.143 + *        script of the current run. This pointer can be <code>NULL</code> if the value is not needed.
   1.144 + *
   1.145 + * @return true if there was another script run.
   1.146 + *
   1.147 + * @draft ICU 2.2
   1.148 + */
   1.149 +U_CAPI UBool U_EXPORT2
   1.150 +uscript_nextRun(UScriptRun *scriptRun, int32_t *pRunStart, int32_t *pRunLimit, UScriptCode *pRunScript);
   1.151 +
   1.152 +#endif