1 | /*
|
---|
2 | * Copyright 2001-2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Id: Op.hpp,v 1.12 2004/09/08 13:56:47 peiyongz Exp $
|
---|
19 | */
|
---|
20 |
|
---|
21 | #if !defined(OP_HPP)
|
---|
22 | #define OP_HPP
|
---|
23 |
|
---|
24 | // ---------------------------------------------------------------------------
|
---|
25 | // Includes
|
---|
26 | // ---------------------------------------------------------------------------
|
---|
27 | #include <xercesc/util/RefVectorOf.hpp>
|
---|
28 | #include <xercesc/util/RuntimeException.hpp>
|
---|
29 |
|
---|
30 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
31 |
|
---|
32 | // ---------------------------------------------------------------------------
|
---|
33 | // Forward Declaration
|
---|
34 | // ---------------------------------------------------------------------------
|
---|
35 | class Token;
|
---|
36 |
|
---|
37 |
|
---|
38 | class XMLUTIL_EXPORT Op : public XMemory
|
---|
39 | {
|
---|
40 | public:
|
---|
41 |
|
---|
42 | enum {
|
---|
43 | O_DOT = 0,
|
---|
44 | O_CHAR = 1,
|
---|
45 | O_RANGE = 3,
|
---|
46 | O_NRANGE = 4,
|
---|
47 | O_ANCHOR = 5,
|
---|
48 | O_STRING = 6,
|
---|
49 | O_CLOSURE = 7,
|
---|
50 | O_NONGREEDYCLOSURE = 8,
|
---|
51 | O_QUESTION = 9,
|
---|
52 | O_NONGREEDYQUESTION = 10,
|
---|
53 | O_UNION = 11,
|
---|
54 | O_CAPTURE = 15,
|
---|
55 | O_BACKREFERENCE = 16,
|
---|
56 | O_LOOKAHEAD = 20,
|
---|
57 | O_NEGATIVELOOKAHEAD = 21,
|
---|
58 | O_LOOKBEHIND = 22,
|
---|
59 | O_NEGATIVELOOKBEHIND = 23,
|
---|
60 | O_INDEPENDENT = 24,
|
---|
61 | O_MODIFIER = 25,
|
---|
62 | O_CONDITION = 26
|
---|
63 | };
|
---|
64 |
|
---|
65 | // -----------------------------------------------------------------------
|
---|
66 | // Public Constructors and Destructor
|
---|
67 | // -----------------------------------------------------------------------
|
---|
68 | virtual ~Op() { }
|
---|
69 |
|
---|
70 | // -----------------------------------------------------------------------
|
---|
71 | // Getter functions
|
---|
72 | // -----------------------------------------------------------------------
|
---|
73 | short getOpType() const;
|
---|
74 | const Op* getNextOp() const;
|
---|
75 | virtual XMLInt32 getData() const;
|
---|
76 | virtual XMLInt32 getData2() const;
|
---|
77 | virtual int getSize() const;
|
---|
78 | virtual int getRefNo() const;
|
---|
79 | virtual const Op* getConditionFlow() const;
|
---|
80 | virtual const Op* getYesFlow() const;
|
---|
81 | virtual const Op* getNoFlow() const;
|
---|
82 | virtual const Op* elementAt(int index) const;
|
---|
83 | virtual const Op* getChild() const;
|
---|
84 | virtual const Token* getToken() const;
|
---|
85 | virtual const XMLCh* getLiteral() const;
|
---|
86 |
|
---|
87 | // -----------------------------------------------------------------------
|
---|
88 | // Setter functions
|
---|
89 | // -----------------------------------------------------------------------
|
---|
90 | void setOpType(const short type);
|
---|
91 | void setNextOp(const Op* const next);
|
---|
92 |
|
---|
93 | protected:
|
---|
94 | // -----------------------------------------------------------------------
|
---|
95 | // Protected Constructors
|
---|
96 | // -----------------------------------------------------------------------
|
---|
97 | Op(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
98 | friend class OpFactory;
|
---|
99 |
|
---|
100 | MemoryManager* const fMemoryManager;
|
---|
101 |
|
---|
102 | private:
|
---|
103 | // -----------------------------------------------------------------------
|
---|
104 | // Unimplemented constructors and operators
|
---|
105 | // -----------------------------------------------------------------------
|
---|
106 | Op(const Op&);
|
---|
107 | Op& operator=(const Op&);
|
---|
108 |
|
---|
109 | // -----------------------------------------------------------------------
|
---|
110 | // Private data members
|
---|
111 | //
|
---|
112 | // fOpType
|
---|
113 | // Indicates the type of operation
|
---|
114 | //
|
---|
115 | // fNextOp
|
---|
116 | // Points to the next operation in the chain
|
---|
117 | // -----------------------------------------------------------------------
|
---|
118 | short fOpType;
|
---|
119 | const Op* fNextOp;
|
---|
120 | };
|
---|
121 |
|
---|
122 |
|
---|
123 | class XMLUTIL_EXPORT CharOp: public Op {
|
---|
124 | public:
|
---|
125 | // -----------------------------------------------------------------------
|
---|
126 | // Public Constructors and Destructor
|
---|
127 | // -----------------------------------------------------------------------
|
---|
128 | CharOp(const short type, const XMLInt32 charData, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
129 | ~CharOp() {}
|
---|
130 |
|
---|
131 | // -----------------------------------------------------------------------
|
---|
132 | // Getter functions
|
---|
133 | // -----------------------------------------------------------------------
|
---|
134 | XMLInt32 getData() const;
|
---|
135 |
|
---|
136 | private:
|
---|
137 | // Private data members
|
---|
138 | XMLInt32 fCharData;
|
---|
139 |
|
---|
140 | // -----------------------------------------------------------------------
|
---|
141 | // Unimplemented constructors and operators
|
---|
142 | // -----------------------------------------------------------------------
|
---|
143 | CharOp(const CharOp&);
|
---|
144 | CharOp& operator=(const CharOp&);
|
---|
145 | };
|
---|
146 |
|
---|
147 | class XMLUTIL_EXPORT UnionOp : public Op {
|
---|
148 | public:
|
---|
149 | // -----------------------------------------------------------------------
|
---|
150 | // Public Constructors and Destructor
|
---|
151 | // -----------------------------------------------------------------------
|
---|
152 | UnionOp(const short type, const int size,
|
---|
153 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
154 | ~UnionOp() { delete fBranches; }
|
---|
155 |
|
---|
156 | // -----------------------------------------------------------------------
|
---|
157 | // Getter functions
|
---|
158 | // -----------------------------------------------------------------------
|
---|
159 | int getSize() const;
|
---|
160 | const Op* elementAt(int index) const;
|
---|
161 |
|
---|
162 | // -----------------------------------------------------------------------
|
---|
163 | // Setter functions
|
---|
164 | // -----------------------------------------------------------------------
|
---|
165 | void addElement(Op* const op);
|
---|
166 |
|
---|
167 | private:
|
---|
168 | // Private Data memebers
|
---|
169 | RefVectorOf<Op>* fBranches;
|
---|
170 |
|
---|
171 | // -----------------------------------------------------------------------
|
---|
172 | // Unimplemented constructors and operators
|
---|
173 | // -----------------------------------------------------------------------
|
---|
174 | UnionOp(const UnionOp&);
|
---|
175 | UnionOp& operator=(const UnionOp&);
|
---|
176 | };
|
---|
177 |
|
---|
178 |
|
---|
179 | class XMLUTIL_EXPORT ChildOp: public Op {
|
---|
180 | public:
|
---|
181 | // -----------------------------------------------------------------------
|
---|
182 | // Public Constructors and Destructor
|
---|
183 | // -----------------------------------------------------------------------
|
---|
184 | ChildOp(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
185 | ~ChildOp() {}
|
---|
186 |
|
---|
187 | // -----------------------------------------------------------------------
|
---|
188 | // Getter functions
|
---|
189 | // -----------------------------------------------------------------------
|
---|
190 | const Op* getChild() const;
|
---|
191 |
|
---|
192 | // -----------------------------------------------------------------------
|
---|
193 | // Setter functions
|
---|
194 | // -----------------------------------------------------------------------
|
---|
195 | void setChild(const Op* const child);
|
---|
196 |
|
---|
197 | private:
|
---|
198 | // Private data members
|
---|
199 | const Op* fChild;
|
---|
200 |
|
---|
201 | // -----------------------------------------------------------------------
|
---|
202 | // Unimplemented constructors and operators
|
---|
203 | // -----------------------------------------------------------------------
|
---|
204 | ChildOp(const ChildOp&);
|
---|
205 | ChildOp& operator=(const ChildOp&);
|
---|
206 | };
|
---|
207 |
|
---|
208 | class XMLUTIL_EXPORT ModifierOp: public ChildOp {
|
---|
209 | public:
|
---|
210 | // -----------------------------------------------------------------------
|
---|
211 | // Public Constructors and Destructor
|
---|
212 | // -----------------------------------------------------------------------
|
---|
213 | ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
214 | ~ModifierOp() {}
|
---|
215 |
|
---|
216 | // -----------------------------------------------------------------------
|
---|
217 | // Getter functions
|
---|
218 | // -----------------------------------------------------------------------
|
---|
219 | XMLInt32 getData() const;
|
---|
220 | XMLInt32 getData2() const;
|
---|
221 |
|
---|
222 | private:
|
---|
223 | // Private data members
|
---|
224 | XMLInt32 fVal1;
|
---|
225 | XMLInt32 fVal2;
|
---|
226 |
|
---|
227 | // -----------------------------------------------------------------------
|
---|
228 | // Unimplemented constructors and operators
|
---|
229 | // -----------------------------------------------------------------------
|
---|
230 | ModifierOp(const ModifierOp&);
|
---|
231 | ModifierOp& operator=(const ModifierOp&);
|
---|
232 | };
|
---|
233 |
|
---|
234 | class XMLUTIL_EXPORT RangeOp: public Op {
|
---|
235 | public:
|
---|
236 | // -----------------------------------------------------------------------
|
---|
237 | // Public Constructors and Destructor
|
---|
238 | // -----------------------------------------------------------------------
|
---|
239 | RangeOp(const short type, const Token* const token, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
240 | ~RangeOp() {}
|
---|
241 |
|
---|
242 | // -----------------------------------------------------------------------
|
---|
243 | // Getter functions
|
---|
244 | // -----------------------------------------------------------------------
|
---|
245 | const Token* getToken() const;
|
---|
246 |
|
---|
247 | private:
|
---|
248 | // Private data members
|
---|
249 | const Token* fToken;
|
---|
250 |
|
---|
251 | // -----------------------------------------------------------------------
|
---|
252 | // Unimplemented constructors and operators
|
---|
253 | // -----------------------------------------------------------------------
|
---|
254 | RangeOp(const RangeOp&);
|
---|
255 | RangeOp& operator=(const RangeOp&);
|
---|
256 | };
|
---|
257 |
|
---|
258 | class XMLUTIL_EXPORT StringOp: public Op {
|
---|
259 | public:
|
---|
260 | // -----------------------------------------------------------------------
|
---|
261 | // Public Constructors and Destructor
|
---|
262 | // -----------------------------------------------------------------------
|
---|
263 | StringOp(const short type, const XMLCh* const literal, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
264 | ~StringOp() { fMemoryManager->deallocate(fLiteral);}
|
---|
265 |
|
---|
266 | // -----------------------------------------------------------------------
|
---|
267 | // Getter functions
|
---|
268 | // -----------------------------------------------------------------------
|
---|
269 | const XMLCh* getLiteral() const;
|
---|
270 |
|
---|
271 | private:
|
---|
272 | // Private data members
|
---|
273 | XMLCh* fLiteral;
|
---|
274 |
|
---|
275 | // -----------------------------------------------------------------------
|
---|
276 | // Unimplemented constructors and operators
|
---|
277 | // -----------------------------------------------------------------------
|
---|
278 | StringOp(const StringOp&);
|
---|
279 | StringOp& operator=(const StringOp&);
|
---|
280 | };
|
---|
281 |
|
---|
282 | class XMLUTIL_EXPORT ConditionOp: public Op {
|
---|
283 | public:
|
---|
284 | // -----------------------------------------------------------------------
|
---|
285 | // Public Constructors and Destructor
|
---|
286 | // -----------------------------------------------------------------------
|
---|
287 | ConditionOp(const short type, const int refNo,
|
---|
288 | const Op* const condFlow, const Op* const yesFlow,
|
---|
289 | const Op* const noFlow, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
290 | ~ConditionOp() {}
|
---|
291 |
|
---|
292 | // -----------------------------------------------------------------------
|
---|
293 | // Getter functions
|
---|
294 | // -----------------------------------------------------------------------
|
---|
295 | int getRefNo() const;
|
---|
296 | const Op* getConditionFlow() const;
|
---|
297 | const Op* getYesFlow() const;
|
---|
298 | const Op* getNoFlow() const;
|
---|
299 |
|
---|
300 | private:
|
---|
301 | // Private data members
|
---|
302 | int fRefNo;
|
---|
303 | const Op* fConditionOp;
|
---|
304 | const Op* fYesOp;
|
---|
305 | const Op* fNoOp;
|
---|
306 |
|
---|
307 | // -----------------------------------------------------------------------
|
---|
308 | // Unimplemented constructors and operators
|
---|
309 | // -----------------------------------------------------------------------
|
---|
310 | ConditionOp(const ConditionOp&);
|
---|
311 | ConditionOp& operator=(const ConditionOp&);
|
---|
312 | };
|
---|
313 |
|
---|
314 | // ---------------------------------------------------------------------------
|
---|
315 | // Op: getter methods
|
---|
316 | // ---------------------------------------------------------------------------
|
---|
317 | inline short Op::getOpType() const {
|
---|
318 |
|
---|
319 | return fOpType;
|
---|
320 | }
|
---|
321 |
|
---|
322 | inline const Op* Op::getNextOp() const {
|
---|
323 |
|
---|
324 | return fNextOp;
|
---|
325 | }
|
---|
326 |
|
---|
327 | // ---------------------------------------------------------------------------
|
---|
328 | // Op: setter methods
|
---|
329 | // ---------------------------------------------------------------------------
|
---|
330 | inline void Op::setOpType(const short type) {
|
---|
331 |
|
---|
332 | fOpType = type;
|
---|
333 | }
|
---|
334 |
|
---|
335 | inline void Op::setNextOp(const Op* const nextOp) {
|
---|
336 |
|
---|
337 | fNextOp = nextOp;
|
---|
338 | }
|
---|
339 |
|
---|
340 | XERCES_CPP_NAMESPACE_END
|
---|
341 |
|
---|
342 | #endif
|
---|
343 |
|
---|
344 | /**
|
---|
345 | * End of file Op.hpp
|
---|
346 | */
|
---|