source: icXML/icXML-devel/src/xercesc/util/regx/OpFactory.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 4.1 KB
Line 
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.cpp 678879 2008-07-22 20:05:05Z amassari $
20 */
21
22// ---------------------------------------------------------------------------
23//  Includes
24// ---------------------------------------------------------------------------
25#include <xercesc/util/regx/Op.hpp>
26#include <xercesc/util/regx/OpFactory.hpp>
27#include <icxercesc/util/PlatformUtils.hpp>
28
29XERCES_CPP_NAMESPACE_BEGIN
30
31// ---------------------------------------------------------------------------
32//  OpFactory: Constructors and Destructor
33// ---------------------------------------------------------------------------
34OpFactory::OpFactory(MemoryManager* const manager) :
35    fOpVector(0)
36    , fMemoryManager(manager)
37{
38    fOpVector = new (fMemoryManager) RefVectorOf<Op>(16, true, fMemoryManager);
39}
40
41OpFactory::~OpFactory() {
42
43    delete fOpVector;
44    fOpVector = 0;
45}
46
47// ---------------------------------------------------------------------------
48//  OpFactory - Factory methods
49// ---------------------------------------------------------------------------
50Op* OpFactory::createDotOp() {
51
52    Op* tmpOp = new (fMemoryManager) Op(Op::O_DOT, fMemoryManager);
53    fOpVector->addElement(tmpOp);
54    return tmpOp;
55}
56
57CharOp* OpFactory::createCharOp(XMLInt32 data) {
58
59    CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CHAR, data, fMemoryManager);
60
61    fOpVector->addElement(tmpOp);
62    return tmpOp;
63}
64
65CharOp* OpFactory::createAnchorOp(XMLInt32 data) {
66
67    CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_ANCHOR, data, fMemoryManager);
68
69    fOpVector->addElement(tmpOp);
70    return tmpOp;
71}
72
73CharOp* OpFactory::createCaptureOp(int number, const Op* const next) {
74
75    CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CAPTURE, number, fMemoryManager);
76
77    tmpOp->setNextOp(next);
78    fOpVector->addElement(tmpOp);
79    return tmpOp;
80}
81
82UnionOp* OpFactory::createUnionOp(XMLSize_t size) {
83
84    UnionOp* tmpOp = new (fMemoryManager) UnionOp(Op::O_UNION, size, fMemoryManager);
85
86    fOpVector->addElement(tmpOp);
87    return tmpOp;
88}
89
90ChildOp* OpFactory::createClosureOp(int id) {
91
92    ModifierOp* tmpOp = new (fMemoryManager) ModifierOp(Op::O_CLOSURE, id, -1, fMemoryManager);
93
94    fOpVector->addElement(tmpOp);
95    return tmpOp;
96}
97
98ChildOp* OpFactory::createNonGreedyClosureOp() {
99
100    ChildOp* tmpOp = new (fMemoryManager) ChildOp(Op::O_NONGREEDYCLOSURE, fMemoryManager);
101
102    fOpVector->addElement(tmpOp);
103    return tmpOp;
104}
105
106ChildOp* OpFactory::createQuestionOp(bool nonGreedy) {
107
108    ChildOp* tmpOp = new (fMemoryManager)  ChildOp(nonGreedy ? Op::O_NONGREEDYQUESTION :
109                                             Op::O_QUESTION, fMemoryManager);
110
111    fOpVector->addElement(tmpOp);
112    return tmpOp;
113}
114
115RangeOp* OpFactory::createRangeOp(const Token* const token) {
116
117    RangeOp* tmpOp = new (fMemoryManager)  RangeOp(Op::O_RANGE, token, fMemoryManager);
118   
119    fOpVector->addElement(tmpOp);
120    return tmpOp;
121}
122
123CharOp* OpFactory::createBackReferenceOp(int refNo) {
124
125    CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_BACKREFERENCE, refNo, fMemoryManager);
126
127    fOpVector->addElement(tmpOp);
128    return tmpOp;
129}
130
131StringOp* OpFactory::createStringOp(const XMLCh* const literal) {
132
133    StringOp* tmpOp = new (fMemoryManager) StringOp(Op::O_STRING, literal, fMemoryManager);
134
135    fOpVector->addElement(tmpOp);
136    return tmpOp;
137}
138
139XERCES_CPP_NAMESPACE_END
140
141/**
142  * End of file OpFactory.cpp
143  */
Note: See TracBrowser for help on using the repository browser.