source: NonGTP/Xerces/xerces/include/xercesc/util/regx/OpFactory.hpp @ 358

Revision 358, 4.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Id: OpFactory.hpp,v 1.7 2004/09/08 13:56:47 peiyongz Exp $
19 */
20
21#if !defined(OPFACTORY_HPP)
22#define OPFACTORY_HPP
23
24// ---------------------------------------------------------------------------
25//  Includes
26// ---------------------------------------------------------------------------
27#include <xercesc/util/XMemory.hpp>
28#include <xercesc/util/RefVectorOf.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32// ---------------------------------------------------------------------------
33//  Forward Declaration
34// ---------------------------------------------------------------------------
35class Op;
36class CharOp;
37class UnionOp;
38class ChildOp;
39class RangeOp;
40class StringOp;
41class ModifierOp;
42class ConditionOp;
43class Token;
44
45/*
46 * A Factory class used by 'RegularExpression' to create different types of
47 * operations (Op) objects. The class will keep track of all objects created
48 * for cleanup purposes. Each 'RegularExpression' object will have its own
49 * instance of OpFactory and when a 'RegularExpression' object is deleted
50 * all associated Op objects will be deleted.
51 */
52
53class XMLUTIL_EXPORT OpFactory : public XMemory
54{
55public:
56        // -----------------------------------------------------------------------
57    //  Constructors and destructors
58    // -----------------------------------------------------------------------
59        OpFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
60    ~OpFactory();
61
62    // -----------------------------------------------------------------------
63    //  Factory methods
64    // -----------------------------------------------------------------------
65    Op* createDotOp();
66        CharOp* createCharOp(XMLInt32 data);
67        CharOp* createAnchorOp(XMLInt32 data);
68        CharOp* createCaptureOp(int number, const Op* const next);
69        UnionOp* createUnionOp(int size);
70        ChildOp* createClosureOp(int id);
71        ChildOp* createNonGreedyClosureOp();
72        ChildOp* createQuestionOp(bool nonGreedy);
73        RangeOp* createRangeOp(const Token* const token);
74        ChildOp* createLookOp(const short type, const Op* const next,
75                          const Op* const branch);
76        CharOp* createBackReferenceOp(int refNo);
77        StringOp* createStringOp(const XMLCh* const literal);
78        ChildOp* createIndependentOp(const Op* const next,
79                                                                 const Op* const branch);
80        ModifierOp* createModifierOp(const Op* const next, const Op* const branch,
81                                                                 const int add, const int mask);
82        ConditionOp* createConditionOp(const Op* const next, const int ref,
83                                   const Op* const conditionFlow,
84                                   const Op* const yesFlow,
85                                   const Op* const noFlow);
86
87    // -----------------------------------------------------------------------
88    //  Reset methods
89    // -----------------------------------------------------------------------
90        /*
91         *      Remove all created Op objects from Vector
92         */
93        void reset();
94
95private:
96    // -----------------------------------------------------------------------
97    //  Unimplemented constructors and operators
98    // -----------------------------------------------------------------------
99    OpFactory(const OpFactory&);
100    OpFactory& operator=(const OpFactory&);
101
102    // -----------------------------------------------------------------------
103    //  Private data members
104    //
105    //  fOpVector
106    //      Contains Op objects. Used for memory cleanup.
107    // -----------------------------------------------------------------------
108    RefVectorOf<Op>* fOpVector;
109    MemoryManager*   fMemoryManager;
110};
111
112// ---------------------------------------------------------------------------
113//  OpFactory - Factory methods
114// ---------------------------------------------------------------------------
115inline void OpFactory::reset() {
116
117        fOpVector->removeAllElements();
118}
119
120XERCES_CPP_NAMESPACE_END
121
122#endif
123
124/**
125  *     End file OpFactory
126  */
Note: See TracBrowser for help on using the repository browser.