Coverage Report

Created: 2025-07-23 06:41

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