LibreOffice Module vcl (master)  1
scrptrun.h
Go to the documentation of this file.
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_INC_SCRPTRUN_H
38 #define INCLUDED_VCL_INC_SCRPTRUN_H
39 
40 #include <sal/config.h>
41 
42 #include <unicode/uobject.h>
43 #include <unicode/uscript.h>
44 #include <vector>
45 
46 namespace vcl
47 {
49 {
50  int32_t pairIndex;
51  UScriptCode scriptCode;
53  : pairIndex(0)
54  , scriptCode(USCRIPT_INVALID_CODE)
55  {
56  }
57 };
58 
59 class ScriptRun final : public icu::UObject
60 {
61 public:
62  ScriptRun(const UChar chars[], int32_t length);
63 
64  void reset();
65 
66  void reset(int32_t start, int32_t count);
67 
68  void reset(const UChar chars[], int32_t start, int32_t length);
69 
70  int32_t getScriptStart() const;
71 
72  int32_t getScriptEnd() const;
73 
74  UScriptCode getScriptCode() const;
75 
76  UBool next();
77 
83  virtual UClassID getDynamicClassID() const override { return getStaticClassID(); }
84 
90  static UClassID getStaticClassID()
91  {
92  return static_cast<UClassID>(const_cast<char*>(&fgClassID));
93  }
94 
95 private:
96  int32_t charStart;
97  int32_t charLimit;
98  const UChar* charArray;
99 
100  int32_t scriptStart;
101  int32_t scriptEnd;
102  UScriptCode scriptCode;
103 
104  std::vector<ParenStackEntry> parenStack;
105  int32_t parenSP;
106 
111  static const char fgClassID;
112 };
113 
114 inline ScriptRun::ScriptRun(const UChar chars[], int32_t length) { reset(chars, 0, length); }
115 
116 inline int32_t ScriptRun::getScriptStart() const { return scriptStart; }
117 
118 inline int32_t ScriptRun::getScriptEnd() const { return scriptEnd; }
119 
120 inline UScriptCode ScriptRun::getScriptCode() const { return scriptCode; }
121 
122 inline void ScriptRun::reset()
123 {
126  scriptCode = USCRIPT_INVALID_CODE;
127  parenSP = -1;
128  parenStack.resize(128);
129 }
130 
131 inline void ScriptRun::reset(int32_t start, int32_t length)
132 {
133  charStart = start;
134  charLimit = start + length;
135 
136  reset();
137 }
138 
139 inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
140 {
141  charArray = chars;
142 
143  reset(start, length);
144 }
145 }
146 
147 #endif
int32_t getScriptEnd() const
Definition: scrptrun.h:118
const size_t count(pCandidateA->getBorderLines().size())
UBool next()
Definition: scrptrun.cxx:145
int32_t scriptEnd
Definition: scrptrun.h:101
const UChar * charArray
Definition: scrptrun.h:98
int32_t scriptStart
Definition: scrptrun.h:100
length
UScriptCode getScriptCode() const
Definition: scrptrun.h:120
std::vector< ParenStackEntry > parenStack
Definition: scrptrun.h:104
int32_t parenSP
Definition: scrptrun.h:105
UScriptCode scriptCode
Definition: scrptrun.h:51
int32_t charLimit
Definition: scrptrun.h:97
int32_t getScriptStart() const
Definition: scrptrun.h:116
void reset()
Definition: scrptrun.h:122
UScriptCode scriptCode
Definition: scrptrun.h:102
int32_t charStart
Definition: scrptrun.h:96
static const char fgClassID
The address of this static class variable serves as this class's ID for ICU "poor man's RTTI"...
Definition: scrptrun.h:111
virtual UClassID getDynamicClassID() const override
s * ICU "poor man's RTTI", returns a UClassID for the actual class.
Definition: scrptrun.h:83
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
Definition: scrptrun.h:90
ScriptRun(const UChar chars[], int32_t length)
Definition: scrptrun.h:114