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