GME  13
OpFactory.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: OpFactory.cpp 678879 2008-07-22 20:05:05Z amassari $
00020  */
00021 
00022 // ---------------------------------------------------------------------------
00023 //  Includes
00024 // ---------------------------------------------------------------------------
00025 #include <xercesc/util/regx/Op.hpp>
00026 #include <xercesc/util/regx/OpFactory.hpp>
00027 #include <xercesc/util/PlatformUtils.hpp>
00028 
00029 XERCES_CPP_NAMESPACE_BEGIN
00030 
00031 // ---------------------------------------------------------------------------
00032 //  OpFactory: Constructors and Destructor
00033 // ---------------------------------------------------------------------------
00034 OpFactory::OpFactory(MemoryManager* const manager) :
00035     fOpVector(0)
00036     , fMemoryManager(manager)
00037 {
00038     fOpVector = new (fMemoryManager) RefVectorOf<Op>(16, true, fMemoryManager);
00039 }
00040 
00041 OpFactory::~OpFactory() {
00042 
00043     delete fOpVector;
00044     fOpVector = 0;
00045 }
00046 
00047 // ---------------------------------------------------------------------------
00048 //  OpFactory - Factory methods
00049 // ---------------------------------------------------------------------------
00050 Op* OpFactory::createDotOp() {
00051 
00052     Op* tmpOp = new (fMemoryManager) Op(Op::O_DOT, fMemoryManager);
00053     fOpVector->addElement(tmpOp);
00054     return tmpOp;
00055 }
00056 
00057 CharOp* OpFactory::createCharOp(XMLInt32 data) {
00058 
00059     CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CHAR, data, fMemoryManager);
00060 
00061     fOpVector->addElement(tmpOp);
00062     return tmpOp;
00063 }
00064 
00065 CharOp* OpFactory::createAnchorOp(XMLInt32 data) {
00066 
00067     CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_ANCHOR, data, fMemoryManager);
00068 
00069     fOpVector->addElement(tmpOp);
00070     return tmpOp;
00071 }
00072 
00073 CharOp* OpFactory::createCaptureOp(int number, const Op* const next) {
00074 
00075     CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CAPTURE, number, fMemoryManager);
00076 
00077     tmpOp->setNextOp(next);
00078     fOpVector->addElement(tmpOp);
00079     return tmpOp;
00080 }
00081 
00082 UnionOp* OpFactory::createUnionOp(XMLSize_t size) {
00083 
00084     UnionOp* tmpOp = new (fMemoryManager) UnionOp(Op::O_UNION, size, fMemoryManager);
00085 
00086     fOpVector->addElement(tmpOp);
00087     return tmpOp;
00088 }
00089 
00090 ChildOp* OpFactory::createClosureOp(int id) {
00091 
00092     ModifierOp* tmpOp = new (fMemoryManager) ModifierOp(Op::O_CLOSURE, id, -1, fMemoryManager);
00093 
00094     fOpVector->addElement(tmpOp);
00095     return tmpOp;
00096 }
00097 
00098 ChildOp* OpFactory::createNonGreedyClosureOp() {
00099 
00100     ChildOp* tmpOp = new (fMemoryManager) ChildOp(Op::O_NONGREEDYCLOSURE, fMemoryManager);
00101 
00102     fOpVector->addElement(tmpOp);
00103     return tmpOp;
00104 }
00105 
00106 ChildOp* OpFactory::createQuestionOp(bool nonGreedy) {
00107 
00108     ChildOp* tmpOp = new (fMemoryManager)  ChildOp(nonGreedy ? Op::O_NONGREEDYQUESTION :
00109                                              Op::O_QUESTION, fMemoryManager);
00110 
00111     fOpVector->addElement(tmpOp);
00112     return tmpOp;
00113 }
00114 
00115 RangeOp* OpFactory::createRangeOp(const Token* const token) {
00116 
00117     RangeOp* tmpOp = new (fMemoryManager)  RangeOp(Op::O_RANGE, token, fMemoryManager);
00118     
00119     fOpVector->addElement(tmpOp);
00120     return tmpOp;
00121 }
00122 
00123 CharOp* OpFactory::createBackReferenceOp(int refNo) {
00124 
00125     CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_BACKREFERENCE, refNo, fMemoryManager);
00126 
00127     fOpVector->addElement(tmpOp);
00128     return tmpOp;
00129 }
00130 
00131 StringOp* OpFactory::createStringOp(const XMLCh* const literal) {
00132 
00133     StringOp* tmpOp = new (fMemoryManager) StringOp(Op::O_STRING, literal, fMemoryManager);
00134 
00135     fOpVector->addElement(tmpOp);
00136     return tmpOp;
00137 }
00138 
00139 XERCES_CPP_NAMESPACE_END
00140