diff --git a/src/xercesc/dom/deprecated/DOMParser.cpp b/src/xercesc/dom/deprecated/DOMParser.cpp index 629ca04953eee493b711d96d7997891a939fb2b2..42f3b62cb42a653f9596779dd97fd20c72169aef 100644 --- a/src/xercesc/dom/deprecated/DOMParser.cpp +++ b/src/xercesc/dom/deprecated/DOMParser.cpp @@ -147,7 +147,7 @@ void DOMParser::initialize() { // Create grammar resolver and URI string pool to pass to the scanner fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager); - fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager); + fURIStringPool = fGrammarResolver->getStringPool(); // Create a scanner and tell it what validator to use. Then set us // as the document event handler so we can fill the DOM document. @@ -165,7 +165,8 @@ void DOMParser::cleanUp() delete fNodeStack; delete fScanner; delete fGrammarResolver; - delete fURIStringPool; + // grammar pool must do this + //delete fURIStringPool; if (fValidator) delete fValidator; diff --git a/src/xercesc/framework/XMLGrammarPool.hpp b/src/xercesc/framework/XMLGrammarPool.hpp index 07b6b98f508eef0bd0f1a1af0be2c88c1fea2faa..f2d83bf54a5c565d42ab03b6216340d0cf327d24 100644 --- a/src/xercesc/framework/XMLGrammarPool.hpp +++ b/src/xercesc/framework/XMLGrammarPool.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/09/16 18:30:54 neilg + * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation + * * Revision 1.3 2003/09/02 08:59:02 gareth * Added API to get enumerator of grammars. * @@ -73,8 +76,8 @@ #define XMLGRAMMARPOOL_HPP #include <xercesc/util/PlatformUtils.hpp> -#include <xercesc/util/XMemory.hpp> #include <xercesc/util/RefHashTableOf.hpp> +#include <xercesc/util/XMemory.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -85,6 +88,7 @@ class DTDGrammar; class SchemaGrammar; class XMLDTDDescription; class XMLSchemaDescription; +class XMLStringPool; class XMLPARSER_EXPORT XMLGrammarPool : public XMemory { @@ -151,17 +155,19 @@ public : virtual void clear() = 0; /** - * lookPool + * lockPool * - * The grammar pool is looked and accessed exclusively by the looking thread + * When this method is called by the application, the + * grammar pool should stop adding new grammars to the cache. * */ virtual void lockPool() = 0; /** - * lookPool + * unlockPool * - * The grammar pool is accessible by multi threads + * After this method has been called, the grammar pool implementation + * should return to its default behaviour when cacheGrammars(...) is called. * */ virtual void unlockPool() = 0; @@ -194,6 +200,7 @@ public : * */ virtual XMLSchemaDescription* createSchemaDescription(const XMLCh* const targetNamespace) = 0; + //@} // ----------------------------------------------------------------------- @@ -210,6 +217,13 @@ public : return fMemMgr; } + /** + * 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() = 0; //@} protected : diff --git a/src/xercesc/internal/XMLGrammarPoolImpl.cpp b/src/xercesc/internal/XMLGrammarPoolImpl.cpp index 088c5af375e4d6c00a1d2716f3eef194d63e7b24..a85d70bb56fe35009bf5a597a770de6b49fefd06 100644 --- a/src/xercesc/internal/XMLGrammarPoolImpl.cpp +++ b/src/xercesc/internal/XMLGrammarPoolImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/09/16 18:30:54 neilg + * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation + * * Revision 1.4 2003/09/02 08:59:02 gareth * Added API to get enumerator of grammars. * @@ -92,13 +95,16 @@ XERCES_CPP_NAMESPACE_BEGIN XMLGrammarPoolImpl::~XMLGrammarPoolImpl() { delete fGrammarRegistry; + delete fStringPool; } XMLGrammarPoolImpl::XMLGrammarPoolImpl(MemoryManager* const memMgr) :XMLGrammarPool(memMgr) ,fGrammarRegistry(0) +,fStringPool(0) { fGrammarRegistry = new (memMgr) RefHashTableOf<Grammar>(29, true, memMgr); + fStringPool = new (memMgr) XMLStringPool(109, memMgr); } // ----------------------------------------------------------------------- @@ -182,4 +188,9 @@ XMLSchemaDescription* XMLGrammarPoolImpl::createSchemaDescription(const XMLCh* c return new (getMemoryManager()) XMLSchemaDescriptionImpl(targetNamespace, getMemoryManager()); } +inline XMLStringPool *XMLGrammarPoolImpl::getURIStringPool() +{ + return fStringPool; +} + XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/internal/XMLGrammarPoolImpl.hpp b/src/xercesc/internal/XMLGrammarPoolImpl.hpp index f0be2ebb5e035d6ddd871aed3b67f2960feecc21..26539dc2f998778eb21b0f9119227a16643208ec 100644 --- a/src/xercesc/internal/XMLGrammarPoolImpl.hpp +++ b/src/xercesc/internal/XMLGrammarPoolImpl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/09/16 18:30:54 neilg + * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation + * * Revision 1.4 2003/09/02 08:59:02 gareth * Added API to get enumerator of grammars. * @@ -146,17 +149,19 @@ public : virtual void clear(); /** - * lookPool + * lockPool * - * The grammar pool is looked and accessed exclusively by the looking thread + * When this method is called by the application, the + * grammar pool should stop adding new grammars to the cache. * */ virtual void lockPool(); /** - * lookPool + * unlockPool * - * The grammar pool is accessible by multi threads + * After this method has been called, the grammar pool implementation + * should return to its default behaviour when cacheGrammars(...) is called. * */ virtual void unlockPool(); @@ -191,6 +196,20 @@ public : virtual XMLSchemaDescription* createSchemaDescription(const XMLCh* const targetNamespace); //@} + // ----------------------------------------------------------------------- + /** @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(); + + // @} private: // ----------------------------------------------------------------------- /** name Unimplemented copy constructor and operator= */ @@ -205,9 +224,12 @@ private: // fGrammarRegistry: // // container + // fStringPool + // grammars need a string pool for URI -> int mappings // // ----------------------------------------------------------------------- RefHashTableOf<Grammar>* fGrammarRegistry; + XMLStringPool * fStringPool; }; diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp index 843754378fffabfefca097d3d75027c67d1840b0..b4dbe0131c82c07955c19747162449955f1f6d71 100644 --- a/src/xercesc/parsers/AbstractDOMParser.cpp +++ b/src/xercesc/parsers/AbstractDOMParser.cpp @@ -154,7 +154,7 @@ void AbstractDOMParser::initialize() { // Create grammar resolver and string pool to pass to the scanner fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager); - fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager); + fURIStringPool = fGrammarResolver->getStringPool(); // Create a scanner and tell it what validator to use. Then set us // as the document event handler so we can fill the DOM document. @@ -178,7 +178,8 @@ void AbstractDOMParser::cleanUp() delete fNodeStack; delete fScanner; delete fGrammarResolver; - delete fURIStringPool; + // grammar pool *always* owns this + //delete fURIStringPool; fMemoryManager->deallocate(fImplementationFeatures); if (fValidator) diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp index 83f8ce4925ae5864bbdb9291548abd9e2a08ebb1..1480f6d842103f5a884324c6cb79df9651accbcd 100644 --- a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp +++ b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.27 2003/09/16 18:30:54 neilg + * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation + * * Revision 1.26 2003/08/13 15:43:24 knoaman * Use memory manager when creating SAX exceptions. * @@ -362,7 +365,7 @@ void SAX2XMLReaderImpl::initialize() { // Create grammar resolver and string pool that we pass to the scanner fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager); - fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager); + fURIStringPool = fGrammarResolver->getStringPool(); // Create a scanner and tell it what validator to use. Then set us // as the document event handler so we can fill the DOM document. @@ -396,7 +399,8 @@ void SAX2XMLReaderImpl::cleanUp() delete fTempAttrVec; delete fPrefixCounts; delete fGrammarResolver; - delete fURIStringPool; + // grammar pool must do this + //delete fURIStringPool; } // --------------------------------------------------------------------------- diff --git a/src/xercesc/parsers/SAXParser.cpp b/src/xercesc/parsers/SAXParser.cpp index 6466a8afe99bcc3a7126228bccc66d2e82d7e92f..852fdf193c9c515cb5a2897c07668ed57656b636 100644 --- a/src/xercesc/parsers/SAXParser.cpp +++ b/src/xercesc/parsers/SAXParser.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.25 2003/09/16 18:30:54 neilg + * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation + * * Revision 1.24 2003/08/13 15:43:24 knoaman * Use memory manager when creating SAX exceptions. * @@ -314,7 +317,7 @@ void SAXParser::initialize() { // Create grammar resolver and string pool to pass to scanner fGrammarResolver = new (fMemoryManager) GrammarResolver(fGrammarPool, fMemoryManager); - fURIStringPool = new (fMemoryManager) XMLStringPool(109, fMemoryManager); + fURIStringPool = fGrammarResolver->getStringPool(); // Create our scanner and tell it what validator to use fScanner = XMLScannerResolver::getDefaultScanner(fValidator, fGrammarResolver, fMemoryManager); @@ -333,7 +336,8 @@ void SAXParser::cleanUp() fMemoryManager->deallocate(fAdvDHList);//delete [] fAdvDHList; delete fScanner; delete fGrammarResolver; - delete fURIStringPool; + // grammar pool must do this + //delete fURIStringPool; if (fValidator) delete fValidator; diff --git a/src/xercesc/validators/common/GrammarResolver.cpp b/src/xercesc/validators/common/GrammarResolver.cpp index 61a63adbd801d1584efb5e278316b8be42b787c9..087fcfe34e02874e3a935ab1fccdce1c31d8e741 100644 --- a/src/xercesc/validators/common/GrammarResolver.cpp +++ b/src/xercesc/validators/common/GrammarResolver.cpp @@ -57,6 +57,9 @@ /* * $Log$ + * Revision 1.19 2003/09/16 18:30:54 neilg + * make Grammar pool be responsible for creating and owning URI string pools. This is one more step towards having grammars be independent of the parsers involved in their creation + * * Revision 1.18 2003/09/02 09:04:44 gareth * added API to get enumerator to referenced grammars. * @@ -147,7 +150,7 @@ GrammarResolver::GrammarResolver(XMLGrammarPool* const gramPool :fCacheGrammar(false) ,fUseCachedGrammar(false) ,fGrammarPoolFromExternalApplication(true) -,fStringPool(109, manager) +,fStringPool(0) ,fGrammarBucket(0) ,fGrammarFromPool(0) ,fDataTypeReg(0) @@ -172,6 +175,7 @@ GrammarResolver::GrammarResolver(XMLGrammarPool* const gramPool fGrammarPool = new (manager) XMLGrammarPoolImpl(manager); fGrammarPoolFromExternalApplication=false; } + fStringPool = fGrammarPool->getURIStringPool(); } diff --git a/src/xercesc/validators/common/GrammarResolver.hpp b/src/xercesc/validators/common/GrammarResolver.hpp index c887e4d32a869f4d1db13d553d7b9e1927c5833e..6a9214c7617bb0d64a2a17a0d7bc0015079d8a67 100644 --- a/src/xercesc/validators/common/GrammarResolver.hpp +++ b/src/xercesc/validators/common/GrammarResolver.hpp @@ -228,6 +228,7 @@ private: // // fStringPool The string pool used by TraverseSchema to store // element/attribute names and prefixes. + // Always owned by Grammar pool implementation // // fGrammarBucket The parsed Grammar Pool, if no caching option. // @@ -243,7 +244,7 @@ private: bool fCacheGrammar; bool fUseCachedGrammar; bool fGrammarPoolFromExternalApplication; - XMLStringPool fStringPool; + XMLStringPool* fStringPool; RefHashTableOf<Grammar>* fGrammarBucket; RefHashTableOf<Grammar>* fGrammarFromPool; DatatypeValidatorFactory* fDataTypeReg; @@ -253,7 +254,7 @@ private: inline XMLStringPool* GrammarResolver::getStringPool() { - return &fStringPool; + return fStringPool; }