|
||||
File indexing completed on 2024-11-16 09:59:28
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_GRAMMARRESOLVER_HPP) 0023 #define XERCESC_INCLUDE_GUARD_GRAMMARRESOLVER_HPP 0024 0025 #include <xercesc/framework/XMLGrammarPool.hpp> 0026 #include <xercesc/util/RefHashTableOf.hpp> 0027 #include <xercesc/util/StringPool.hpp> 0028 #include <xercesc/validators/common/Grammar.hpp> 0029 0030 XERCES_CPP_NAMESPACE_BEGIN 0031 0032 class DatatypeValidator; 0033 class DatatypeValidatorFactory; 0034 class XMLGrammarDescription; 0035 0036 /** 0037 * This class embodies the representation of a Grammar pool Resolver. 0038 * This class is called from the validator. 0039 * 0040 */ 0041 0042 class VALIDATORS_EXPORT GrammarResolver : public XMemory 0043 { 0044 public: 0045 0046 /** @name Constructor and Destructor */ 0047 //@{ 0048 /** 0049 * 0050 * Default Constructor 0051 */ 0052 GrammarResolver( 0053 XMLGrammarPool* const gramPool 0054 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0055 ); 0056 /** 0057 * Destructor 0058 */ 0059 ~GrammarResolver(); 0060 0061 //@} 0062 0063 /** @name Getter methods */ 0064 //@{ 0065 /** 0066 * Retrieve the DatatypeValidator 0067 * 0068 * @param uriStr the namespace URI 0069 * @param typeName the type name 0070 * @return the DatatypeValidator associated with namespace & type name 0071 */ 0072 DatatypeValidator* getDatatypeValidator(const XMLCh* const uriStr, 0073 const XMLCh* const typeName); 0074 0075 /** 0076 * Retrieve the DatatypeValidatorFactory used for built-in schema types 0077 * 0078 * @return the DatatypeValidator associated with namespace for XMLSchema 0079 */ 0080 DatatypeValidatorFactory* getBuiltinDatatypeValidatorFactory(); 0081 0082 /** 0083 * Retrieve the grammar that is associated with the specified namespace key 0084 * 0085 * @param gramDesc grammar description for the grammar 0086 * @return Grammar abstraction associated with the grammar description 0087 */ 0088 Grammar* getGrammar( XMLGrammarDescription* const gramDesc ) ; 0089 0090 /** 0091 * Retrieve the grammar that is associated with the specified namespace key 0092 * 0093 * @param namespaceKey Namespace key into Grammar pool 0094 * @return Grammar abstraction associated with the NameSpace key. 0095 */ 0096 Grammar* getGrammar( const XMLCh* const namespaceKey ) ; 0097 0098 /** 0099 * Get an enumeration of Grammar in the Grammar pool 0100 * 0101 * @return enumeration of Grammar in Grammar pool 0102 */ 0103 RefHashTableOfEnumerator<Grammar> getGrammarEnumerator() const; 0104 0105 /** 0106 * Get an enumeration of the referenced Grammars 0107 * 0108 * @return enumeration of referenced Grammars 0109 */ 0110 RefHashTableOfEnumerator<Grammar> getReferencedGrammarEnumerator() const; 0111 0112 /** 0113 * Get an enumeration of the cached Grammars in the Grammar pool 0114 * 0115 * @return enumeration of the cached Grammars in Grammar pool 0116 */ 0117 RefHashTableOfEnumerator<Grammar> getCachedGrammarEnumerator() const; 0118 0119 /** 0120 * Get a string pool of schema grammar element/attribute names/prefixes 0121 * (used by TraverseSchema) 0122 * 0123 * @return a string pool of schema grammar element/attribute names/prefixes 0124 */ 0125 XMLStringPool* getStringPool(); 0126 0127 /** 0128 * Is the specified Namespace key in Grammar pool? 0129 * 0130 * @param nameSpaceKey Namespace key 0131 * @return True if Namespace key association is in the Grammar pool. 0132 */ 0133 bool containsNameSpace( const XMLCh* const nameSpaceKey ); 0134 0135 inline XMLGrammarPool* getGrammarPool() const; 0136 0137 inline MemoryManager* getGrammarPoolMemoryManager() const; 0138 0139 //@} 0140 0141 /** @name Setter methods */ 0142 //@{ 0143 0144 /** 0145 * Set the 'Grammar caching' flag 0146 */ 0147 void cacheGrammarFromParse(const bool newState); 0148 0149 /** 0150 * Set the 'Use cached grammar' flag 0151 */ 0152 void useCachedGrammarInParse(const bool newState); 0153 0154 //@} 0155 0156 0157 /** @name GrammarResolver methods */ 0158 //@{ 0159 /** 0160 * Add the Grammar with Namespace Key associated to the Grammar Pool. 0161 * The Grammar will be owned by the Grammar Pool. 0162 * 0163 * @param grammarToAdopt Grammar abstraction used by validator. 0164 */ 0165 void putGrammar(Grammar* const grammarToAdopt ); 0166 0167 /** 0168 * Returns the Grammar with Namespace Key associated from the Grammar Pool 0169 * The Key entry is removed from the table (grammar is not deleted if 0170 * adopted - now owned by caller). 0171 * 0172 * @param nameSpaceKey Key to associate with Grammar abstraction 0173 */ 0174 Grammar* orphanGrammar(const XMLCh* const nameSpaceKey); 0175 0176 /** 0177 * Cache the grammars in fGrammarBucket to fCachedGrammarRegistry. 0178 * If a grammar with the same key is already cached, an exception is 0179 * thrown and none of the grammars will be cached. 0180 */ 0181 void cacheGrammars(); 0182 0183 /** 0184 * Reset internal Namespace/Grammar registry. 0185 */ 0186 void reset(); 0187 void resetCachedGrammar(); 0188 0189 /** 0190 * Returns an XSModel, either from the GrammarPool or by creating one 0191 */ 0192 XSModel* getXSModel(); 0193 0194 0195 ValueVectorOf<SchemaGrammar*>* getGrammarsToAddToXSModel(); 0196 0197 //@} 0198 0199 private: 0200 // ----------------------------------------------------------------------- 0201 // Unimplemented constructors and operators 0202 // ----------------------------------------------------------------------- 0203 GrammarResolver(const GrammarResolver&); 0204 GrammarResolver& operator=(const GrammarResolver&); 0205 0206 // ----------------------------------------------------------------------- 0207 // Private data members 0208 // 0209 // fStringPool The string pool used by TraverseSchema to store 0210 // element/attribute names and prefixes. 0211 // Always owned by Grammar pool implementation 0212 // 0213 // fGrammarBucket The parsed Grammar Pool, if no caching option. 0214 // 0215 // fGrammarFromPool Referenced Grammar Set, not owned 0216 // 0217 // fGrammarPool The Grammar Set either plugged or created. 0218 // 0219 // fDataTypeReg DatatypeValidatorFactory registry 0220 // 0221 // fMemoryManager Pluggable memory manager for dynamic memory 0222 // allocation/deallocation 0223 // ----------------------------------------------------------------------- 0224 bool fCacheGrammar; 0225 bool fUseCachedGrammar; 0226 bool fGrammarPoolFromExternalApplication; 0227 XMLStringPool* fStringPool; 0228 RefHashTableOf<Grammar>* fGrammarBucket; 0229 RefHashTableOf<Grammar>* fGrammarFromPool; 0230 DatatypeValidatorFactory* fDataTypeReg; 0231 MemoryManager* fMemoryManager; 0232 XMLGrammarPool* fGrammarPool; 0233 XSModel* fXSModel; 0234 XSModel* fGrammarPoolXSModel; 0235 ValueVectorOf<SchemaGrammar*>* fGrammarsToAddToXSModel; 0236 }; 0237 0238 inline XMLStringPool* GrammarResolver::getStringPool() { 0239 0240 return fStringPool; 0241 } 0242 0243 0244 inline void GrammarResolver::useCachedGrammarInParse(const bool aValue) 0245 { 0246 fUseCachedGrammar = aValue; 0247 } 0248 0249 inline XMLGrammarPool* GrammarResolver::getGrammarPool() const 0250 { 0251 return fGrammarPool; 0252 } 0253 0254 inline MemoryManager* GrammarResolver::getGrammarPoolMemoryManager() const 0255 { 0256 return fGrammarPool->getMemoryManager(); 0257 } 0258 0259 inline ValueVectorOf<SchemaGrammar*>* GrammarResolver::getGrammarsToAddToXSModel() 0260 { 0261 return fGrammarsToAddToXSModel; 0262 } 0263 0264 inline DatatypeValidatorFactory* GrammarResolver::getBuiltinDatatypeValidatorFactory() 0265 { 0266 return fDataTypeReg; 0267 } 0268 0269 XERCES_CPP_NAMESPACE_END 0270 0271 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |