[188] | 1 | /*
|
---|
| 2 | * The Apache Software License, Version 1.1
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
---|
| 5 | * reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | *
|
---|
| 14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 15 | * notice, this list of conditions and the following disclaimer in
|
---|
| 16 | * the documentation and/or other materials provided with the
|
---|
| 17 | * distribution.
|
---|
| 18 | *
|
---|
| 19 | * 3. The end-user documentation included with the redistribution,
|
---|
| 20 | * if any, must include the following acknowledgment:
|
---|
| 21 | * "This product includes software developed by the
|
---|
| 22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
| 23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
| 24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
| 25 | *
|
---|
| 26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
| 27 | * not be used to endorse or promote products derived from this
|
---|
| 28 | * software without prior written permission. For written
|
---|
| 29 | * permission, please contact apache\@apache.org.
|
---|
| 30 | *
|
---|
| 31 | * 5. Products derived from this software may not be called "Apache",
|
---|
| 32 | * nor may "Apache" appear in their name, without prior written
|
---|
| 33 | * permission of the Apache Software Foundation.
|
---|
| 34 | *
|
---|
| 35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
| 36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
| 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
| 42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
| 45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 46 | * SUCH DAMAGE.
|
---|
| 47 | * ====================================================================
|
---|
| 48 | *
|
---|
| 49 | * This software consists of voluntary contributions made by many
|
---|
| 50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
| 51 | * originally based on software copyright (c) 2001, International
|
---|
| 52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
| 53 | * on the Apache Software Foundation, please see
|
---|
| 54 | * <http://www.apache.org/>.
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * $Id: Op.hpp,v 1.11 2004/01/29 11:51:21 cargilld Exp $
|
---|
| 59 | */
|
---|
| 60 |
|
---|
| 61 | #if !defined(OP_HPP)
|
---|
| 62 | #define OP_HPP
|
---|
| 63 |
|
---|
| 64 | // ---------------------------------------------------------------------------
|
---|
| 65 | // Includes
|
---|
| 66 | // ---------------------------------------------------------------------------
|
---|
| 67 | #include <xercesc/util/RefVectorOf.hpp>
|
---|
| 68 | #include <xercesc/util/RuntimeException.hpp>
|
---|
| 69 |
|
---|
| 70 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 71 |
|
---|
| 72 | // ---------------------------------------------------------------------------
|
---|
| 73 | // Forward Declaration
|
---|
| 74 | // ---------------------------------------------------------------------------
|
---|
| 75 | class Token;
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | class XMLUTIL_EXPORT Op : public XMemory
|
---|
| 79 | {
|
---|
| 80 | public:
|
---|
| 81 |
|
---|
| 82 | enum {
|
---|
| 83 | O_DOT = 0,
|
---|
| 84 | O_CHAR = 1,
|
---|
| 85 | O_RANGE = 3,
|
---|
| 86 | O_NRANGE = 4,
|
---|
| 87 | O_ANCHOR = 5,
|
---|
| 88 | O_STRING = 6,
|
---|
| 89 | O_CLOSURE = 7,
|
---|
| 90 | O_NONGREEDYCLOSURE = 8,
|
---|
| 91 | O_QUESTION = 9,
|
---|
| 92 | O_NONGREEDYQUESTION = 10,
|
---|
| 93 | O_UNION = 11,
|
---|
| 94 | O_CAPTURE = 15,
|
---|
| 95 | O_BACKREFERENCE = 16,
|
---|
| 96 | O_LOOKAHEAD = 20,
|
---|
| 97 | O_NEGATIVELOOKAHEAD = 21,
|
---|
| 98 | O_LOOKBEHIND = 22,
|
---|
| 99 | O_NEGATIVELOOKBEHIND = 23,
|
---|
| 100 | O_INDEPENDENT = 24,
|
---|
| 101 | O_MODIFIER = 25,
|
---|
| 102 | O_CONDITION = 26
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 | // -----------------------------------------------------------------------
|
---|
| 106 | // Public Constructors and Destructor
|
---|
| 107 | // -----------------------------------------------------------------------
|
---|
| 108 | virtual ~Op() { }
|
---|
| 109 |
|
---|
| 110 | // -----------------------------------------------------------------------
|
---|
| 111 | // Getter functions
|
---|
| 112 | // -----------------------------------------------------------------------
|
---|
| 113 | short getOpType() const;
|
---|
| 114 | const Op* getNextOp() const;
|
---|
| 115 | virtual XMLInt32 getData() const;
|
---|
| 116 | virtual XMLInt32 getData2() const;
|
---|
| 117 | virtual int getSize() const;
|
---|
| 118 | virtual int getRefNo() const;
|
---|
| 119 | virtual const Op* getConditionFlow() const;
|
---|
| 120 | virtual const Op* getYesFlow() const;
|
---|
| 121 | virtual const Op* getNoFlow() const;
|
---|
| 122 | virtual const Op* elementAt(int index) const;
|
---|
| 123 | virtual const Op* getChild() const;
|
---|
| 124 | virtual const Token* getToken() const;
|
---|
| 125 | virtual const XMLCh* getLiteral() const;
|
---|
| 126 |
|
---|
| 127 | // -----------------------------------------------------------------------
|
---|
| 128 | // Setter functions
|
---|
| 129 | // -----------------------------------------------------------------------
|
---|
| 130 | void setOpType(const short type);
|
---|
| 131 | void setNextOp(const Op* const next);
|
---|
| 132 |
|
---|
| 133 | protected:
|
---|
| 134 | // -----------------------------------------------------------------------
|
---|
| 135 | // Protected Constructors
|
---|
| 136 | // -----------------------------------------------------------------------
|
---|
| 137 | Op(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 138 | friend class OpFactory;
|
---|
| 139 |
|
---|
| 140 | MemoryManager* const fMemoryManager;
|
---|
| 141 |
|
---|
| 142 | private:
|
---|
| 143 | // -----------------------------------------------------------------------
|
---|
| 144 | // Unimplemented constructors and operators
|
---|
| 145 | // -----------------------------------------------------------------------
|
---|
| 146 | Op(const Op&);
|
---|
| 147 | Op& operator=(const Op&);
|
---|
| 148 |
|
---|
| 149 | // -----------------------------------------------------------------------
|
---|
| 150 | // Private data members
|
---|
| 151 | //
|
---|
| 152 | // fOpType
|
---|
| 153 | // Indicates the type of operation
|
---|
| 154 | //
|
---|
| 155 | // fNextOp
|
---|
| 156 | // Points to the next operation in the chain
|
---|
| 157 | // -----------------------------------------------------------------------
|
---|
| 158 | short fOpType;
|
---|
| 159 | const Op* fNextOp;
|
---|
| 160 | };
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | class XMLUTIL_EXPORT CharOp: public Op {
|
---|
| 164 | public:
|
---|
| 165 | // -----------------------------------------------------------------------
|
---|
| 166 | // Public Constructors and Destructor
|
---|
| 167 | // -----------------------------------------------------------------------
|
---|
| 168 | CharOp(const short type, const XMLInt32 charData, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 169 | ~CharOp() {}
|
---|
| 170 |
|
---|
| 171 | // -----------------------------------------------------------------------
|
---|
| 172 | // Getter functions
|
---|
| 173 | // -----------------------------------------------------------------------
|
---|
| 174 | XMLInt32 getData() const;
|
---|
| 175 |
|
---|
| 176 | private:
|
---|
| 177 | // Private data members
|
---|
| 178 | XMLInt32 fCharData;
|
---|
| 179 |
|
---|
| 180 | // -----------------------------------------------------------------------
|
---|
| 181 | // Unimplemented constructors and operators
|
---|
| 182 | // -----------------------------------------------------------------------
|
---|
| 183 | CharOp(const CharOp&);
|
---|
| 184 | CharOp& operator=(const CharOp&);
|
---|
| 185 | };
|
---|
| 186 |
|
---|
| 187 | class XMLUTIL_EXPORT UnionOp : public Op {
|
---|
| 188 | public:
|
---|
| 189 | // -----------------------------------------------------------------------
|
---|
| 190 | // Public Constructors and Destructor
|
---|
| 191 | // -----------------------------------------------------------------------
|
---|
| 192 | UnionOp(const short type, const int size,
|
---|
| 193 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 194 | ~UnionOp() { delete fBranches; }
|
---|
| 195 |
|
---|
| 196 | // -----------------------------------------------------------------------
|
---|
| 197 | // Getter functions
|
---|
| 198 | // -----------------------------------------------------------------------
|
---|
| 199 | int getSize() const;
|
---|
| 200 | const Op* elementAt(int index) const;
|
---|
| 201 |
|
---|
| 202 | // -----------------------------------------------------------------------
|
---|
| 203 | // Setter functions
|
---|
| 204 | // -----------------------------------------------------------------------
|
---|
| 205 | void addElement(Op* const op);
|
---|
| 206 |
|
---|
| 207 | private:
|
---|
| 208 | // Private Data memebers
|
---|
| 209 | RefVectorOf<Op>* fBranches;
|
---|
| 210 |
|
---|
| 211 | // -----------------------------------------------------------------------
|
---|
| 212 | // Unimplemented constructors and operators
|
---|
| 213 | // -----------------------------------------------------------------------
|
---|
| 214 | UnionOp(const UnionOp&);
|
---|
| 215 | UnionOp& operator=(const UnionOp&);
|
---|
| 216 | };
|
---|
| 217 |
|
---|
| 218 |
|
---|
| 219 | class XMLUTIL_EXPORT ChildOp: public Op {
|
---|
| 220 | public:
|
---|
| 221 | // -----------------------------------------------------------------------
|
---|
| 222 | // Public Constructors and Destructor
|
---|
| 223 | // -----------------------------------------------------------------------
|
---|
| 224 | ChildOp(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 225 | ~ChildOp() {}
|
---|
| 226 |
|
---|
| 227 | // -----------------------------------------------------------------------
|
---|
| 228 | // Getter functions
|
---|
| 229 | // -----------------------------------------------------------------------
|
---|
| 230 | const Op* getChild() const;
|
---|
| 231 |
|
---|
| 232 | // -----------------------------------------------------------------------
|
---|
| 233 | // Setter functions
|
---|
| 234 | // -----------------------------------------------------------------------
|
---|
| 235 | void setChild(const Op* const child);
|
---|
| 236 |
|
---|
| 237 | private:
|
---|
| 238 | // Private data members
|
---|
| 239 | const Op* fChild;
|
---|
| 240 |
|
---|
| 241 | // -----------------------------------------------------------------------
|
---|
| 242 | // Unimplemented constructors and operators
|
---|
| 243 | // -----------------------------------------------------------------------
|
---|
| 244 | ChildOp(const ChildOp&);
|
---|
| 245 | ChildOp& operator=(const ChildOp&);
|
---|
| 246 | };
|
---|
| 247 |
|
---|
| 248 | class XMLUTIL_EXPORT ModifierOp: public ChildOp {
|
---|
| 249 | public:
|
---|
| 250 | // -----------------------------------------------------------------------
|
---|
| 251 | // Public Constructors and Destructor
|
---|
| 252 | // -----------------------------------------------------------------------
|
---|
| 253 | ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 254 | ~ModifierOp() {}
|
---|
| 255 |
|
---|
| 256 | // -----------------------------------------------------------------------
|
---|
| 257 | // Getter functions
|
---|
| 258 | // -----------------------------------------------------------------------
|
---|
| 259 | XMLInt32 getData() const;
|
---|
| 260 | XMLInt32 getData2() const;
|
---|
| 261 |
|
---|
| 262 | private:
|
---|
| 263 | // Private data members
|
---|
| 264 | XMLInt32 fVal1;
|
---|
| 265 | XMLInt32 fVal2;
|
---|
| 266 |
|
---|
| 267 | // -----------------------------------------------------------------------
|
---|
| 268 | // Unimplemented constructors and operators
|
---|
| 269 | // -----------------------------------------------------------------------
|
---|
| 270 | ModifierOp(const ModifierOp&);
|
---|
| 271 | ModifierOp& operator=(const ModifierOp&);
|
---|
| 272 | };
|
---|
| 273 |
|
---|
| 274 | class XMLUTIL_EXPORT RangeOp: public Op {
|
---|
| 275 | public:
|
---|
| 276 | // -----------------------------------------------------------------------
|
---|
| 277 | // Public Constructors and Destructor
|
---|
| 278 | // -----------------------------------------------------------------------
|
---|
| 279 | RangeOp(const short type, const Token* const token, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 280 | ~RangeOp() {}
|
---|
| 281 |
|
---|
| 282 | // -----------------------------------------------------------------------
|
---|
| 283 | // Getter functions
|
---|
| 284 | // -----------------------------------------------------------------------
|
---|
| 285 | const Token* getToken() const;
|
---|
| 286 |
|
---|
| 287 | private:
|
---|
| 288 | // Private data members
|
---|
| 289 | const Token* fToken;
|
---|
| 290 |
|
---|
| 291 | // -----------------------------------------------------------------------
|
---|
| 292 | // Unimplemented constructors and operators
|
---|
| 293 | // -----------------------------------------------------------------------
|
---|
| 294 | RangeOp(const RangeOp&);
|
---|
| 295 | RangeOp& operator=(const RangeOp&);
|
---|
| 296 | };
|
---|
| 297 |
|
---|
| 298 | class XMLUTIL_EXPORT StringOp: public Op {
|
---|
| 299 | public:
|
---|
| 300 | // -----------------------------------------------------------------------
|
---|
| 301 | // Public Constructors and Destructor
|
---|
| 302 | // -----------------------------------------------------------------------
|
---|
| 303 | StringOp(const short type, const XMLCh* const literal, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 304 | ~StringOp() { fMemoryManager->deallocate(fLiteral);}
|
---|
| 305 |
|
---|
| 306 | // -----------------------------------------------------------------------
|
---|
| 307 | // Getter functions
|
---|
| 308 | // -----------------------------------------------------------------------
|
---|
| 309 | const XMLCh* getLiteral() const;
|
---|
| 310 |
|
---|
| 311 | private:
|
---|
| 312 | // Private data members
|
---|
| 313 | XMLCh* fLiteral;
|
---|
| 314 |
|
---|
| 315 | // -----------------------------------------------------------------------
|
---|
| 316 | // Unimplemented constructors and operators
|
---|
| 317 | // -----------------------------------------------------------------------
|
---|
| 318 | StringOp(const StringOp&);
|
---|
| 319 | StringOp& operator=(const StringOp&);
|
---|
| 320 | };
|
---|
| 321 |
|
---|
| 322 | class XMLUTIL_EXPORT ConditionOp: public Op {
|
---|
| 323 | public:
|
---|
| 324 | // -----------------------------------------------------------------------
|
---|
| 325 | // Public Constructors and Destructor
|
---|
| 326 | // -----------------------------------------------------------------------
|
---|
| 327 | ConditionOp(const short type, const int refNo,
|
---|
| 328 | const Op* const condFlow, const Op* const yesFlow,
|
---|
| 329 | const Op* const noFlow, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 330 | ~ConditionOp() {}
|
---|
| 331 |
|
---|
| 332 | // -----------------------------------------------------------------------
|
---|
| 333 | // Getter functions
|
---|
| 334 | // -----------------------------------------------------------------------
|
---|
| 335 | int getRefNo() const;
|
---|
| 336 | const Op* getConditionFlow() const;
|
---|
| 337 | const Op* getYesFlow() const;
|
---|
| 338 | const Op* getNoFlow() const;
|
---|
| 339 |
|
---|
| 340 | private:
|
---|
| 341 | // Private data members
|
---|
| 342 | int fRefNo;
|
---|
| 343 | const Op* fConditionOp;
|
---|
| 344 | const Op* fYesOp;
|
---|
| 345 | const Op* fNoOp;
|
---|
| 346 |
|
---|
| 347 | // -----------------------------------------------------------------------
|
---|
| 348 | // Unimplemented constructors and operators
|
---|
| 349 | // -----------------------------------------------------------------------
|
---|
| 350 | ConditionOp(const ConditionOp&);
|
---|
| 351 | ConditionOp& operator=(const ConditionOp&);
|
---|
| 352 | };
|
---|
| 353 |
|
---|
| 354 | // ---------------------------------------------------------------------------
|
---|
| 355 | // Op: getter methods
|
---|
| 356 | // ---------------------------------------------------------------------------
|
---|
| 357 | inline short Op::getOpType() const {
|
---|
| 358 |
|
---|
| 359 | return fOpType;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | inline const Op* Op::getNextOp() const {
|
---|
| 363 |
|
---|
| 364 | return fNextOp;
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | // ---------------------------------------------------------------------------
|
---|
| 368 | // Op: setter methods
|
---|
| 369 | // ---------------------------------------------------------------------------
|
---|
| 370 | inline void Op::setOpType(const short type) {
|
---|
| 371 |
|
---|
| 372 | fOpType = type;
|
---|
| 373 | }
|
---|
| 374 |
|
---|
| 375 | inline void Op::setNextOp(const Op* const nextOp) {
|
---|
| 376 |
|
---|
| 377 | fNextOp = nextOp;
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | XERCES_CPP_NAMESPACE_END
|
---|
| 381 |
|
---|
| 382 | #endif
|
---|
| 383 |
|
---|
| 384 | /**
|
---|
| 385 | * End of file Op.hpp
|
---|
| 386 | */
|
---|