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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /*
     2  *******************************************************************************
     3  *
     4  *   Copyright (C) 1999-2003, International Business Machines
     5  *   Corporation and others.  All Rights Reserved.
     6  *
     7  *******************************************************************************
     8  *   file name:  scrptrun.h
     9  *
    10  *   created on: 10/17/2001
    11  *   created by: Eric R. Mader
    12  */
    14 #ifndef __SCRPTRUN_H
    15 #define __SCRPTRUN_H
    17 #include "unicode/utypes.h"
    18 #include "unicode/uobject.h"
    19 #include "unicode/uscript.h"
    21 struct ScriptRecord
    22 {
    23     UChar32 startChar;
    24     UChar32 endChar;
    25     UScriptCode scriptCode;
    26 };
    28 struct ParenStackEntry
    29 {
    30     int32_t pairIndex;
    31     UScriptCode scriptCode;
    32 };
    34 class ScriptRun : public UObject {
    35 public:
    36     ScriptRun();
    38     ScriptRun(const UChar chars[], int32_t length);
    40     ScriptRun(const UChar chars[], int32_t start, int32_t length);
    42     void reset();
    44     void reset(int32_t start, int32_t count);
    46     void reset(const UChar chars[], int32_t start, int32_t length);
    48     int32_t getScriptStart();
    50     int32_t getScriptEnd();
    52     UScriptCode getScriptCode();
    54     UBool next();
    56     /**
    57      * ICU "poor man's RTTI", returns a UClassID for the actual class.
    58      *
    59      * @stable ICU 2.2
    60      */
    61     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
    63     /**
    64      * ICU "poor man's RTTI", returns a UClassID for this class.
    65      *
    66      * @stable ICU 2.2
    67      */
    68     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
    70 private:
    72     static UBool sameScript(int32_t scriptOne, int32_t scriptTwo);
    74     int32_t charStart;
    75     int32_t charLimit;
    76     const UChar *charArray;
    78     int32_t scriptStart;
    79     int32_t scriptEnd;
    80     UScriptCode scriptCode;
    82     ParenStackEntry parenStack[128];
    83     int32_t parenSP;
    85     static int8_t highBit(int32_t value);
    86     static int32_t getPairIndex(UChar32 ch);
    88     static UChar32 pairedChars[];
    89     static const int32_t pairedCharCount;
    90     static const int32_t pairedCharPower;
    91     static const int32_t pairedCharExtra;
    93     /**
    94      * The address of this static class variable serves as this class's ID
    95      * for ICU "poor man's RTTI".
    96      */
    97     static const char fgClassID;
    98 };
   100 inline ScriptRun::ScriptRun()
   101 {
   102     reset(NULL, 0, 0);
   103 }
   105 inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
   106 {
   107     reset(chars, 0, length);
   108 }
   110 inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
   111 {
   112     reset(chars, start, length);
   113 }
   115 inline int32_t ScriptRun::getScriptStart()
   116 {
   117     return scriptStart;
   118 }
   120 inline int32_t ScriptRun::getScriptEnd()
   121 {
   122     return scriptEnd;
   123 }
   125 inline UScriptCode ScriptRun::getScriptCode()
   126 {
   127     return scriptCode;
   128 }
   130 inline void ScriptRun::reset()
   131 {
   132     scriptStart = charStart;
   133     scriptEnd   = charStart;
   134     scriptCode  = USCRIPT_INVALID_CODE;
   135     parenSP     = -1;
   136 }
   138 inline void ScriptRun::reset(int32_t start, int32_t length)
   139 {
   140     charStart = start;
   141     charLimit = start + length;
   143     reset();
   144 }
   146 inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
   147 {
   148     charArray = chars;
   150     reset(start, length);
   151 }
   154 #endif

mercurial