/usr/include/xercesc/framework/XMLGrammarPoolImpl.hpp is in libxerces-c-dev 3.1.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLGrammarPoolImpl.hpp 671531 2008-06-25 12:38:28Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLGRAMMARPOOLIMPL_HPP)
#define XERCESC_INCLUDE_GUARD_XMLGRAMMARPOOLIMPL_HPP
#include <xercesc/framework/XMLGrammarPool.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLSynchronizedStringPool;
class XMLUTIL_EXPORT XMLGrammarPoolImpl : public XMLGrammarPool
{
public :
// -----------------------------------------------------------------------
/** @name constructor and destructor */
// -----------------------------------------------------------------------
//@{
XMLGrammarPoolImpl(MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager);
~XMLGrammarPoolImpl();
//@}
// -----------------------------------------------------------------------
/** @name Implementation of Grammar Pool Interface */
// -----------------------------------------------------------------------
//@{
/**
* cacheGrammar
*
* Provide the grammar pool with an opportunity
* to cache the given grammar. If the pool does not choose to do so,
* it should return false; otherwise, it should return true, so that
* the caller knows whether the grammar has been adopted.
*
* @param gramToCache: the Grammar to be cached in the grammar pool
* @return true if the grammar pool has elected to cache the grammar (in which case
* it is assumed to have adopted it); false if it does not cache it
*
*/
virtual bool cacheGrammar(Grammar* const gramToCache);
/**
* retrieveGrammar
*
* @param gramDesc: the Grammar Description used to search for grammar
* cached in the grammar pool
*
*/
virtual Grammar* retrieveGrammar(XMLGrammarDescription* const gramDesc);
/**
* orphanGrammar
*
* grammar removed from the grammar pool and owned by the caller
*
* @param nameSpaceKey: Key used to search for grammar in the grammar pool
*
*/
virtual Grammar* orphanGrammar(const XMLCh* const nameSpaceKey);
/**
* Get an enumeration of the cached Grammars in the Grammar pool
*
* @return enumeration of the cached Grammars in Grammar pool
*/
virtual RefHashTableOfEnumerator<Grammar> getGrammarEnumerator() const;
/**
* clear
*
* all grammars are removed from the grammar pool and deleted.
* @return true if the grammar pool was cleared. false if it did not.
*/
virtual bool clear();
/**
* lockPool
*
* When this method is called by the application, the
* grammar pool should stop adding new grammars to the cache.
*/
virtual void lockPool();
/**
* unlockPool
*
* After this method has been called, the grammar pool implementation
* should return to its default behaviour when cacheGrammars(...) is called.
*
* For PSVI support any previous XSModel that was produced will be deleted.
*/
virtual void unlockPool();
//@}
// -----------------------------------------------------------------------
/** @name Implementation of Factory interface */
// -----------------------------------------------------------------------
//@{
/**
* createDTDGrammar
*
*/
virtual DTDGrammar* createDTDGrammar();
/**
* createSchemaGrammar
*
*/
virtual SchemaGrammar* createSchemaGrammar();
/**
* createDTDDescription
*
*/
virtual XMLDTDDescription* createDTDDescription(const XMLCh* const systemId);
/**
* createSchemaDescription
*
*/
virtual XMLSchemaDescription* createSchemaDescription(const XMLCh* const targetNamespace);
//@}
// -----------------------------------------------------------------------
/** @name schema component model support */
// -----------------------------------------------------------------------
//@{
/***
* Return an XSModel derived from the components of all SchemaGrammars
* in the grammar pool. If the pool is locked, this should
* be a thread-safe operation.
*
* NOTE: The function should NEVER return NULL. If there are no grammars in
* the pool it should return an XSModel containing the Schema for Schema.
*
* Calling getXSModel() on an unlocked grammar pool may result in the
* creation of a new XSModel with the old XSModel being deleted.
* The bool parameter will indicate if the XSModel was changed.
*
* In this implementation, when the pool is not locked a new XSModel will be
* computed each this time the pool is called if the pool has changed (and the
* previous one will be destroyed at that time). When the lockPool()
* method is called, an XSModel will be generated and returned whenever this method is called
* while the pool is in the locked state. This will be destroyed if the unlockPool()
* operation is called. The XSModel will not be serialized,
* but will be recreated if a deserialized pool is in the
* locked state.
*
*/
virtual XSModel *getXSModel(bool& XSModelWasChanged);
// @}
// -----------------------------------------------------------------------
/** @name Getter */
// -----------------------------------------------------------------------
//@{
/**
* Return an XMLStringPool for use by validation routines.
* Implementations should not create a string pool on each call to this
* method, but should maintain one string pool for all grammars
* for which this pool is responsible.
*/
virtual XMLStringPool *getURIStringPool();
// @}
// -----------------------------------------------------------------------
// serialization and deserialization support
// -----------------------------------------------------------------------
/***
*
* Multiple serializations
*
* For multiple serializations, if the same file name is given, then the
* last result will be in the file (overwriting mode), if different file
* names are given, then there are multiple data stores for each serialization.
*
* Multiple deserializations
*
* Not supported
*
* Versioning
*
* Only binary data serialized with the current XercesC Version and
* SerializationLevel is supported.
*
* Clean up
*
* In the event of an exception thrown due to a corrupted data store during
* deserialization, this implementation may not be able to clean up all resources
* allocated, and therefore it is the client application's responsibility to
* clean up those unreleased resources.
*
* Coupling of Grammars and StringPool
*
* This implementation assumes that StringPool shall always be
* serialized/deserialized together with the grammars. In the case that such a
* coupling is not desired, client application can modify this behaviour by
* either derivate from this imlementation and overwrite the serializeGrammars()
* and/or deserializeGrammars() to decouple grammars and string pool, or
* Once deserializeGrammars() is done, insert another StringPool through
* setStringPool().
*
* Client application shall be aware of the unpredicatable/undefined consequence
* of this decoupling.
*/
virtual void serializeGrammars(BinOutputStream* const);
virtual void deserializeGrammars(BinInputStream* const);
private:
virtual void createXSModel();
void
cleanUp();
// -----------------------------------------------------------------------
/** name Unimplemented copy constructor and operator= */
// -----------------------------------------------------------------------
//@{
XMLGrammarPoolImpl(const XMLGrammarPoolImpl& );
XMLGrammarPoolImpl& operator=(const XMLGrammarPoolImpl& );
//@}
// -----------------------------------------------------------------------
//
// fGrammarRegistry:
//
// container
// fStringPool
// grammars need a string pool for URI -> int mappings
// fSynchronizedStringPool
// When the grammar pool is locked, provide a string pool
// that can be updated in a thread-safe manner.
// fLocked
// whether the pool has been locked
//
// -----------------------------------------------------------------------
RefHashTableOf<Grammar>* fGrammarRegistry;
XMLStringPool* fStringPool;
XMLSynchronizedStringPool* fSynchronizedStringPool;
XSModel* fXSModel;
bool fLocked;
bool fXSModelIsValid;
};
XERCES_CPP_NAMESPACE_END
#endif
|