|
||||
File indexing completed on 2025-01-18 10:15:01
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_RANGETOKENMAP_HPP) 0023 #define XERCESC_INCLUDE_GUARD_RANGETOKENMAP_HPP 0024 0025 // --------------------------------------------------------------------------- 0026 // Includes 0027 // --------------------------------------------------------------------------- 0028 #include <xercesc/util/Mutexes.hpp> 0029 #include <xercesc/util/RefHashTableOf.hpp> 0030 0031 XERCES_CPP_NAMESPACE_BEGIN 0032 0033 // --------------------------------------------------------------------------- 0034 // Forward Declaration 0035 // --------------------------------------------------------------------------- 0036 class RangeToken; 0037 class RangeFactory; 0038 class TokenFactory; 0039 class XMLStringPool; 0040 0041 class XMLUTIL_EXPORT RangeTokenElemMap : public XMemory 0042 { 0043 0044 public: 0045 RangeTokenElemMap(unsigned int categoryId); 0046 ~RangeTokenElemMap(); 0047 0048 // ----------------------------------------------------------------------- 0049 // Getter methods 0050 // ----------------------------------------------------------------------- 0051 unsigned int getCategoryId() const; 0052 RangeToken* getRangeToken(const bool complement = false) const; 0053 0054 // ----------------------------------------------------------------------- 0055 // Setter methods 0056 // ----------------------------------------------------------------------- 0057 void setRangeToken(RangeToken* const tok, const bool complement = false); 0058 void setCategoryId(const unsigned int categId); 0059 0060 private: 0061 // ----------------------------------------------------------------------- 0062 // Unimplemented constructors and operators 0063 // ----------------------------------------------------------------------- 0064 RangeTokenElemMap(const RangeTokenElemMap&); 0065 RangeTokenElemMap& operator=(const RangeTokenElemMap&); 0066 0067 // Data members 0068 unsigned int fCategoryId; 0069 RangeToken* fRange; 0070 RangeToken* fNRange; 0071 }; 0072 0073 0074 class XMLUTIL_EXPORT RangeTokenMap : public XMemory 0075 { 0076 public: 0077 // ----------------------------------------------------------------------- 0078 // Putter methods 0079 // ----------------------------------------------------------------------- 0080 void addCategory(const XMLCh* const categoryName); 0081 void addRangeMap(const XMLCh* const categoryName, 0082 RangeFactory* const rangeFactory); 0083 void addKeywordMap(const XMLCh* const keyword, 0084 const XMLCh* const categoryName); 0085 0086 // ----------------------------------------------------------------------- 0087 // Instance methods 0088 // ----------------------------------------------------------------------- 0089 static RangeTokenMap* instance(); 0090 0091 // ----------------------------------------------------------------------- 0092 // Setter methods 0093 // ----------------------------------------------------------------------- 0094 void setRangeToken(const XMLCh* const keyword, RangeToken* const tok, 0095 const bool complement = false); 0096 0097 // ----------------------------------------------------------------------- 0098 // Getter methods 0099 // ----------------------------------------------------------------------- 0100 TokenFactory* getTokenFactory() const; 0101 0102 protected: 0103 // ----------------------------------------------------------------------- 0104 // Constructor and destructors 0105 // ----------------------------------------------------------------------- 0106 RangeTokenMap(MemoryManager* manager); 0107 ~RangeTokenMap(); 0108 0109 // ----------------------------------------------------------------------- 0110 // Getter methods 0111 // ----------------------------------------------------------------------- 0112 /* 0113 * Gets a commonly used RangeToken from the token registry based on the 0114 * range name - Called by TokenFactory. 0115 */ 0116 RangeToken* getRange(const XMLCh* const name, 0117 const bool complement = false); 0118 0119 RefHashTableOf<RangeTokenElemMap>* getTokenRegistry() const; 0120 RefHashTableOf<RangeFactory>* getRangeMap() const; 0121 XMLStringPool* getCategories() const; 0122 0123 private: 0124 // ----------------------------------------------------------------------- 0125 // Unimplemented constructors and operators 0126 // ----------------------------------------------------------------------- 0127 RangeTokenMap(const RangeTokenMap&); 0128 RangeTokenMap& operator=(const RangeTokenMap&); 0129 0130 // ----------------------------------------------------------------------- 0131 // Private Helpers methods 0132 // ----------------------------------------------------------------------- 0133 /* 0134 * Initializes the registry with a set of commonly used RangeToken 0135 * objects. 0136 */ 0137 void initializeRegistry(); 0138 void buildTokenRanges(); 0139 void cleanUp(); 0140 friend class TokenFactory; 0141 0142 // ----------------------------------------------------------------------- 0143 // Private data members 0144 // 0145 // fTokenRegistry 0146 // Contains a set of commonly used tokens 0147 // 0148 // fRangeMap 0149 // Contains a map between a category name and a RangeFactory object. 0150 // 0151 // fCategories 0152 // Contains range categories names 0153 // 0154 // fTokenFactory 0155 // Token factory object 0156 // 0157 // fInstance 0158 // A RangeTokenMap instance 0159 // 0160 // fMutex 0161 // A mutex object for synchronization 0162 // ----------------------------------------------------------------------- 0163 RefHashTableOf<RangeTokenElemMap>* fTokenRegistry; 0164 RefHashTableOf<RangeFactory>* fRangeMap; 0165 XMLStringPool* fCategories; 0166 TokenFactory* fTokenFactory; 0167 XMLMutex fMutex; 0168 static RangeTokenMap* fInstance; 0169 0170 friend class XMLInitializer; 0171 }; 0172 0173 // --------------------------------------------------------------------------- 0174 // RangeTokenElemMap: Getter methods 0175 // --------------------------------------------------------------------------- 0176 inline unsigned int RangeTokenElemMap::getCategoryId() const { 0177 0178 return fCategoryId; 0179 } 0180 0181 inline RangeToken* RangeTokenElemMap::getRangeToken(const bool complement) const { 0182 0183 return complement ? fNRange : fRange; 0184 } 0185 0186 // --------------------------------------------------------------------------- 0187 // RangeTokenElemMap: Setter methods 0188 // --------------------------------------------------------------------------- 0189 inline void RangeTokenElemMap::setCategoryId(const unsigned int categId) { 0190 0191 fCategoryId = categId; 0192 } 0193 0194 inline void RangeTokenElemMap::setRangeToken(RangeToken* const tok, 0195 const bool complement) { 0196 0197 if (complement) 0198 fNRange = tok; 0199 else 0200 fRange = tok; 0201 } 0202 0203 // --------------------------------------------------------------------------- 0204 // RangeTokenMap: Getter methods 0205 // --------------------------------------------------------------------------- 0206 inline RefHashTableOf<RangeTokenElemMap>* RangeTokenMap::getTokenRegistry() const { 0207 0208 return fTokenRegistry; 0209 } 0210 0211 inline RefHashTableOf<RangeFactory>* RangeTokenMap::getRangeMap() const { 0212 0213 return fRangeMap; 0214 } 0215 0216 inline XMLStringPool* RangeTokenMap::getCategories() const { 0217 0218 return fCategories; 0219 } 0220 0221 inline TokenFactory* RangeTokenMap::getTokenFactory() const { 0222 0223 return fTokenFactory; 0224 } 0225 0226 XERCES_CPP_NAMESPACE_END 0227 0228 #endif 0229 0230 /** 0231 * End file RangeToken.hpp 0232 */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |