source: icXML/icXML-devel/src/xercesc/util/regx/TokenFactory.hpp

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

Original Xerces files with import mods for icxercesc

File size: 4.7 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: TokenFactory.hpp 678879 2008-07-22 20:05:05Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_TOKENFACTORY_HPP)
23#define XERCESC_INCLUDE_GUARD_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
32XERCES_CPP_NAMESPACE_BEGIN
33
34// ---------------------------------------------------------------------------
35//  Forward Declaration
36// ---------------------------------------------------------------------------
37class RangeToken;
38class CharToken;
39class ClosureToken;
40class ConcatToken;
41class ParenToken;
42class StringToken;
43class UnionToken;
44
45class XMLUTIL_EXPORT TokenFactory : public XMemory
46{
47
48public:
49    // -----------------------------------------------------------------------
50    //  Constructors and destructors
51    // -----------------------------------------------------------------------
52    TokenFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
53    ~TokenFactory();
54
55    // -----------------------------------------------------------------------
56    //  Factory methods
57    // -----------------------------------------------------------------------
58    Token* createToken(const Token::tokType tkType);
59
60    ParenToken* createParenthesis(Token* const token, const int noGroups);
61    ClosureToken* createClosure(Token* const token, bool isNonGreedy = false);
62    ConcatToken* createConcat(Token* const token1, Token* const token2);
63    UnionToken* createUnion(const bool isConcat = false);
64    RangeToken* createRange(const bool isNegRange = false);
65    CharToken* createChar(const XMLUInt32 ch, const bool isAnchor = false);
66    StringToken* createBackReference(const int refNo);
67    StringToken* createString(const XMLCh* const literal);
68
69
70    //static void printUnicode();
71
72    // -----------------------------------------------------------------------
73    //  Getter methods
74    // -----------------------------------------------------------------------
75    /*
76     *  Gets a commonly used RangeToken from the token registry based on the
77     *  range name.
78     */
79    RangeToken* getRange(const XMLCh* const name,const bool complement=false);
80    Token* getLineBegin();
81    Token* getLineEnd();
82    Token* getDot();
83    MemoryManager* getMemoryManager() const;
84
85    static RangeToken* staticGetRange(const XMLCh* const name,const bool complement=false);
86
87    // -----------------------------------------------------------------------
88    //  Notification that lazy data has been deleted
89    // -----------------------------------------------------------------------
90    static void reinitTokenFactoryMutex();
91
92private:
93    // -----------------------------------------------------------------------
94    //  Unimplemented constructors and operators
95    // -----------------------------------------------------------------------
96    TokenFactory(const TokenFactory&);
97    TokenFactory& operator=(const TokenFactory&);
98
99    // -----------------------------------------------------------------------
100    //  Private data members
101    //
102    //  fRangeInitialized
103    //      Indicates whether we have initialized the RangeFactory instance or
104    //      not
105    //       
106    //  fToken
107    //      Contains user created Token objects. Used for memory cleanup.
108    // -----------------------------------------------------------------------
109    RefVectorOf<Token>* fTokens;
110    Token*              fEmpty;
111    Token*              fLineBegin;
112    Token*              fLineEnd;
113    Token*              fDot;
114    MemoryManager*      fMemoryManager;
115};
116
117inline RangeToken* TokenFactory::getRange(const XMLCh* const name,const bool complement)
118{
119    return staticGetRange(name, complement);
120}
121
122inline MemoryManager* TokenFactory::getMemoryManager() const
123{
124    return fMemoryManager;
125}
126
127XERCES_CPP_NAMESPACE_END
128
129#endif
130
131/**
132  *    End file TokenFactory
133  */
134
Note: See TracBrowser for help on using the repository browser.