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: TokenFactory.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(TOKENFACTORY_HPP) |
---|
23 | #define TOKENFACTORY_HPP |
---|
24 | |
---|
25 | // --------------------------------------------------------------------------- |
---|
26 | // Includes |
---|
27 | // --------------------------------------------------------------------------- |
---|
28 | #include <xercesc/util/RefVectorOf.hpp> |
---|
29 | #include <xercesc/util/regx/Token.hpp> |
---|
30 | #include <xercesc/util/Mutexes.hpp> |
---|
31 | |
---|
32 | XERCES_CPP_NAMESPACE_BEGIN |
---|
33 | |
---|
34 | // --------------------------------------------------------------------------- |
---|
35 | // Forward Declaration |
---|
36 | // --------------------------------------------------------------------------- |
---|
37 | class RangeToken; |
---|
38 | class CharToken; |
---|
39 | class ClosureToken; |
---|
40 | class ConditionToken; |
---|
41 | class ConcatToken; |
---|
42 | class ModifierToken; |
---|
43 | class ParenToken; |
---|
44 | class StringToken; |
---|
45 | class UnionToken; |
---|
46 | |
---|
47 | class XMLUTIL_EXPORT TokenFactory : public XMemory |
---|
48 | { |
---|
49 | |
---|
50 | public: |
---|
51 | // ----------------------------------------------------------------------- |
---|
52 | // Constructors and destructors |
---|
53 | // ----------------------------------------------------------------------- |
---|
54 | TokenFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
55 | ~TokenFactory(); |
---|
56 | |
---|
57 | // ----------------------------------------------------------------------- |
---|
58 | // Factory methods |
---|
59 | // ----------------------------------------------------------------------- |
---|
60 | Token* createToken(const unsigned short tokType); |
---|
61 | |
---|
62 | ParenToken* createLook(const unsigned short tokType, Token* const token); |
---|
63 | ParenToken* createParenthesis(Token* const token, const int noGroups); |
---|
64 | ClosureToken* createClosure(Token* const token, bool isNonGreedy = false); |
---|
65 | ConcatToken* createConcat(Token* const token1, Token* const token2); |
---|
66 | UnionToken* createUnion(const bool isConcat = false); |
---|
67 | RangeToken* createRange(const bool isNegRange = false); |
---|
68 | CharToken* createChar(const XMLUInt32 ch, const bool isAnchor = false); |
---|
69 | StringToken* createBackReference(const int refNo); |
---|
70 | StringToken* createString(const XMLCh* const literal); |
---|
71 | ModifierToken* createModifierGroup(Token* const child, |
---|
72 | const int add, const int mask); |
---|
73 | ConditionToken* createCondition(const int refNo, Token* const condition, |
---|
74 | Token* const yesFlow, Token* const noFlow); |
---|
75 | |
---|
76 | |
---|
77 | //static void printUnicode(); |
---|
78 | |
---|
79 | // ----------------------------------------------------------------------- |
---|
80 | // Getter methods |
---|
81 | // ----------------------------------------------------------------------- |
---|
82 | /* |
---|
83 | * Gets a commonly used RangeToken from the token registry based on the |
---|
84 | * range name. |
---|
85 | */ |
---|
86 | RangeToken* getRange(const XMLCh* const name,const bool complement=false); |
---|
87 | Token* getLineBegin(); |
---|
88 | Token* getLineBegin2(); |
---|
89 | Token* getLineEnd(); |
---|
90 | Token* getStringBegin(); |
---|
91 | Token* getStringEnd(); |
---|
92 | Token* getStringEnd2(); |
---|
93 | Token* getWordEdge(); |
---|
94 | Token* getNotWordEdge(); |
---|
95 | Token* getWordBegin(); |
---|
96 | Token* getWordEnd(); |
---|
97 | Token* getDot(); |
---|
98 | Token* getCombiningCharacterSequence(); |
---|
99 | Token* getGraphemePattern(); |
---|
100 | MemoryManager* getMemoryManager() const; |
---|
101 | |
---|
102 | static RangeToken* staticGetRange(const XMLCh* const name,const bool complement=false); |
---|
103 | |
---|
104 | // ----------------------------------------------------------------------- |
---|
105 | // Notification that lazy data has been deleted |
---|
106 | // ----------------------------------------------------------------------- |
---|
107 | static void reinitTokenFactoryMutex(); |
---|
108 | |
---|
109 | private: |
---|
110 | // ----------------------------------------------------------------------- |
---|
111 | // Unimplemented constructors and operators |
---|
112 | // ----------------------------------------------------------------------- |
---|
113 | TokenFactory(const TokenFactory&); |
---|
114 | TokenFactory& operator=(const TokenFactory&); |
---|
115 | |
---|
116 | // ----------------------------------------------------------------------- |
---|
117 | // Private data members |
---|
118 | // |
---|
119 | // fRangeInitialized |
---|
120 | // Indicates whether we have initialized the RangeFactory instance or |
---|
121 | // not |
---|
122 | // |
---|
123 | // fToken |
---|
124 | // Contains user created Token objects. Used for memory cleanup. |
---|
125 | // ----------------------------------------------------------------------- |
---|
126 | RefVectorOf<Token>* fTokens; |
---|
127 | Token* fEmpty; |
---|
128 | Token* fLineBegin; |
---|
129 | Token* fLineBegin2; |
---|
130 | Token* fLineEnd; |
---|
131 | Token* fStringBegin; |
---|
132 | Token* fStringEnd; |
---|
133 | Token* fStringEnd2; |
---|
134 | Token* fWordEdge; |
---|
135 | Token* fNotWordEdge; |
---|
136 | Token* fWordEnd; |
---|
137 | Token* fWordBegin; |
---|
138 | Token* fDot; |
---|
139 | Token* fCombiningChar; |
---|
140 | Token* fGrapheme; |
---|
141 | MemoryManager* fMemoryManager; |
---|
142 | }; |
---|
143 | |
---|
144 | inline RangeToken* TokenFactory::getRange(const XMLCh* const name,const bool complement) |
---|
145 | { |
---|
146 | return staticGetRange(name, complement); |
---|
147 | } |
---|
148 | |
---|
149 | inline MemoryManager* TokenFactory::getMemoryManager() const |
---|
150 | { |
---|
151 | return fMemoryManager; |
---|
152 | } |
---|
153 | |
---|
154 | XERCES_CPP_NAMESPACE_END |
---|
155 | |
---|
156 | #endif |
---|
157 | |
---|
158 | /** |
---|
159 | * End file TokenFactory |
---|
160 | */ |
---|
161 | |
---|