Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:02

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_TOKENFACTORY_HPP)
0023 #define XERCESC_INCLUDE_GUARD_TOKENFACTORY_HPP
0024 
0025 // ---------------------------------------------------------------------------
0026 //  Includes
0027 // ---------------------------------------------------------------------------
0028 #include <xercesc/util/RefVectorOf.hpp>
0029 #include <xercesc/util/regx/Token.hpp>
0030 #include <xercesc/util/Mutexes.hpp>
0031 
0032 XERCES_CPP_NAMESPACE_BEGIN
0033 
0034 // ---------------------------------------------------------------------------
0035 //  Forward Declaration
0036 // ---------------------------------------------------------------------------
0037 class RangeToken;
0038 class CharToken;
0039 class ClosureToken;
0040 class ConcatToken;
0041 class ParenToken;
0042 class StringToken;
0043 class UnionToken;
0044 
0045 class XMLUTIL_EXPORT TokenFactory : public XMemory
0046 {
0047 
0048 public:
0049     // -----------------------------------------------------------------------
0050     //  Constructors and destructors
0051     // -----------------------------------------------------------------------
0052     TokenFactory(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0053     ~TokenFactory();
0054 
0055     // -----------------------------------------------------------------------
0056     //  Factory methods
0057     // -----------------------------------------------------------------------
0058     Token* createToken(const Token::tokType tkType);
0059 
0060     ParenToken* createParenthesis(Token* const token, const int noGroups);
0061     ClosureToken* createClosure(Token* const token, bool isNonGreedy = false);
0062     ConcatToken* createConcat(Token* const token1, Token* const token2);
0063     UnionToken* createUnion(const bool isConcat = false);
0064     RangeToken* createRange(const bool isNegRange = false);
0065     CharToken* createChar(const XMLUInt32 ch, const bool isAnchor = false);
0066     StringToken* createBackReference(const int refNo);
0067     StringToken* createString(const XMLCh* const literal);
0068 
0069 
0070     //static void printUnicode();
0071 
0072     // -----------------------------------------------------------------------
0073     //  Getter methods
0074     // -----------------------------------------------------------------------
0075     /*
0076      *  Gets a commonly used RangeToken from the token registry based on the
0077      *  range name.
0078      */
0079     RangeToken* getRange(const XMLCh* const name,const bool complement=false);
0080     Token* getLineBegin();
0081     Token* getLineEnd();
0082     Token* getDot();
0083     MemoryManager* getMemoryManager() const;
0084 
0085     static RangeToken* staticGetRange(const XMLCh* const name,const bool complement=false);
0086 
0087     // -----------------------------------------------------------------------
0088     //  Notification that lazy data has been deleted
0089     // -----------------------------------------------------------------------
0090     static void reinitTokenFactoryMutex();
0091 
0092 private:
0093     // -----------------------------------------------------------------------
0094     //  Unimplemented constructors and operators
0095     // -----------------------------------------------------------------------
0096     TokenFactory(const TokenFactory&);
0097     TokenFactory& operator=(const TokenFactory&);
0098 
0099     // -----------------------------------------------------------------------
0100     //  Private data members
0101     //
0102     //  fRangeInitialized
0103     //      Indicates whether we have initialized the RangeFactory instance or
0104     //      not
0105     //        
0106     //  fToken
0107     //      Contains user created Token objects. Used for memory cleanup.
0108     // -----------------------------------------------------------------------
0109     RefVectorOf<Token>* fTokens;
0110     Token*              fEmpty;
0111     Token*              fLineBegin;
0112     Token*              fLineEnd;
0113     Token*              fDot;
0114     MemoryManager*      fMemoryManager;
0115 };
0116 
0117 inline RangeToken* TokenFactory::getRange(const XMLCh* const name,const bool complement)
0118 {
0119     return staticGetRange(name, complement);
0120 }
0121 
0122 inline MemoryManager* TokenFactory::getMemoryManager() const
0123 {
0124     return fMemoryManager;
0125 }
0126 
0127 XERCES_CPP_NAMESPACE_END
0128 
0129 #endif
0130 
0131 /**
0132   *    End file TokenFactory
0133   */
0134