[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: OpFactory.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(OPFACTORY_HPP) |
---|
| 23 | #define OPFACTORY_HPP |
---|
| 24 | |
---|
| 25 | // --------------------------------------------------------------------------- |
---|
| 26 | // Includes |
---|
| 27 | // --------------------------------------------------------------------------- |
---|
| 28 | #include <xercesc/util/XMemory.hpp> |
---|
| 29 | #include <xercesc/util/RefVectorOf.hpp> |
---|
| 30 | |
---|
| 31 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 32 | |
---|
| 33 | // --------------------------------------------------------------------------- |
---|
| 34 | // Forward Declaration |
---|
| 35 | // --------------------------------------------------------------------------- |
---|
| 36 | class Op; |
---|
| 37 | class CharOp; |
---|
| 38 | class UnionOp; |
---|
| 39 | class ChildOp; |
---|
| 40 | class RangeOp; |
---|
| 41 | class StringOp; |
---|
| 42 | class ModifierOp; |
---|
| 43 | class ConditionOp; |
---|
| 44 | class Token; |
---|
| 45 | |
---|
| 46 | /* |
---|
| 47 | * A Factory class used by 'RegularExpression' to create different types of |
---|
| 48 | * operations (Op) objects. The class will keep track of all objects created |
---|
| 49 | * for cleanup purposes. Each 'RegularExpression' object will have its own |
---|
| 50 | * instance of OpFactory and when a 'RegularExpression' object is deleted |
---|
| 51 | * all associated Op objects will be deleted. |
---|
| 52 | */ |
---|
| 53 | |
---|
| 54 | class XMLUTIL_EXPORT OpFactory : public XMemory |
---|
| 55 | { |
---|
| 56 | public: |
---|
| 57 | // ----------------------------------------------------------------------- |
---|
| 58 | // Constructors and destructors |
---|
| 59 | // ----------------------------------------------------------------------- |
---|
| 60 | OpFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 61 | ~OpFactory(); |
---|
| 62 | |
---|
| 63 | // ----------------------------------------------------------------------- |
---|
| 64 | // Factory methods |
---|
| 65 | // ----------------------------------------------------------------------- |
---|
| 66 | Op* createDotOp(); |
---|
| 67 | CharOp* createCharOp(XMLInt32 data); |
---|
| 68 | CharOp* createAnchorOp(XMLInt32 data); |
---|
| 69 | CharOp* createCaptureOp(int number, const Op* const next); |
---|
| 70 | UnionOp* createUnionOp(int size); |
---|
| 71 | ChildOp* createClosureOp(int id); |
---|
| 72 | ChildOp* createNonGreedyClosureOp(); |
---|
| 73 | ChildOp* createQuestionOp(bool nonGreedy); |
---|
| 74 | RangeOp* createRangeOp(const Token* const token); |
---|
| 75 | ChildOp* createLookOp(const short type, const Op* const next, |
---|
| 76 | const Op* const branch); |
---|
| 77 | CharOp* createBackReferenceOp(int refNo); |
---|
| 78 | StringOp* createStringOp(const XMLCh* const literal); |
---|
| 79 | ChildOp* createIndependentOp(const Op* const next, |
---|
| 80 | const Op* const branch); |
---|
| 81 | ModifierOp* createModifierOp(const Op* const next, const Op* const branch, |
---|
| 82 | const int add, const int mask); |
---|
| 83 | ConditionOp* createConditionOp(const Op* const next, const int ref, |
---|
| 84 | const Op* const conditionFlow, |
---|
| 85 | const Op* const yesFlow, |
---|
| 86 | const Op* const noFlow); |
---|
| 87 | |
---|
| 88 | // ----------------------------------------------------------------------- |
---|
| 89 | // Reset methods |
---|
| 90 | // ----------------------------------------------------------------------- |
---|
| 91 | /* |
---|
| 92 | * Remove all created Op objects from Vector |
---|
| 93 | */ |
---|
| 94 | void reset(); |
---|
| 95 | |
---|
| 96 | private: |
---|
| 97 | // ----------------------------------------------------------------------- |
---|
| 98 | // Unimplemented constructors and operators |
---|
| 99 | // ----------------------------------------------------------------------- |
---|
| 100 | OpFactory(const OpFactory&); |
---|
| 101 | OpFactory& operator=(const OpFactory&); |
---|
| 102 | |
---|
| 103 | // ----------------------------------------------------------------------- |
---|
| 104 | // Private data members |
---|
| 105 | // |
---|
| 106 | // fOpVector |
---|
| 107 | // Contains Op objects. Used for memory cleanup. |
---|
| 108 | // ----------------------------------------------------------------------- |
---|
| 109 | RefVectorOf<Op>* fOpVector; |
---|
| 110 | MemoryManager* fMemoryManager; |
---|
| 111 | }; |
---|
| 112 | |
---|
| 113 | // --------------------------------------------------------------------------- |
---|
| 114 | // OpFactory - Factory methods |
---|
| 115 | // --------------------------------------------------------------------------- |
---|
| 116 | inline void OpFactory::reset() { |
---|
| 117 | |
---|
| 118 | fOpVector->removeAllElements(); |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | XERCES_CPP_NAMESPACE_END |
---|
| 122 | |
---|
| 123 | #endif |
---|
| 124 | |
---|
| 125 | /** |
---|
| 126 | * End file OpFactory |
---|
| 127 | */ |
---|