LCOV - code coverage report
Current view: top level - vcl/generic/glyphs - scrptrun.h (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 28 30 93.3 %
Date: 2014-11-03 Functions: 9 12 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *******************************************************************************
       3             :  *
       4             :  *   Copyright (c) 1995-2013 International Business Machines Corporation and others
       5             :  *
       6             :  *   All rights reserved.
       7             :  *
       8             :  *   Permission is hereby granted, free of charge, to any person obtaining a copy of
       9             :  *   this software and associated documentation files (the "Software"), to deal in
      10             :  *   the Software without restriction, including without limitation the rights to
      11             :  *   use, copy, modify, merge, publish, distribute, and/or sell copies of the
      12             :  *   Software, and to permit persons to whom the Software is furnished to do so,
      13             :  *   provided that the above copyright notice(s) and this permission notice appear
      14             :  *   in all copies of the Software and that both the above copyright notice(s) and
      15             :  *   this permission notice appear in supporting documentation.
      16             :  *
      17             :  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      18             :  *   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      19             :  *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
      20             :  *   NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE
      21             :  *   LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY
      22             :  *   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
      23             :  *   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
      24             :  *   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      25             :  *
      26             :  *   Except as contained in this notice, the name of a copyright holder shall not be
      27             :  *   used in advertising or otherwise to promote the sale, use or other dealings in
      28             :  *   this Software without prior written authorization of the copyright holder.
      29             :  *
      30             :  *******************************************************************************
      31             :  *   file name:  scrptrun.h
      32             :  *
      33             :  *   created on: 10/17/2001
      34             :  *   created by: Eric R. Mader
      35             :  */
      36             : 
      37             : #ifndef INCLUDED_VCL_GENERIC_GLYPHS_SCRPTRUN_H
      38             : #define INCLUDED_VCL_GENERIC_GLYPHS_SCRPTRUN_H
      39             : 
      40             : #include <sal/config.h>
      41             : 
      42             : #include <sal/types.h>
      43             : #include "unicode/utypes.h"
      44             : #include "unicode/uobject.h"
      45             : #include "unicode/uscript.h"
      46             : 
      47             : namespace vcl {
      48             : 
      49             : struct ScriptRecord
      50             : {
      51             :     UChar32 startChar;
      52             :     UChar32 endChar;
      53             :     UScriptCode scriptCode;
      54             : };
      55             : 
      56             : struct ParenStackEntry
      57             : {
      58             :     int32_t pairIndex;
      59             :     UScriptCode scriptCode;
      60   276015744 :     ParenStackEntry()
      61             :       : pairIndex(0)
      62   276015744 :       , scriptCode(USCRIPT_INVALID_CODE)
      63             :     {
      64   276015744 :     }
      65             : };
      66             : 
      67     2156373 : class ScriptRun : public UObject {
      68             : public:
      69             :     ScriptRun();
      70             : 
      71             :     ScriptRun(const UChar chars[], int32_t length);
      72             : 
      73             :     ScriptRun(const UChar chars[], int32_t start, int32_t length);
      74             : 
      75             :     void reset();
      76             : 
      77             :     void reset(int32_t start, int32_t count);
      78             : 
      79             :     void reset(const UChar chars[], int32_t start, int32_t length);
      80             : 
      81             :     int32_t getScriptStart();
      82             : 
      83             :     int32_t getScriptEnd();
      84             : 
      85             :     UScriptCode getScriptCode();
      86             : 
      87             :     UBool next();
      88             : 
      89             :     /**
      90             :      * ICU "poor man's RTTI", returns a UClassID for the actual class.
      91             :      *
      92             :      * @stable ICU 2.2
      93             :      */
      94           0 :     virtual inline UClassID getDynamicClassID() const SAL_OVERRIDE { return getStaticClassID(); }
      95             : 
      96             :     /**
      97             :      * ICU "poor man's RTTI", returns a UClassID for this class.
      98             :      *
      99             :      * @stable ICU 2.2
     100             :      */
     101           0 :     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
     102             : 
     103             : private:
     104             : 
     105             :     static UBool sameScript(int32_t scriptOne, int32_t scriptTwo);
     106             : 
     107             :     int32_t charStart;
     108             :     int32_t charLimit;
     109             :     const UChar *charArray;
     110             : 
     111             :     int32_t scriptStart;
     112             :     int32_t scriptEnd;
     113             :     UScriptCode scriptCode;
     114             : 
     115             :     ParenStackEntry parenStack[128];
     116             :     int32_t parenSP;
     117             : 
     118             :     static int8_t highBit(int32_t value);
     119             :     static int32_t getPairIndex(UChar32 ch);
     120             : 
     121             :     static UChar32 pairedChars[];
     122             :     static const int32_t pairedCharCount;
     123             :     static const int32_t pairedCharPower;
     124             :     static const int32_t pairedCharExtra;
     125             : 
     126             :     /**
     127             :      * The address of this static class variable serves as this class's ID
     128             :      * for ICU "poor man's RTTI".
     129             :      */
     130             :     static const char fgClassID;
     131             : };
     132             : 
     133             : inline ScriptRun::ScriptRun()
     134             : {
     135             :     reset(NULL, 0, 0);
     136             : }
     137             : 
     138     2156373 : inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
     139             : {
     140     2156373 :     reset(chars, 0, length);
     141     2156373 : }
     142             : 
     143             : inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
     144             : {
     145             :     reset(chars, start, length);
     146             : }
     147             : 
     148     2140328 : inline int32_t ScriptRun::getScriptStart()
     149             : {
     150     2140328 :     return scriptStart;
     151             : }
     152             : 
     153     4280578 : inline int32_t ScriptRun::getScriptEnd()
     154             : {
     155     4280578 :     return scriptEnd;
     156             : }
     157             : 
     158     2140250 : inline UScriptCode ScriptRun::getScriptCode()
     159             : {
     160     2140250 :     return scriptCode;
     161             : }
     162             : 
     163     4296109 : inline void ScriptRun::reset()
     164             : {
     165     4296109 :     scriptStart = charStart;
     166     4296109 :     scriptEnd   = charStart;
     167     4296109 :     scriptCode  = USCRIPT_INVALID_CODE;
     168     4296109 :     parenSP     = -1;
     169     4296109 : }
     170             : 
     171     2156373 : inline void ScriptRun::reset(int32_t start, int32_t length)
     172             : {
     173     2156373 :     charStart = start;
     174     2156373 :     charLimit = start + length;
     175             : 
     176     2156373 :     reset();
     177     2156373 : }
     178             : 
     179     2156373 : inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
     180             : {
     181     2156373 :     charArray = chars;
     182             : 
     183     2156373 :     reset(start, length);
     184     2156373 : }
     185             : 
     186             : }
     187             : 
     188             : #endif

Generated by: LCOV version 1.10