LCOV - code coverage report
Current view: top level - vcl/generic/glyphs - scrptrun.h (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 31 93.5 %
Date: 2015-06-13 12:38:46 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             : #include <vector>
      47             : 
      48             : namespace vcl {
      49             : 
      50             : struct ScriptRecord
      51             : {
      52             :     UChar32 startChar;
      53             :     UChar32 endChar;
      54             :     UScriptCode scriptCode;
      55             : };
      56             : 
      57             : struct ParenStackEntry
      58             : {
      59             :     int32_t pairIndex;
      60             :     UScriptCode scriptCode;
      61   193719424 :     ParenStackEntry()
      62             :       : pairIndex(0)
      63   193719424 :       , scriptCode(USCRIPT_INVALID_CODE)
      64             :     {
      65   193719424 :     }
      66             : };
      67             : 
      68     1513433 : class ScriptRun : public UObject {
      69             : public:
      70             :     ScriptRun();
      71             : 
      72             :     ScriptRun(const UChar chars[], int32_t length);
      73             : 
      74             :     ScriptRun(const UChar chars[], int32_t start, int32_t length);
      75             : 
      76             :     void reset();
      77             : 
      78             :     void reset(int32_t start, int32_t count);
      79             : 
      80             :     void reset(const UChar chars[], int32_t start, int32_t length);
      81             : 
      82             :     int32_t getScriptStart();
      83             : 
      84             :     int32_t getScriptEnd();
      85             : 
      86             :     UScriptCode getScriptCode();
      87             : 
      88             :     UBool next();
      89             : 
      90             :     /**
      91             : s     * ICU "poor man's RTTI", returns a UClassID for the actual class.
      92             :      *
      93             :      * @stable ICU 2.2
      94             :      */
      95           0 :     virtual inline UClassID getDynamicClassID() const SAL_OVERRIDE { return getStaticClassID(); }
      96             : 
      97             :     /**
      98             :      * ICU "poor man's RTTI", returns a UClassID for this class.
      99             :      *
     100             :      * @stable ICU 2.2
     101             :      */
     102           0 :     static inline UClassID getStaticClassID() { return static_cast<UClassID>(const_cast<char *>(&fgClassID)); }
     103             : 
     104             : private:
     105             : 
     106             :     int32_t charStart;
     107             :     int32_t charLimit;
     108             :     const UChar *charArray;
     109             : 
     110             :     int32_t scriptStart;
     111             :     int32_t scriptEnd;
     112             :     UScriptCode scriptCode;
     113             : 
     114             :     std::vector<ParenStackEntry> parenStack;
     115             :     int32_t parenSP;
     116             : 
     117             :     /**
     118             :      * The address of this static class variable serves as this class's ID
     119             :      * for ICU "poor man's RTTI".
     120             :      */
     121             :     static const char fgClassID;
     122             : };
     123             : 
     124             : inline ScriptRun::ScriptRun()
     125             : {
     126             :     reset(NULL, 0, 0);
     127             : }
     128             : 
     129     1513433 : inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
     130             : {
     131     1513433 :     reset(chars, 0, length);
     132     1513433 : }
     133             : 
     134             : inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
     135             : {
     136             :     reset(chars, start, length);
     137             : }
     138             : 
     139     1470263 : inline int32_t ScriptRun::getScriptStart()
     140             : {
     141     1470263 :     return scriptStart;
     142             : }
     143             : 
     144     1470263 : inline int32_t ScriptRun::getScriptEnd()
     145             : {
     146     1470263 :     return scriptEnd;
     147             : }
     148             : 
     149     1470263 : inline UScriptCode ScriptRun::getScriptCode()
     150             : {
     151     1470263 :     return scriptCode;
     152             : }
     153             : 
     154     1513433 : inline void ScriptRun::reset()
     155             : {
     156     1513433 :     scriptStart = charStart;
     157     1513433 :     scriptEnd   = charStart;
     158     1513433 :     scriptCode  = USCRIPT_INVALID_CODE;
     159     1513433 :     parenSP     = -1;
     160     1513433 :     parenStack.resize(128);
     161     1513433 : }
     162             : 
     163     1513433 : inline void ScriptRun::reset(int32_t start, int32_t length)
     164             : {
     165     1513433 :     charStart = start;
     166     1513433 :     charLimit = start + length;
     167             : 
     168     1513433 :     reset();
     169     1513433 : }
     170             : 
     171     1513433 : inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
     172             : {
     173     1513433 :     charArray = chars;
     174             : 
     175     1513433 :     reset(start, length);
     176     1513433 : }
     177             : 
     178             : }
     179             : 
     180             : #endif

Generated by: LCOV version 1.11