intl/icu/source/extra/scrptrun/scrptrun.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/extra/scrptrun/scrptrun.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,154 @@
     1.4 +/*
     1.5 + *******************************************************************************
     1.6 + *
     1.7 + *   Copyright (C) 1999-2003, International Business Machines
     1.8 + *   Corporation and others.  All Rights Reserved.
     1.9 + *
    1.10 + *******************************************************************************
    1.11 + *   file name:  scrptrun.h
    1.12 + *
    1.13 + *   created on: 10/17/2001
    1.14 + *   created by: Eric R. Mader
    1.15 + */
    1.16 +
    1.17 +#ifndef __SCRPTRUN_H
    1.18 +#define __SCRPTRUN_H
    1.19 +
    1.20 +#include "unicode/utypes.h"
    1.21 +#include "unicode/uobject.h"
    1.22 +#include "unicode/uscript.h"
    1.23 +
    1.24 +struct ScriptRecord
    1.25 +{
    1.26 +    UChar32 startChar;
    1.27 +    UChar32 endChar;
    1.28 +    UScriptCode scriptCode;
    1.29 +};
    1.30 +
    1.31 +struct ParenStackEntry
    1.32 +{
    1.33 +    int32_t pairIndex;
    1.34 +    UScriptCode scriptCode;
    1.35 +};
    1.36 +
    1.37 +class ScriptRun : public UObject {
    1.38 +public:
    1.39 +    ScriptRun();
    1.40 +
    1.41 +    ScriptRun(const UChar chars[], int32_t length);
    1.42 +
    1.43 +    ScriptRun(const UChar chars[], int32_t start, int32_t length);
    1.44 +
    1.45 +    void reset();
    1.46 +
    1.47 +    void reset(int32_t start, int32_t count);
    1.48 +
    1.49 +    void reset(const UChar chars[], int32_t start, int32_t length);
    1.50 +
    1.51 +    int32_t getScriptStart();
    1.52 +
    1.53 +    int32_t getScriptEnd();
    1.54 +
    1.55 +    UScriptCode getScriptCode();
    1.56 +
    1.57 +    UBool next();
    1.58 +
    1.59 +    /**
    1.60 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
    1.61 +     *
    1.62 +     * @stable ICU 2.2
    1.63 +     */
    1.64 +    virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
    1.65 +
    1.66 +    /**
    1.67 +     * ICU "poor man's RTTI", returns a UClassID for this class.
    1.68 +     *
    1.69 +     * @stable ICU 2.2
    1.70 +     */
    1.71 +    static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
    1.72 +
    1.73 +private:
    1.74 +
    1.75 +    static UBool sameScript(int32_t scriptOne, int32_t scriptTwo);
    1.76 +
    1.77 +    int32_t charStart;
    1.78 +    int32_t charLimit;
    1.79 +    const UChar *charArray;
    1.80 +
    1.81 +    int32_t scriptStart;
    1.82 +    int32_t scriptEnd;
    1.83 +    UScriptCode scriptCode;
    1.84 +
    1.85 +    ParenStackEntry parenStack[128];
    1.86 +    int32_t parenSP;
    1.87 +
    1.88 +    static int8_t highBit(int32_t value);
    1.89 +    static int32_t getPairIndex(UChar32 ch);
    1.90 +
    1.91 +    static UChar32 pairedChars[];
    1.92 +    static const int32_t pairedCharCount;
    1.93 +    static const int32_t pairedCharPower;
    1.94 +    static const int32_t pairedCharExtra;
    1.95 +
    1.96 +    /**
    1.97 +     * The address of this static class variable serves as this class's ID
    1.98 +     * for ICU "poor man's RTTI".
    1.99 +     */
   1.100 +    static const char fgClassID;
   1.101 +};
   1.102 +
   1.103 +inline ScriptRun::ScriptRun()
   1.104 +{
   1.105 +    reset(NULL, 0, 0);
   1.106 +}
   1.107 +
   1.108 +inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
   1.109 +{
   1.110 +    reset(chars, 0, length);
   1.111 +}
   1.112 +
   1.113 +inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
   1.114 +{
   1.115 +    reset(chars, start, length);
   1.116 +}
   1.117 +
   1.118 +inline int32_t ScriptRun::getScriptStart()
   1.119 +{
   1.120 +    return scriptStart;
   1.121 +}
   1.122 +
   1.123 +inline int32_t ScriptRun::getScriptEnd()
   1.124 +{
   1.125 +    return scriptEnd;
   1.126 +}
   1.127 +
   1.128 +inline UScriptCode ScriptRun::getScriptCode()
   1.129 +{
   1.130 +    return scriptCode;
   1.131 +}
   1.132 +
   1.133 +inline void ScriptRun::reset()
   1.134 +{
   1.135 +    scriptStart = charStart;
   1.136 +    scriptEnd   = charStart;
   1.137 +    scriptCode  = USCRIPT_INVALID_CODE;
   1.138 +    parenSP     = -1;
   1.139 +}
   1.140 +
   1.141 +inline void ScriptRun::reset(int32_t start, int32_t length)
   1.142 +{
   1.143 +    charStart = start;
   1.144 +    charLimit = start + length;
   1.145 +
   1.146 +    reset();
   1.147 +}
   1.148 +
   1.149 +inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
   1.150 +{
   1.151 +    charArray = chars;
   1.152 +
   1.153 +    reset(start, length);
   1.154 +}
   1.155 +
   1.156 +
   1.157 +#endif

mercurial