diff --git a/src/xercesc/dom/deprecated/DOMParser.cpp b/src/xercesc/dom/deprecated/DOMParser.cpp index 8812f18116a288d178be5ed3567bdcfe31391440..163dcb53a91852aa8fdb3f3420b2b72a57574b8a 100644 --- a/src/xercesc/dom/deprecated/DOMParser.cpp +++ b/src/xercesc/dom/deprecated/DOMParser.cpp @@ -453,7 +453,7 @@ void DOMParser::parse(const InputSource& source) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -476,7 +476,7 @@ void DOMParser::parse(const XMLCh* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -499,7 +499,7 @@ void DOMParser::parse(const char* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -531,7 +531,7 @@ bool DOMParser::parseFirst( const XMLCh* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -544,7 +544,7 @@ bool DOMParser::parseFirst( const char* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -557,7 +557,7 @@ bool DOMParser::parseFirst( const InputSource& source // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(source, toFill); } @@ -1407,7 +1407,7 @@ Grammar* DOMParser::loadGrammar(const char* const systemId, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -1434,7 +1434,7 @@ Grammar* DOMParser::loadGrammar(const XMLCh* const systemId, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -1462,7 +1462,7 @@ Grammar* DOMParser::loadGrammar(const InputSource& source, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try diff --git a/src/xercesc/dom/deprecated/DStringPool.cpp b/src/xercesc/dom/deprecated/DStringPool.cpp index 2bf955faa9f39ac1ba1a6c7b9ba2073030ace24c..2daa5d340d2d8785486f9e5b4bf058d60d09a3d9 100644 --- a/src/xercesc/dom/deprecated/DStringPool.cpp +++ b/src/xercesc/dom/deprecated/DStringPool.cpp @@ -126,7 +126,7 @@ const DOMString &DStringPool::getPooledString(const XMLCh *in) DStringPoolEntry **pspe; DStringPoolEntry *spe; - int inHash = XMLString::hash(in, fHashTableSize); + int inHash = XMLString::hash(in, fHashTableSize, fMemoryManager); pspe = &fHashTable[inHash]; while (*pspe != 0) { @@ -148,7 +148,7 @@ const DOMString &DStringPool::getPooledString(const DOMString &in) const XMLCh *inCharData = in.rawBuffer(); int inLength = in.length(); - int inHash = XMLString::hashN(inCharData, inLength, fHashTableSize); + int inHash = XMLString::hashN(inCharData, inLength, fHashTableSize, fMemoryManager); pspe = &fHashTable[inHash]; while (*pspe != 0) diff --git a/src/xercesc/dom/deprecated/NodeIDMap.cpp b/src/xercesc/dom/deprecated/NodeIDMap.cpp index f50dd9c98b0ebc8b1969729d0981425166fc20af..7dd0e97a10cfafa249b4e79abe834b7a438ba8ac 100644 --- a/src/xercesc/dom/deprecated/NodeIDMap.cpp +++ b/src/xercesc/dom/deprecated/NodeIDMap.cpp @@ -80,7 +80,7 @@ NodeIDMap::NodeIDMap(int initialSize, // We need a bigger size than the largest available one. // Big trouble. fSizeIndex--; - ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::NodeIDMap_GrowErr, fMemoryManager); } } @@ -120,7 +120,7 @@ void NodeIDMap::add(AttrImpl *attr) // An initial hash of zero would cause the rehash to fail. // DOMString id=attr->getValue(); - unsigned int initalHash = XMLString::hashN(id.rawBuffer(), id.length(), fSize-1); + unsigned int initalHash = XMLString::hashN(id.rawBuffer(), id.length(), fSize-1, fMemoryManager); initalHash++; unsigned int currentHash = initalHash; @@ -157,7 +157,7 @@ void NodeIDMap::remove(AttrImpl *attr) // An initial hash of zero would cause the rehash to fail. // DOMString id=attr->getValue(); - unsigned int initalHash = XMLString::hashN(id.rawBuffer(), id.length(), fSize-1); + unsigned int initalHash = XMLString::hashN(id.rawBuffer(), id.length(), fSize-1, fMemoryManager); initalHash++; unsigned int currentHash = initalHash; @@ -196,7 +196,7 @@ AttrImpl *NodeIDMap::find(const DOMString &id) // // Get the hashcode for the supplied string. // - unsigned int initalHash = XMLString::hashN(id.rawBuffer(), id.length(), fSize-1); + unsigned int initalHash = XMLString::hashN(id.rawBuffer(), id.length(), fSize-1, fMemoryManager); initalHash++; unsigned int currentHash = initalHash; @@ -247,7 +247,7 @@ void NodeIDMap::growTable() // We need to grow bigger than the largest available size. // Big trouble. fSizeIndex--; - ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::NodeIDMap_GrowErr, fMemoryManager); } // diff --git a/src/xercesc/dom/impl/DOMDeepNodeListPool.c b/src/xercesc/dom/impl/DOMDeepNodeListPool.c index 348dcc3f5b59b9bfbf4bb78ed3075d45e622b230..526312fc14f80b8a5e0c6336670a88a6b982bcdc 100644 --- a/src/xercesc/dom/impl/DOMDeepNodeListPool.c +++ b/src/xercesc/dom/impl/DOMDeepNodeListPool.c @@ -170,7 +170,7 @@ template <class TVal> void DOMDeepNodeListPool<TVal>::initialize(const XMLSize_t modulus) { if (modulus == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager); // Allocate the bucket list and zero them fBucketList = (DOMDeepNodeListPoolTableBucketElem<TVal>**) @@ -295,7 +295,7 @@ DOMDeepNodeListPool<TVal>::getById(const XMLSize_t elemId) { // If its either zero or beyond our current id, its an error if (!elemId || (elemId > fIdCounter)) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_InvalidId, fMemoryManager); return fIdPtrs[elemId]; } @@ -305,7 +305,7 @@ DOMDeepNodeListPool<TVal>::getById(const XMLSize_t elemId) const { // If its either zero or beyond our current id, its an error if (!elemId || (elemId > fIdCounter)) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_InvalidId, fMemoryManager); return fIdPtrs[elemId]; } @@ -401,9 +401,9 @@ template <class TVal> DOMDeepNodeListPoolTableBucketElem<TVal>* DOMDeepNodeListP findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal) { // Hash the key - hashVal = fHash->getHashVal(key1, fHashModulus); + hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -437,9 +437,9 @@ template <class TVal> const DOMDeepNodeListPoolTableBucketElem<TVal>* DOMDeepNod findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal) const { // Hash the key - hashVal = fHash->getHashVal(key1, fHashModulus); + hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key const DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal]; diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.cpp b/src/xercesc/dom/impl/DOMDocumentImpl.cpp index de78203c42b467ff1d3ea7f8db63e4f4cd3746db..c074f11c97fbdee5f0dd517e7c08cdbea42799f5 100644 --- a/src/xercesc/dom/impl/DOMDocumentImpl.cpp +++ b/src/xercesc/dom/impl/DOMDocumentImpl.cpp @@ -1265,7 +1265,7 @@ void DOMDocumentImpl::callUserDataHandlers(const DOMNodeImpl* n, DOMUserDataHand DOMNodeUserDataTable* node_userDataTable = fUserDataTable->get((void*)n); if (node_userDataTable) { - RefHashTableOfEnumerator<DOMUserDataRecord> userDataEnum(node_userDataTable); + RefHashTableOfEnumerator<DOMUserDataRecord> userDataEnum(node_userDataTable, false, fMemoryManager); // walk through the entire node_userDataTable table while (userDataEnum.hasMoreElements()) { diff --git a/src/xercesc/dom/impl/DOMNodeIDMap.cpp b/src/xercesc/dom/impl/DOMNodeIDMap.cpp index 15d6ae67e43655166a45398e6f73518373671b17..3c0ae5d1cf3f0496ab6e63774346036ae52f41d6 100644 --- a/src/xercesc/dom/impl/DOMNodeIDMap.cpp +++ b/src/xercesc/dom/impl/DOMNodeIDMap.cpp @@ -85,7 +85,7 @@ DOMNodeIDMap::DOMNodeIDMap(int initialSize, DOMDocument *doc) // We need a bigger size than the largest available one. // Big trouble. fSizeIndex--; - ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::NodeIDMap_GrowErr, ((DOMDocumentImpl *)fDoc)->getMemoryManager()); } } @@ -126,7 +126,7 @@ void DOMNodeIDMap::add(DOMAttr *attr) // An initial hash of zero would cause the rehash to fail. // const XMLCh *id=attr->getValue(); - XMLSize_t initalHash = XMLString::hash(id, fSize-1); + XMLSize_t initalHash = XMLString::hash(id, fSize-1, ((DOMDocumentImpl *)fDoc)->getMemoryManager()); initalHash++; XMLSize_t currentHash = initalHash; @@ -163,7 +163,7 @@ void DOMNodeIDMap::remove(DOMAttr *attr) // An initial hash of zero would cause the rehash to fail. // const XMLCh *id=attr->getValue(); - XMLSize_t initalHash = XMLString::hash(id, fSize-1); + XMLSize_t initalHash = XMLString::hash(id, fSize-1, ((DOMDocumentImpl *)fDoc)->getMemoryManager()); initalHash++; XMLSize_t currentHash = initalHash; @@ -202,7 +202,7 @@ DOMAttr *DOMNodeIDMap::find(const XMLCh *id) // // Get the hashcode for the supplied string. // - XMLSize_t initalHash = XMLString::hash(id, fSize-1); + XMLSize_t initalHash = XMLString::hash(id, fSize-1, ((DOMDocumentImpl *)fDoc)->getMemoryManager()); initalHash++; XMLSize_t currentHash = initalHash; @@ -253,7 +253,7 @@ void DOMNodeIDMap::growTable() // We need to grow bigger than the largest available size. // Big trouble. fSizeIndex--; - ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::NodeIDMap_GrowErr, ((DOMDocumentImpl *)fDoc)->getMemoryManager()); } // diff --git a/src/xercesc/dom/impl/DOMNormalizer.cpp b/src/xercesc/dom/impl/DOMNormalizer.cpp index e55c6da0b8f24d8cfb7aeb5a8a5cd0a8d120cb06..33498e70fec4eeb72e900e8c42299a8b5b1b0e09 100644 --- a/src/xercesc/dom/impl/DOMNormalizer.cpp +++ b/src/xercesc/dom/impl/DOMNormalizer.cpp @@ -511,7 +511,7 @@ void DOMNormalizer::InScopeNamespaces::Scope::addOrChangeBinding(const XMLCh *pr fUriHash = new (manager) RefHashTableOf<XMLCh>(10, (bool) false, manager); if(fBaseScopeWithBindings) { - RefHashTableOfEnumerator<XMLCh> preEnumer(fBaseScopeWithBindings->fPrefixHash); + RefHashTableOfEnumerator<XMLCh> preEnumer(fBaseScopeWithBindings->fPrefixHash, false, manager); while(preEnumer.hasMoreElements()) { const XMLCh* prefix = (XMLCh*) preEnumer.nextElementKey(); const XMLCh* uri = fBaseScopeWithBindings->fPrefixHash->get((void*)prefix); @@ -520,7 +520,7 @@ void DOMNormalizer::InScopeNamespaces::Scope::addOrChangeBinding(const XMLCh *pr fPrefixHash->put((void *)prefix, (XMLCh*)uri); } - RefHashTableOfEnumerator<XMLCh> uriEnumer(fBaseScopeWithBindings->fUriHash); + RefHashTableOfEnumerator<XMLCh> uriEnumer(fBaseScopeWithBindings->fUriHash, false, manager); while(uriEnumer.hasMoreElements()) { const XMLCh* uri = (XMLCh*) uriEnumer.nextElementKey(); const XMLCh* prefix = fBaseScopeWithBindings->fUriHash->get((void*)uri); diff --git a/src/xercesc/dom/impl/DOMRangeImpl.cpp b/src/xercesc/dom/impl/DOMRangeImpl.cpp index e7877c27e997e0804cde0200ce8b4b6b05b051ca..34649037d817be5ac34f756684b67edb2ee94f7f 100644 --- a/src/xercesc/dom/impl/DOMRangeImpl.cpp +++ b/src/xercesc/dom/impl/DOMRangeImpl.cpp @@ -880,7 +880,7 @@ const XMLCh* DOMRangeImpl::toString() const else tempString = temp; - XMLString::subString(tempString, fStartContainer->getNodeValue(), fStartOffset, fEndOffset); + XMLString::subString(tempString, fStartContainer->getNodeValue(), fStartOffset, fEndOffset, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); const XMLCh* retString = ((DOMDocumentImpl *)fDocument)->getPooledString(tempString); if ((fEndOffset-fStartOffset) >= 3999) @@ -901,7 +901,7 @@ const XMLCh* DOMRangeImpl::toString() const else tempString = temp; - XMLString::subString(tempString, fStartContainer->getNodeValue(), fStartOffset, length); + XMLString::subString(tempString, fStartContainer->getNodeValue(), fStartOffset, length, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); retStringBuf.append(tempString); if ((length - fStartOffset) >= 3999) @@ -970,7 +970,7 @@ const XMLCh* DOMRangeImpl::toString() const else tempString = temp; - XMLString::subString(tempString, fEndContainer->getNodeValue(), 0, fEndOffset); + XMLString::subString(tempString, fEndContainer->getNodeValue(), 0, fEndOffset, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); retStringBuf.append(tempString); if (fEndOffset >= 3999) @@ -1300,7 +1300,7 @@ DOMDocumentFragment* DOMRangeImpl::traverseSameContainer( int how ) else tempString = temp; - XMLString::subString(tempString, cloneCurrent->getNodeValue(), fStartOffset, fEndOffset); + XMLString::subString(tempString, cloneCurrent->getNodeValue(), fStartOffset, fEndOffset, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); cloneCurrent->setNodeValue(((DOMDocumentImpl *)fDocument)->getPooledString(tempString)); if (fEndOffset >= 3999) @@ -1725,7 +1725,7 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how ) else { oldNodeValue = oldTemp; } - XMLString::subString(oldNodeValue, txtValue, 0, offset); + XMLString::subString(oldNodeValue, txtValue, 0, offset, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); if ( how != CLONE_CONTENTS ) n->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(oldNodeValue) ); @@ -1755,7 +1755,7 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how ) else { newNodeValue = newTemp; } - XMLString::subString(newNodeValue, txtValue, offset, startLen); + XMLString::subString(newNodeValue, txtValue, offset, startLen, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); newNode->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(newNodeValue) ); if (offset>= 3999) @@ -1786,7 +1786,7 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how ) else { oldNodeValue = oldTemp; } - XMLString::subString(oldNodeValue, txtValue, offset, endLen); + XMLString::subString(oldNodeValue, txtValue, offset, endLen, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); if ( how != CLONE_CONTENTS ) n->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(oldNodeValue) ); @@ -1816,7 +1816,7 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how ) else { newNodeValue = newTemp; } - XMLString::subString(newNodeValue, txtValue, 0, offset); + XMLString::subString(newNodeValue, txtValue, 0, offset, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); newNode->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(newNodeValue) ); if (offset>= 3999) diff --git a/src/xercesc/dom/impl/DOMStringPool.cpp b/src/xercesc/dom/impl/DOMStringPool.cpp index 78807d999db38fd3f5f6871982cb58afdef1dd97..f722830fc8af87102cb2ddd8e24401b7747b55a5 100644 --- a/src/xercesc/dom/impl/DOMStringPool.cpp +++ b/src/xercesc/dom/impl/DOMStringPool.cpp @@ -128,7 +128,7 @@ const XMLCh *DOMStringPool::getPooledString(const XMLCh *in) DOMStringPoolEntry **pspe; DOMStringPoolEntry *spe; - int inHash = XMLString::hash(in, fHashTableSize); + int inHash = XMLString::hash(in, fHashTableSize, fDoc->getMemoryManager()); pspe = &fHashTable[inHash]; while (*pspe != 0) { diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp index 588e83be09445d493a6f780e7b7ab6e0ed628d6d..675bba7238683ba12c410921f92f7aba1e86099c 100644 --- a/src/xercesc/dom/impl/DOMWriterImpl.cpp +++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.47 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.46 2003/11/24 19:52:22 neilg * fix a typo * @@ -1673,7 +1676,7 @@ void DOMWriterImpl::procUnrepCharInCdataSection(const XMLCh* const nodeValue while (srcPtr < endPtr) { // Build a char ref for the current char - XMLString::binToText(*srcPtr, &tmpBuf[3], 8, 16); + XMLString::binToText(*srcPtr, &tmpBuf[3], 8, 16, fMemoryManager); const unsigned int bufLen = XMLString::stringLen(tmpBuf); tmpBuf[bufLen] = chSemiColon; tmpBuf[bufLen+1] = chNull; diff --git a/src/xercesc/framework/LocalFileFormatTarget.cpp b/src/xercesc/framework/LocalFileFormatTarget.cpp index 9112ea705b9e4e10cc02f6c883ee8c0e47d31fe3..42c61cb6fc39b9fcaae05d2fa168f463934c5267 100644 --- a/src/xercesc/framework/LocalFileFormatTarget.cpp +++ b/src/xercesc/framework/LocalFileFormatTarget.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/05/16 21:36:55 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * @@ -99,7 +102,7 @@ LocalFileFormatTarget::LocalFileFormatTarget( const XMLCh* const fileName fSource = XMLPlatformUtils::openFileToWrite(fileName); if (!fSource) - ThrowXML1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName); + ThrowXMLwithMemMgr1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName, fMemoryManager); // Buffer is one larger than capacity, to allow for zero term fDataBuf = (XMLByte*) fMemoryManager->allocate @@ -123,7 +126,7 @@ LocalFileFormatTarget::LocalFileFormatTarget( const char* const fileName fSource = XMLPlatformUtils::openFileToWrite(fileName); if (!fSource) - ThrowXML1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName); + ThrowXMLwithMemMgr1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName, fMemoryManager); // Buffer is one larger than capacity, to allow for zero term fDataBuf = (XMLByte*) fMemoryManager->allocate diff --git a/src/xercesc/framework/LocalFileInputSource.cpp b/src/xercesc/framework/LocalFileInputSource.cpp index b3ea62a64cb036cb7dd2fce6145332c494d7598a..77dfce245b446c2fb4711f0f264e72376f45a662 100644 --- a/src/xercesc/framework/LocalFileInputSource.cpp +++ b/src/xercesc/framework/LocalFileInputSource.cpp @@ -131,16 +131,16 @@ LocalFileInputSource::LocalFileInputSource( const XMLCh* const basePath // if (XMLPlatformUtils::isRelative(relativePath)) { - XMLCh* tmpBuf = XMLPlatformUtils::weavePaths(basePath, relativePath); + XMLCh* tmpBuf = XMLPlatformUtils::weavePaths(basePath, relativePath, manager); setSystemId(tmpBuf); - XMLPlatformUtils::fgMemoryManager->deallocate(tmpBuf); //delete [] tmpBuf; + manager->deallocate(tmpBuf); //delete [] tmpBuf; } else { - XMLCh* tmpBuf = XMLString::replicate(relativePath, getMemoryManager()); - XMLPlatformUtils::removeDotSlash(tmpBuf); + XMLCh* tmpBuf = XMLString::replicate(relativePath, manager); + XMLPlatformUtils::removeDotSlash(tmpBuf, manager); setSystemId(tmpBuf); - getMemoryManager()->deallocate(tmpBuf);//delete [] tmpBuf; + manager->deallocate(tmpBuf);//delete [] tmpBuf; } } @@ -157,11 +157,11 @@ LocalFileInputSource::LocalFileInputSource(const XMLCh* const filePath, // if (XMLPlatformUtils::isRelative(filePath)) { - XMLCh* curDir = XMLPlatformUtils::getCurrentDirectory(getMemoryManager()); + XMLCh* curDir = XMLPlatformUtils::getCurrentDirectory(manager); int curDirLen = XMLString::stringLen(curDir); int filePathLen = XMLString::stringLen(filePath); - XMLCh* fullDir = (XMLCh*) getMemoryManager()->allocate + XMLCh* fullDir = (XMLCh*) manager->allocate ( (curDirLen + filePathLen + 2) * sizeof(XMLCh) );//new XMLCh [ curDirLen + filePathLen + 2]; @@ -170,20 +170,20 @@ LocalFileInputSource::LocalFileInputSource(const XMLCh* const filePath, fullDir[curDirLen] = chForwardSlash; XMLString::copyString(&fullDir[curDirLen+1], filePath); - XMLPlatformUtils::removeDotSlash(fullDir); - XMLPlatformUtils::removeDotDotSlash(fullDir); + XMLPlatformUtils::removeDotSlash(fullDir, manager); + XMLPlatformUtils::removeDotDotSlash(fullDir, manager); setSystemId(fullDir); - getMemoryManager()->deallocate(curDir);//delete [] curDir; - getMemoryManager()->deallocate(fullDir);//delete [] fullDir; + manager->deallocate(curDir);//delete [] curDir; + manager->deallocate(fullDir);//delete [] fullDir; } else { - XMLCh* tmpBuf = XMLString::replicate(filePath, getMemoryManager()); - XMLPlatformUtils::removeDotSlash(tmpBuf); + XMLCh* tmpBuf = XMLString::replicate(filePath, manager); + XMLPlatformUtils::removeDotSlash(tmpBuf, manager); setSystemId(tmpBuf); - getMemoryManager()->deallocate(tmpBuf);//delete [] tmpBuf; + manager->deallocate(tmpBuf);//delete [] tmpBuf; } } diff --git a/src/xercesc/framework/Wrapper4DOMInputSource.cpp b/src/xercesc/framework/Wrapper4DOMInputSource.cpp index eb0f6787238f101620cc7a663f328ce84ba4a9d7..0163566105a75ea768616d6a6157bf167d7838c8 100644 --- a/src/xercesc/framework/Wrapper4DOMInputSource.cpp +++ b/src/xercesc/framework/Wrapper4DOMInputSource.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/05/30 16:11:43 gareth * Fixes so we compile under VC7.1. Patch by Alberto Massari. * @@ -95,7 +98,7 @@ Wrapper4DOMInputSource::Wrapper4DOMInputSource(DOMInputSource* const inputSource , fInputSource(inputSource) { if (!inputSource) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, getMemoryManager()); } Wrapper4DOMInputSource::~Wrapper4DOMInputSource() diff --git a/src/xercesc/framework/Wrapper4InputSource.cpp b/src/xercesc/framework/Wrapper4InputSource.cpp index 4cea22b765b1b1e95d71ff83765d0a883bdf1bca..e08168261837601ecc39cf3f8f26dcf70a926b9a 100644 --- a/src/xercesc/framework/Wrapper4InputSource.cpp +++ b/src/xercesc/framework/Wrapper4InputSource.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/05/30 16:11:43 gareth * Fixes so we compile under VC7.1. Patch by Alberto Massari. * @@ -88,12 +91,13 @@ XERCES_CPP_NAMESPACE_BEGIN // Wrapper4InputSource: Constructor and Destructor // --------------------------------------------------------------------------- Wrapper4InputSource::Wrapper4InputSource(InputSource* const inputSource, - const bool adoptFlag) : + const bool adoptFlag + , MemoryManager* const manager) : fAdoptInputSource(adoptFlag) , fInputSource(inputSource) { if (!inputSource) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, manager); } Wrapper4InputSource::~Wrapper4InputSource() diff --git a/src/xercesc/framework/Wrapper4InputSource.hpp b/src/xercesc/framework/Wrapper4InputSource.hpp index 188ecadeb9406348844ce81cdbab6c628abb07a8..c48e96f29baa9ad262dc349ad6a32c594ea0b479 100644 --- a/src/xercesc/framework/Wrapper4InputSource.hpp +++ b/src/xercesc/framework/Wrapper4InputSource.hpp @@ -63,6 +63,7 @@ #define WRAPPER4INPUTSOURCE_HPP #include <xercesc/dom/DOMInputSource.hpp> +#include <xercesc/util/PlatformUtils.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -88,8 +89,9 @@ public: * @param adoptFlag Indicates if the wrapper should adopt the wrapped * SAX InputSource. Default is true. */ - Wrapper4InputSource(InputSource* const inputSource, - const bool adoptFlag = true); + Wrapper4InputSource(InputSource* const inputSource + , const bool adoptFlag = true + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** * Destructor diff --git a/src/xercesc/framework/XMLAttDef.cpp b/src/xercesc/framework/XMLAttDef.cpp index 326f1aa2479f1ef9d91ca943a27f17c73e83af67..99057ec06bc19051769fb55f5b50038ecc1549fd 100644 --- a/src/xercesc/framework/XMLAttDef.cpp +++ b/src/xercesc/framework/XMLAttDef.cpp @@ -123,19 +123,21 @@ const unsigned int XMLAttDef::fgInvalidAttrId = 0xFFFFFFFE; // --------------------------------------------------------------------------- // XMLAttDef: Public, static methods // --------------------------------------------------------------------------- -const XMLCh* XMLAttDef::getAttTypeString(const XMLAttDef::AttTypes attrType) +const XMLCh* XMLAttDef::getAttTypeString(const XMLAttDef::AttTypes attrType + , MemoryManager* const manager) { // Check for an invalid attribute type and return a null if ((attrType < AttTypes_Min) || (attrType > AttTypes_Max)) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::AttDef_BadAttType); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttDef_BadAttType, manager); return gAttTypeStrings[attrType]; } -const XMLCh* XMLAttDef::getDefAttTypeString(const XMLAttDef::DefAttTypes attrType) +const XMLCh* XMLAttDef::getDefAttTypeString(const XMLAttDef::DefAttTypes attrType + , MemoryManager* const manager) { // Check for an invalid attribute type and return a null if ((attrType < DefAttTypes_Min) || (attrType > DefAttTypes_Max)) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::AttDef_BadDefAttType); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttDef_BadDefAttType, manager); return gDefAttTypeStrings[attrType]; } diff --git a/src/xercesc/framework/XMLAttDef.hpp b/src/xercesc/framework/XMLAttDef.hpp index cb992243df37e7c42a9840fe8deeabb597b04f34..3a0770c2a46c5b1491479d2214a4d21ea088891b 100644 --- a/src/xercesc/framework/XMLAttDef.hpp +++ b/src/xercesc/framework/XMLAttDef.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/11/24 05:19:15 neilg * update method documentation * @@ -253,7 +256,8 @@ public: * @return A const pointer to the static string that holds the text * description of the passed type. */ - static const XMLCh* getAttTypeString(const AttTypes attrType); + static const XMLCh* getAttTypeString(const AttTypes attrType + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Get a string representation of the passed def attribute type enum * @@ -265,7 +269,8 @@ public: * @return A const pointer to the static string that holds the text * description of the passed default type. */ - static const XMLCh* getDefAttTypeString(const DefAttTypes attrType); + static const XMLCh* getDefAttTypeString(const DefAttTypes attrType + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} diff --git a/src/xercesc/framework/XMLAttr.hpp b/src/xercesc/framework/XMLAttr.hpp index 7a158038b0e8e4d444b56afe1925598cb1ff7d3d..32e2c83d6cbd063385d08cec19b720d1f8677c30 100644 --- a/src/xercesc/framework/XMLAttr.hpp +++ b/src/xercesc/framework/XMLAttr.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/11/24 05:19:37 neilg * update XMLAttr class to carry information needed by DOMTypeInfo * @@ -593,7 +596,7 @@ inline const XMLCh* XMLAttr::getValidatingTypeName() const } else { - return XMLAttDef::getAttTypeString(fType); + return XMLAttDef::getAttTypeString(fType, fMemoryManager); } } diff --git a/src/xercesc/framework/XMLBufferMgr.cpp b/src/xercesc/framework/XMLBufferMgr.cpp index 45859eebf0d16ec994ae877dd169e041e5a6260a..e66a045fe784fb5b553576a991834818e3120eff 100644 --- a/src/xercesc/framework/XMLBufferMgr.cpp +++ b/src/xercesc/framework/XMLBufferMgr.cpp @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.4 2003/12/17 00:18:33 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -152,7 +155,7 @@ XMLBuffer& XMLBufferMgr::bidOnBuffer() } // We did not find one, so freak out - ThrowXML(RuntimeException, XMLExcepts::BufMgr_NoMoreBuffers); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::BufMgr_NoMoreBuffers, fMemoryManager); // NOTE: Dummy return to make some compilers happy. Never really gets called! return *fBufList[0]; @@ -173,7 +176,7 @@ void XMLBufferMgr::releaseBuffer(XMLBuffer& toRelease) } // It was not a legal buffer - ThrowXML(RuntimeException, XMLExcepts::BufMgr_BufferNotInPool); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::BufMgr_BufferNotInPool, fMemoryManager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/framework/XMLFormatter.cpp b/src/xercesc/framework/XMLFormatter.cpp index 292b60b5d5cb951f847fa8b3b4c03c7f954c2783..529beca2a310f6bd46ff8679691a57a5013468d4 100644 --- a/src/xercesc/framework/XMLFormatter.cpp +++ b/src/xercesc/framework/XMLFormatter.cpp @@ -217,11 +217,12 @@ XMLFormatter::XMLFormatter( const char* const outEncoding if (!fXCoder) { fMemoryManager->deallocate(fOutEncoding); //delete [] fOutEncoding; - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , outEncoding + , fMemoryManager ); } @@ -267,11 +268,12 @@ XMLFormatter::XMLFormatter( const XMLCh* const outEncoding if (!fXCoder) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , outEncoding + , fMemoryManager ); } @@ -323,11 +325,12 @@ XMLFormatter::XMLFormatter( const char* const outEncoding if (!fXCoder) { fMemoryManager->deallocate(fOutEncoding); //delete [] fOutEncoding; - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , outEncoding + , fMemoryManager ); } @@ -375,11 +378,12 @@ XMLFormatter::XMLFormatter( const XMLCh* const outEncoding if (!fXCoder) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , outEncoding + , fMemoryManager ); } @@ -603,7 +607,7 @@ void XMLFormatter::writeCharRef(const XMLCh &toWrite) tmpBuf[2] = chLatin_x; // Build a char ref for the current char - XMLString::binToText(toWrite, &tmpBuf[3], 8, 16); + XMLString::binToText(toWrite, &tmpBuf[3], 8, 16, fMemoryManager); const unsigned int bufLen = XMLString::stringLen(tmpBuf); tmpBuf[bufLen] = chSemiColon; tmpBuf[bufLen+1] = chNull; @@ -624,7 +628,7 @@ void XMLFormatter::writeCharRef(unsigned long toWrite) tmpBuf[2] = chLatin_x; // Build a char ref for the current char - XMLString::binToText(toWrite, &tmpBuf[3], 8, 16); + XMLString::binToText(toWrite, &tmpBuf[3], 8, 16, fMemoryManager); const unsigned int bufLen = XMLString::stringLen(tmpBuf); tmpBuf[bufLen] = chSemiColon; tmpBuf[bufLen+1] = chNull; diff --git a/src/xercesc/framework/XMLRecognizer.cpp b/src/xercesc/framework/XMLRecognizer.cpp index 68507fc56f8d2d318d8f207fbf1ecd8c55906786..84e1ab68feb4a0a7d88774673b792464cfc6dd1b 100644 --- a/src/xercesc/framework/XMLRecognizer.cpp +++ b/src/xercesc/framework/XMLRecognizer.cpp @@ -289,10 +289,11 @@ XMLRecognizer::encodingForName(const XMLCh* const encName) const XMLCh* -XMLRecognizer::nameForEncoding(const XMLRecognizer::Encodings theEncoding) +XMLRecognizer::nameForEncoding(const XMLRecognizer::Encodings theEncoding + , MemoryManager* const manager) { if (theEncoding > Encodings_Count) - ThrowXML(RuntimeException, XMLExcepts::XMLRec_UnknownEncoding); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::XMLRec_UnknownEncoding, manager); return gEncodingNameMap[theEncoding]; } diff --git a/src/xercesc/framework/XMLRecognizer.hpp b/src/xercesc/framework/XMLRecognizer.hpp index 0d2f1a256913deeed1227bf225b857f3e94bfeda..408013335b2f55d709b2ba619e0d6e66dae64108 100644 --- a/src/xercesc/framework/XMLRecognizer.hpp +++ b/src/xercesc/framework/XMLRecognizer.hpp @@ -62,6 +62,7 @@ #define XMLRECOGNIZER_HPP #include <xercesc/util/XercesDefs.hpp> +#include <xercesc/util/PlatformUtils.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -155,7 +156,8 @@ public : const XMLCh* const theEncName ); - static const XMLCh* nameForEncoding(const Encodings theEncoding); + static const XMLCh* nameForEncoding(const Encodings theEncoding + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); protected : diff --git a/src/xercesc/framework/XMLValidator.cpp b/src/xercesc/framework/XMLValidator.cpp index 0615a538ce4589ee1372412c96b43ca855b9aaf4..687670c2b7551c916342a36e576b52e574ae71de 100644 --- a/src/xercesc/framework/XMLValidator.cpp +++ b/src/xercesc/framework/XMLValidator.cpp @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.5 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -330,7 +333,7 @@ void XMLValidator::emitError(const XMLValid::Codes toEmit XMLCh errText[maxChars + 1]; // load the text - if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4)) + if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4, fScanner->getMemoryManager())) { // <TBD> Should probably load a default message here } diff --git a/src/xercesc/framework/psvi/XSModel.cpp b/src/xercesc/framework/psvi/XSModel.cpp index 9b3439b5ccf1f989869016b88c7efbcc10578d3f..4bcac015632f34f14e385efbe42d3bf025f46351 100644 --- a/src/xercesc/framework/psvi/XSModel.cpp +++ b/src/xercesc/framework/psvi/XSModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.13 2003/12/15 17:23:48 cargilld * psvi updates; cleanup revisits and bug fixes * @@ -128,7 +131,7 @@ void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem) { // First loop through top-level BUILTIN simple type definitions in the grammar... // all grammar's would be the same... - RefHashTableOfEnumerator<DatatypeValidator> simpleEnum = RefHashTableOfEnumerator<DatatypeValidator> (namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getBuiltInRegistry()); + RefHashTableOfEnumerator<DatatypeValidator> simpleEnum = RefHashTableOfEnumerator<DatatypeValidator> (namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getBuiltInRegistry(), false, fMemoryManager); while (simpleEnum.hasMoreElements()) { DatatypeValidator& curSimple = simpleEnum.nextElement(); @@ -145,7 +148,7 @@ void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem) // end of simple BuiltIn loop // Loop through top-level attribute declarations in the grammar... - RefHashTableOfEnumerator<XMLAttDef> attrEnum = RefHashTableOfEnumerator<XMLAttDef> (namespaceItem->getSchemaGrammar()->getAttributeDeclRegistry()); + RefHashTableOfEnumerator<XMLAttDef> attrEnum = RefHashTableOfEnumerator<XMLAttDef> (namespaceItem->getSchemaGrammar()->getAttributeDeclRegistry(), false, fMemoryManager); while (attrEnum.hasMoreElements()) { @@ -180,7 +183,7 @@ void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem) DVHashTable* dvHT = namespaceItem->getSchemaGrammar()->getDatatypeRegistry()->getUserDefinedRegistry(); if (dvHT) { - RefHashTableOfEnumerator<DatatypeValidator> simpleUserEnum = RefHashTableOfEnumerator<DatatypeValidator> (dvHT); + RefHashTableOfEnumerator<DatatypeValidator> simpleUserEnum = RefHashTableOfEnumerator<DatatypeValidator> (dvHT, false, fMemoryManager); while (simpleUserEnum.hasMoreElements()) { DatatypeValidator& curSimple = simpleUserEnum.nextElement(); @@ -196,7 +199,7 @@ void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem) } // Loop through top-level COMPLEX type definitions in the grammar... - RefHashTableOfEnumerator<ComplexTypeInfo> complexEnum = RefHashTableOfEnumerator<ComplexTypeInfo> (namespaceItem->getSchemaGrammar()->getComplexTypeRegistry()); + RefHashTableOfEnumerator<ComplexTypeInfo> complexEnum = RefHashTableOfEnumerator<ComplexTypeInfo> (namespaceItem->getSchemaGrammar()->getComplexTypeRegistry(), false, fMemoryManager); while (complexEnum.hasMoreElements()) { ComplexTypeInfo& curComplex = complexEnum.nextElement(); @@ -210,7 +213,7 @@ void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem) } // end of type definition loop // Loop through top-level attribute group definitions in the grammar... - RefHashTableOfEnumerator<XercesAttGroupInfo> attrGroupEnum = RefHashTableOfEnumerator<XercesAttGroupInfo> (namespaceItem->getSchemaGrammar()->getAttGroupInfoRegistry()); + RefHashTableOfEnumerator<XercesAttGroupInfo> attrGroupEnum = RefHashTableOfEnumerator<XercesAttGroupInfo> (namespaceItem->getSchemaGrammar()->getAttGroupInfoRegistry(), false, fMemoryManager); while (attrGroupEnum.hasMoreElements()) { XercesAttGroupInfo& curAttrGroup = attrGroupEnum.nextElement(); @@ -221,7 +224,7 @@ void XSModel::addGrammarToXSModel(XSNamespaceItem* namespaceItem) } // end of attribute group loop // Loop through top-level model group definitions in the grammar... - RefHashTableOfEnumerator<XercesGroupInfo> modelGroupEnum = RefHashTableOfEnumerator<XercesGroupInfo> (namespaceItem->getSchemaGrammar()->getGroupInfoRegistry()); + RefHashTableOfEnumerator<XercesGroupInfo> modelGroupEnum = RefHashTableOfEnumerator<XercesGroupInfo> (namespaceItem->getSchemaGrammar()->getGroupInfoRegistry(), false, fMemoryManager); while (modelGroupEnum.hasMoreElements()) { XercesGroupInfo& curModelGroup = modelGroupEnum.nextElement(); diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp index dd50c5db658cf4dabf9b7aa8f0844e41a2892df6..abfedd4f7bfadd953133741b9ffe587dd2f13d9d 100644 --- a/src/xercesc/internal/DGXMLScanner.cpp +++ b/src/xercesc/internal/DGXMLScanner.cpp @@ -107,7 +107,7 @@ DGXMLScanner::DGXMLScanner(XMLValidator* const valToAdopt if (valToAdopt) { if (!valToAdopt->handlesDTD()) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); } else { @@ -149,7 +149,7 @@ DGXMLScanner::DGXMLScanner( XMLDocumentHandler* const docHandler if (valToAdopt) { if (!valToAdopt->handlesDTD()) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); } else { @@ -323,7 +323,7 @@ bool DGXMLScanner::scanNext(XMLPScanToken& token) { // Make sure this token is still legal if (!isLegalToken(token)) - ThrowXML(RuntimeException, XMLExcepts::Scan_BadPScanToken); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_BadPScanToken, fMemoryManager); // Find the next token and remember the reader id unsigned int orgReader; @@ -641,7 +641,7 @@ void DGXMLScanner::scanEndTag(bool& gotData) { emitError(XMLErrs::MoreEndThanStartTags); fReaderMgr.skipPastChar(chCloseAngle); - ThrowXML(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd, fMemoryManager); } // After the </ is the element QName, so get a name from the input @@ -922,7 +922,7 @@ void DGXMLScanner::scanDocTypeDecl() // We can't have any internal subset if we are reusing the validator if (fUseCachedGrammar || fToCacheGrammar) - ThrowXML(RuntimeException, XMLExcepts::Val_CantHaveIntSS); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager); // And try to scan the internal subset. If we fail, try to recover // by skipping forward tot he close angle and returning. @@ -1025,7 +1025,7 @@ void DGXMLScanner::scanDocTypeDecl() // If it failed then throw an exception if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId(), fMemoryManager); if (fToCacheGrammar) { @@ -1484,7 +1484,7 @@ bool DGXMLScanner::scanStartTag(bool& gotData) // It was some special case character so do all of the checks and // deal with it. if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chForwardSlash) { @@ -1816,9 +1816,9 @@ Grammar* DGXMLScanner::loadDTDGrammar(const InputSource& src, ); if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // In order to make the processing work consistently, we have to @@ -2203,9 +2203,9 @@ void DGXMLScanner::scanReset(const InputSource& src) if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // Push this read onto the reader manager @@ -2453,15 +2453,16 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId) XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -2536,7 +2537,7 @@ bool DGXMLScanner::scanAttValue( const XMLAttDef* const attDef nextCh = fReaderMgr.getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Check for our ending quote in the same entity if (nextCh == quoteCh) @@ -2603,6 +2604,7 @@ bool DGXMLScanner::scanAttValue( const XMLAttDef* const attDef , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf); } @@ -2743,7 +2745,7 @@ void DGXMLScanner::scanCDSection() if (!nextCh) { emitError(XMLErrs::UnterminatedCDATASection); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } if (fValidate && fStandalone && (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))) @@ -2838,6 +2840,7 @@ void DGXMLScanner::scanCDSection() , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); emittedError = true; @@ -2964,6 +2967,7 @@ void DGXMLScanner::scanCharData(XMLBuffer& toUse) , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -3171,7 +3175,7 @@ DGXMLScanner::scanEntityRef( const bool inAttVal // If the creation failed, and its not because the source was empty, // then emit an error and return. if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId(), fMemoryManager); // Push the reader. If its a recursive expansion, then emit an error // and return an failure. @@ -3185,7 +3189,7 @@ DGXMLScanner::scanEntityRef( const bool inAttVal // how many entity references we've had if(fSecurityManager != 0 && ++fEntityExpansionCount > fEntityExpansionLimit) { XMLCh expLimStr[16]; - XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10); + XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10, fMemoryManager); emitError ( XMLErrs::EntityExpansionLimitExceeded @@ -3243,7 +3247,7 @@ DGXMLScanner::scanEntityRef( const bool inAttVal // how many entity references we've had if(fSecurityManager != 0 && ++fEntityExpansionCount > fEntityExpansionLimit) { XMLCh expLimStr[16]; - XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10); + XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10, fMemoryManager); emitError ( XMLErrs::EntityExpansionLimitExceeded diff --git a/src/xercesc/internal/ElemStack.cpp b/src/xercesc/internal/ElemStack.cpp index 22884d39af66aa486619a9fc8079c39bae06d244..9e4c82fccf705ada3608ab34299341f1b1656871 100644 --- a/src/xercesc/internal/ElemStack.cpp +++ b/src/xercesc/internal/ElemStack.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/10/23 14:11:07 knoaman * Fix memory leak. * @@ -282,7 +285,7 @@ const ElemStack::StackElem* ElemStack::popTop() { // Watch for an underflow error if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow, fMemoryManager); fStackTop--; return fStack[fStackTop]; @@ -293,7 +296,7 @@ void ElemStack::setElement(XMLElementDecl* const toSet, const unsigned int readerNum) { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); fStack[fStackTop - 1]->fThisElement = toSet; fStack[fStackTop - 1]->fReaderNum = readerNum; @@ -306,14 +309,14 @@ ElemStack::setElement(XMLElementDecl* const toSet, const unsigned int readerNum) unsigned int ElemStack::addChild(QName* const child, const bool toParent) { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); // // If they want to add to the parent, then we have to have at least two // elements on the stack. // if (toParent && (fStackTop < 2)) - ThrowXML(NoSuchElementException, XMLExcepts::ElemStack_NoParentPushed); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::ElemStack_NoParentPushed, fMemoryManager); // Get a convenience pointer to the stack top row StackElem* curRow = toParent @@ -363,7 +366,7 @@ unsigned int ElemStack::addChild(QName* const child, const bool toParent) const ElemStack::StackElem* ElemStack::topElement() const { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); return fStack[fStackTop - 1]; } @@ -376,7 +379,7 @@ void ElemStack::addPrefix( const XMLCh* const prefixToAdd , const unsigned int uriId) { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); // Get a convenience pointer to the stack top row StackElem* curRow = fStack[fStackTop - 1]; @@ -729,7 +732,7 @@ const WFElemStack::StackElem* WFElemStack::popTop() { // Watch for an underflow error if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow, fMemoryManager); fStackTop--; return fStack[fStackTop]; @@ -742,7 +745,7 @@ WFElemStack::setElement(const XMLCh* const toSet, const unsigned int readerNum) { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); if (toSetLen > fStack[fStackTop - 1]->fElemMaxLength) { @@ -765,7 +768,7 @@ WFElemStack::setElement(const XMLCh* const toSet, const WFElemStack::StackElem* WFElemStack::topElement() const { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); return fStack[fStackTop - 1]; } @@ -778,7 +781,7 @@ void WFElemStack::addPrefix( const XMLCh* const prefixToAdd , const unsigned int uriId) { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); // Get a convenience pointer to the stack top row StackElem* curRow = fStack[fStackTop - 1]; diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp index 480b37591d557f411ac0e4f8cefbeeb243d8c2ba..a87242e60f5d78467587038d6dd0e1c572b4610c 100644 --- a/src/xercesc/internal/IGXMLScanner.cpp +++ b/src/xercesc/internal/IGXMLScanner.cpp @@ -267,6 +267,9 @@ void IGXMLScanner::scanDocument(const InputSource& src) if (fDocHandler) fDocHandler->endDocument(); + //cargill debug: + fGrammarResolver->getXSModel(); + // Reset the reader manager to close all files, sockets, etc... fReaderMgr.reset(); } @@ -345,7 +348,7 @@ bool IGXMLScanner::scanNext(XMLPScanToken& token) { // Make sure this token is still legal if (!isLegalToken(token)) - ThrowXML(RuntimeException, XMLExcepts::Scan_BadPScanToken); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_BadPScanToken, fMemoryManager); // Find the next token and remember the reader id unsigned int orgReader; @@ -804,7 +807,7 @@ IGXMLScanner::rawAttrScan(const XMLCh* const elemName // It was some special case character so do all of the checks and // deal with it. if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chForwardSlash) { @@ -978,7 +981,7 @@ void IGXMLScanner::scanEndTag(bool& gotData) { emitError(XMLErrs::MoreEndThanStartTags); fReaderMgr.skipPastChar(chCloseAngle); - ThrowXML(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd, fMemoryManager); } // After the </ is the element QName, so get a name from the input @@ -1280,14 +1283,14 @@ void IGXMLScanner::scanEndTag(bool& gotData) fGrammarType = fGrammar->getGrammarType(); if (fGrammarType == Grammar::SchemaGrammarType && !fValidator->handlesSchema()) { if (fValidatorFromUser) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); else { fValidator = fSchemaValidator; } } else if (fGrammarType == Grammar::DTDGrammarType && !fValidator->handlesDTD()) { if (fValidatorFromUser) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); else { fValidator = fDTDValidator; } @@ -1460,7 +1463,7 @@ void IGXMLScanner::scanDocTypeDecl() // We can't have any internal subset if we are reusing the validator if (fUseCachedGrammar || fToCacheGrammar) - ThrowXML(RuntimeException, XMLExcepts::Val_CantHaveIntSS); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager); // And try to scan the internal subset. If we fail, try to recover // by skipping forward tot he close angle and returning. @@ -1561,7 +1564,7 @@ void IGXMLScanner::scanDocTypeDecl() // If it failed then throw an exception if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId(), fMemoryManager); if (fToCacheGrammar) { @@ -1979,7 +1982,7 @@ bool IGXMLScanner::scanStartTag(bool& gotData) // It was some special case character so do all of the checks and // deal with it. if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chForwardSlash) { @@ -3055,14 +3058,14 @@ bool IGXMLScanner::scanStartTagNS(bool& gotData) fGrammarType = fGrammar->getGrammarType(); if (fGrammarType == Grammar::SchemaGrammarType && !fValidator->handlesSchema()) { if (fValidatorFromUser) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); else { fValidator = fSchemaValidator; } } else if (fGrammarType == Grammar::DTDGrammarType && !fValidator->handlesDTD()) { if (fValidatorFromUser) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); else { fValidator = fDTDValidator; } @@ -3299,7 +3302,7 @@ Grammar* IGXMLScanner::loadDTDGrammar(const InputSource& src, if (!fValidator->handlesDTD()) { if (fValidatorFromUser && fValidate) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); else { fValidator = fDTDValidator; } @@ -3356,9 +3359,9 @@ Grammar* IGXMLScanner::loadDTDGrammar(const InputSource& src, ); if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // In order to make the processing work consistently, we have to diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp index 7f1a2372a9197bf37cb453a7339650633d8cc22a..1169bfa9ccde06e363d8a55d54169cc955140ccf 100644 --- a/src/xercesc/internal/IGXMLScanner2.cpp +++ b/src/xercesc/internal/IGXMLScanner2.cpp @@ -1291,9 +1291,9 @@ void IGXMLScanner::scanReset(const InputSource& src) if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // Push this read onto the reader manager @@ -1722,18 +1722,19 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con try { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); + XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer(), fMemoryManager); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -1798,7 +1799,7 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con { if (fValidatorFromUser) { // the fValidator is from user - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); } else { fValidator = fSchemaValidator; @@ -1851,7 +1852,7 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con { if (fValidatorFromUser) { // the fValidator is from user - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); } else { fValidator = fSchemaValidator; @@ -1906,15 +1907,16 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId) XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -1954,7 +1956,7 @@ Grammar* IGXMLScanner::loadXMLSchemaGrammar(const InputSource& src, if (!fValidator->handlesSchema()) { if (fValidatorFromUser && fValidate) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); else { fValidator = fSchemaValidator; } @@ -2069,7 +2071,7 @@ bool IGXMLScanner::basicAttrValueScan(const XMLCh* const attrName, XMLBuffer& to nextCh = fReaderMgr.getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Check for our ending quote. It has to be in the same entity // as where we started. Quotes in nested entities are ignored. @@ -2139,6 +2141,7 @@ bool IGXMLScanner::basicAttrValueScan(const XMLCh* const attrName, XMLBuffer& to , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf); } @@ -2221,7 +2224,7 @@ bool IGXMLScanner::scanAttValue( const XMLAttDef* const attDef nextCh = fReaderMgr.getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Check for our ending quote in the same entity if (nextCh == quoteCh) @@ -2288,6 +2291,7 @@ bool IGXMLScanner::scanAttValue( const XMLAttDef* const attDef , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf); } @@ -2451,7 +2455,7 @@ void IGXMLScanner::scanCDSection() if (!nextCh) { emitError(XMLErrs::UnterminatedCDATASection); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } if (fValidate && fStandalone && (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))) @@ -2594,6 +2598,7 @@ void IGXMLScanner::scanCDSection() , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); emittedError = true; @@ -2720,6 +2725,7 @@ void IGXMLScanner::scanCharData(XMLBuffer& toUse) , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -2950,7 +2956,7 @@ IGXMLScanner::scanEntityRef( const bool inAttVal // If the creation failed, and its not because the source was empty, // then emit an error and return. if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId(), fMemoryManager); // Push the reader. If its a recursive expansion, then emit an error // and return an failure. @@ -2964,7 +2970,7 @@ IGXMLScanner::scanEntityRef( const bool inAttVal // how many entity references we've had if(fSecurityManager != 0 && ++fEntityExpansionCount > fEntityExpansionLimit) { XMLCh expLimStr[16]; - XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10); + XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10, fMemoryManager); emitError ( XMLErrs::EntityExpansionLimitExceeded @@ -3022,7 +3028,7 @@ IGXMLScanner::scanEntityRef( const bool inAttVal // how many entity references we've had if(fSecurityManager != 0 && ++fEntityExpansionCount > fEntityExpansionLimit) { XMLCh expLimStr[16]; - XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10); + XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10, fMemoryManager); emitError ( XMLErrs::EntityExpansionLimitExceeded @@ -3065,14 +3071,14 @@ bool IGXMLScanner::switchGrammar(const XMLCh* const newGrammarNameSpace) fGrammarType = fGrammar->getGrammarType(); if (fGrammarType == Grammar::SchemaGrammarType && !fValidator->handlesSchema()) { if (fValidatorFromUser) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); else { fValidator = fSchemaValidator; } } else if (fGrammarType == Grammar::DTDGrammarType && !fValidator->handlesDTD()) { if (fValidatorFromUser) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); else { fValidator = fDTDValidator; } diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp index 1b4764bdd2eb5177c98927810a79d018e9feba3d..afa3734dc0e69482b42b04b5fd635844b9ae8834 100644 --- a/src/xercesc/internal/ReaderMgr.cpp +++ b/src/xercesc/internal/ReaderMgr.cpp @@ -403,7 +403,7 @@ void ReaderMgr::cleanStackBackTo(const unsigned int readerNum) break; if (fReaderStack->empty()) - ThrowXML(RuntimeException, XMLExcepts::RdrMgr_ReaderIdNotFound); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::RdrMgr_ReaderIdNotFound, fMemoryManager); delete fCurReader; fCurReader = fReaderStack->pop(); @@ -546,18 +546,19 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const sysId try { - XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); + XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer(), fMemoryManager); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -654,19 +655,20 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const baseURI try { - XMLURL urlTmp((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, expSysId.getRawBuffer()); + XMLURL urlTmp((!baseURI || !*baseURI) ? lastInfo.systemId : baseURI, expSysId.getRawBuffer(), fMemoryManager); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp index 057aaae34d650dbb23b1cc2a691d93c9c2b00249..aac91454b014ca3fc27c5ab69edace72ce1395dd 100644 --- a/src/xercesc/internal/SGXMLScanner.cpp +++ b/src/xercesc/internal/SGXMLScanner.cpp @@ -128,7 +128,7 @@ SGXMLScanner::SGXMLScanner( XMLValidator* const valToAdopt if (valToAdopt) { if (!valToAdopt->handlesSchema()) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); } else { @@ -181,7 +181,7 @@ SGXMLScanner::SGXMLScanner( XMLDocumentHandler* const docHandler if (valToAdopt) { if (!valToAdopt->handlesSchema()) - ThrowXML(RuntimeException, XMLExcepts::Gen_NoSchemaValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoSchemaValidator, fMemoryManager); } else { @@ -351,7 +351,7 @@ bool SGXMLScanner::scanNext(XMLPScanToken& token) { // Make sure this token is still legal if (!isLegalToken(token)) - ThrowXML(RuntimeException, XMLExcepts::Scan_BadPScanToken); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_BadPScanToken, fMemoryManager); // Find the next token and remember the reader id unsigned int orgReader; @@ -733,7 +733,7 @@ SGXMLScanner::rawAttrScan(const XMLCh* const elemName // It was some special case character so do all of the checks and // deal with it. if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chForwardSlash) { @@ -904,7 +904,7 @@ void SGXMLScanner::scanEndTag(bool& gotData) { emitError(XMLErrs::MoreEndThanStartTags); fReaderMgr.skipPastChar(chCloseAngle); - ThrowXML(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd, fMemoryManager); } // After the </ is the element QName, so get a name from the input @@ -3331,9 +3331,9 @@ void SGXMLScanner::scanReset(const InputSource& src) if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // Push this read onto the reader manager @@ -3675,7 +3675,7 @@ void SGXMLScanner::scanRawAttrListforNameSpaces(const RefVectorOf<KVStringPair>* void SGXMLScanner::parseSchemaLocation(const XMLCh* const schemaLocationStr) { - BaseRefVectorOf<XMLCh>* schemaLocation = XMLString::tokenizeString(schemaLocationStr); + BaseRefVectorOf<XMLCh>* schemaLocation = XMLString::tokenizeString(schemaLocationStr, fMemoryManager); unsigned int size = schemaLocation->size(); if (size % 2 != 0 ) { emitError(XMLErrs::BadSchemaLocation); @@ -3739,15 +3739,16 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -3898,15 +3899,16 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId) XMLURL urlTmp(lastInfo.systemId, expSysId.getRawBuffer()); if (urlTmp.isRelative()) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_NoProtocolPresent + , fMemoryManager ); } else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -4054,7 +4056,7 @@ bool SGXMLScanner::basicAttrValueScan(const XMLCh* const attrName, XMLBuffer& to nextCh = fReaderMgr.getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Check for our ending quote. It has to be in the same entity // as where we started. Quotes in nested entities are ignored. @@ -4124,6 +4126,7 @@ bool SGXMLScanner::basicAttrValueScan(const XMLCh* const attrName, XMLBuffer& to , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf); } @@ -4213,7 +4216,7 @@ void SGXMLScanner::scanCDSection() if (!nextCh) { emitError(XMLErrs::UnterminatedCDATASection); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } if (fValidate && fStandalone && (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))) @@ -4341,6 +4344,7 @@ void SGXMLScanner::scanCDSection() , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); emittedError = true; @@ -4467,6 +4471,7 @@ void SGXMLScanner::scanCharData(XMLBuffer& toUse) , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -4644,7 +4649,7 @@ SGXMLScanner::scanEntityRef( const bool inAttVal // how many entity references we've had if(fSecurityManager != 0 && ++fEntityExpansionCount > fEntityExpansionLimit) { XMLCh expLimStr[16]; - XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10); + XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10, fMemoryManager); emitError ( XMLErrs::EntityExpansionLimitExceeded @@ -4674,7 +4679,7 @@ bool SGXMLScanner::switchGrammar(const XMLCh* const newGrammarNameSpace) fGrammar = tempGrammar; fGrammarType = fGrammar->getGrammarType(); if (fGrammarType == Grammar::DTDGrammarType) { - ThrowXML(RuntimeException, XMLExcepts::Gen_NoDTDValidator); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Gen_NoDTDValidator, fMemoryManager); } fValidator->setGrammar(fGrammar); diff --git a/src/xercesc/internal/ValidationContextImpl.cpp b/src/xercesc/internal/ValidationContextImpl.cpp index 34f3177f234940b3c8f05c3ee73bea29c9454a5d..5ead6cfeb9fd392d54a3cc8670efa2bb32554329 100644 --- a/src/xercesc/internal/ValidationContextImpl.cpp +++ b/src/xercesc/internal/ValidationContextImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2003/11/24 05:10:26 neilg * implement method for determining member type of union that validated some value * @@ -131,9 +134,10 @@ void ValidationContextImpl::addId(const XMLCh * const content) { if (idEntry->getDeclared()) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_ID_Not_Unique - , content); + , content + , fMemoryManager); } } else @@ -201,19 +205,21 @@ void ValidationContextImpl::checkEntity(const XMLCh * const content) const if (!decl || !decl->isUnparsed()) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_ENTITY_Invalid - , content); + , content + , fMemoryManager); } } else { - ThrowXML1 + ThrowXMLwithMemMgr1 ( InvalidDatatypeValueException , XMLExcepts::VALUE_ENTITY_Invalid , content + , fMemoryManager ); } diff --git a/src/xercesc/internal/VecAttrListImpl.cpp b/src/xercesc/internal/VecAttrListImpl.cpp index fcd3ddb509fb30359e3441112ed148431a07508a..681e9b06e5be6e9fb871350a9e5bafc1e963889e 100644 --- a/src/xercesc/internal/VecAttrListImpl.cpp +++ b/src/xercesc/internal/VecAttrListImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -154,7 +157,7 @@ const XMLCh* VecAttrListImpl::getType(const unsigned int index) const if (index >= fCount) { return 0; } - return XMLAttDef::getAttTypeString(fVector->elementAt(index)->getType()); + return XMLAttDef::getAttTypeString(fVector->elementAt(index)->getType(), fVector->getMemoryManager()); } const XMLCh* VecAttrListImpl::getValue(const unsigned int index) const @@ -176,7 +179,7 @@ const XMLCh* VecAttrListImpl::getType(const XMLCh* const name) const const XMLAttr* curElem = fVector->elementAt(index); if (XMLString::equals(curElem->getQName(), name)) - return XMLAttDef::getAttTypeString(curElem->getType()); + return XMLAttDef::getAttTypeString(curElem->getType(), fVector->getMemoryManager()); } return 0; } diff --git a/src/xercesc/internal/VecAttributesImpl.cpp b/src/xercesc/internal/VecAttributesImpl.cpp index eabbef022030e943640513ff8ffdfb3e4f2c8fbf..e2373b04439d100d28e16d49432908aced54a6c9 100644 --- a/src/xercesc/internal/VecAttributesImpl.cpp +++ b/src/xercesc/internal/VecAttributesImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/05/16 21:36:57 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * @@ -174,7 +177,7 @@ const XMLCh* VecAttributesImpl::getType(const unsigned int index) const if (index >= fCount) { return 0; } - return XMLAttDef::getAttTypeString(fVector->elementAt(index)->getType()); + return XMLAttDef::getAttTypeString(fVector->elementAt(index)->getType(), fVector->getMemoryManager()); } const XMLCh* VecAttributesImpl::getValue(const unsigned int index) const diff --git a/src/xercesc/internal/WFXMLScanner.cpp b/src/xercesc/internal/WFXMLScanner.cpp index f604988a3de7a043b0960106da19c17b41ad515a..f0b50fc5dc901ccd196204c3547c947d99b2ab85 100644 --- a/src/xercesc/internal/WFXMLScanner.cpp +++ b/src/xercesc/internal/WFXMLScanner.cpp @@ -278,7 +278,7 @@ bool WFXMLScanner::scanNext(XMLPScanToken& token) { // Make sure this token is still legal if (!isLegalToken(token)) - ThrowXML(RuntimeException, XMLExcepts::Scan_BadPScanToken); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_BadPScanToken, fMemoryManager); // Find the next token and remember the reader id unsigned int orgReader; @@ -561,9 +561,9 @@ void WFXMLScanner::scanReset(const InputSource& src) if (!newReader) { if (src.getIssueFatalErrorIfNotFound()) - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource, src.getSystemId(), fMemoryManager); else - ThrowXML1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Scan_CouldNotOpenSource_Warning, src.getSystemId(), fMemoryManager); } // Push this read onto the reader manager @@ -734,7 +734,7 @@ void WFXMLScanner::scanEndTag(bool& gotData) { emitError(XMLErrs::MoreEndThanStartTags); fReaderMgr.skipPastChar(chCloseAngle); - ThrowXML(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_UnbalancedStartEnd, fMemoryManager); } // Pop the stack of the element we are supposed to be ending. Remember @@ -943,7 +943,7 @@ bool WFXMLScanner::scanStartTag(bool& gotData) // See if this attribute is declared more than one for this element. const XMLCh* attNameRawBuf = fAttNameBuf.getRawBuffer(); - unsigned int attNameHash = XMLString::hash(attNameRawBuf, 109); + unsigned int attNameHash = XMLString::hash(attNameRawBuf, 109, fMemoryManager); if (attCount) { @@ -1049,7 +1049,7 @@ bool WFXMLScanner::scanStartTag(bool& gotData) // It was some special case character so do all of the checks and // deal with it. if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chForwardSlash) { @@ -1270,7 +1270,7 @@ bool WFXMLScanner::scanStartTagNS(bool& gotData) // See if this attribute is declared more than one for this element. const XMLCh* attNameRawBuf = fAttNameBuf.getRawBuffer(); - unsigned int attNameHash = XMLString::hash(attNameRawBuf, 109); + unsigned int attNameHash = XMLString::hash(attNameRawBuf, 109, fMemoryManager); if (attCount) { for (unsigned int k=0; k < attCount; k++) { @@ -1460,7 +1460,7 @@ bool WFXMLScanner::scanStartTagNS(bool& gotData) // It was some special case character so do all of the checks and // deal with it. if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chForwardSlash) { @@ -1656,7 +1656,7 @@ bool WFXMLScanner::scanAttValue(const XMLCh* const attrName nextCh = fReaderMgr.getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Check for our ending quote in the same entity if (nextCh == quoteCh) @@ -1725,6 +1725,7 @@ bool WFXMLScanner::scanAttValue(const XMLCh* const attrName , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacterInAttrValue, attrName, tmpBuf); } @@ -1799,7 +1800,7 @@ void WFXMLScanner::scanCDSection() if (!nextCh) { emitError(XMLErrs::UnterminatedCDATASection); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } // If this is a close square bracket it could be our closing @@ -1869,6 +1870,7 @@ void WFXMLScanner::scanCDSection() , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); emittedError = true; @@ -1997,6 +1999,7 @@ void WFXMLScanner::scanCharData(XMLBuffer& toUse) , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -2131,7 +2134,7 @@ WFXMLScanner::scanEntityRef(const bool inAttVal // how many entity references we've had if(fSecurityManager != 0 && ++fEntityExpansionCount > fEntityExpansionLimit) { XMLCh expLimStr[16]; - XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10); + XMLString::binToText(fEntityExpansionLimit, expLimStr, 15, 10, fMemoryManager); emitError ( XMLErrs::EntityExpansionLimitExceeded diff --git a/src/xercesc/internal/XMLGrammarPoolImpl.cpp b/src/xercesc/internal/XMLGrammarPoolImpl.cpp index 20aabeaba13acb591134211f431e6aab74b33aee..42dc377c4519a548c2cc6624a3f8c842182edc96 100644 --- a/src/xercesc/internal/XMLGrammarPoolImpl.cpp +++ b/src/xercesc/internal/XMLGrammarPoolImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.16 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.15 2003/11/25 18:18:39 knoaman * Check for out of memory exception. Thanks to David Cargill. * @@ -130,7 +133,7 @@ XERCES_CPP_NAMESPACE_BEGIN // private function used to update fXSModel void XMLGrammarPoolImpl::createXSModel() { - RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry); + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry, false, getMemoryManager()); if (fXSModel) { // Need to guarantee that we return a different address... @@ -192,7 +195,7 @@ bool XMLGrammarPoolImpl::cacheGrammar(Grammar* const gramToCache ) if (fGrammarRegistry->containsKey(grammarKey)) { - ThrowXML(RuntimeException, XMLExcepts::GC_ExistingGrammar); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::GC_ExistingGrammar, getMemoryManager()); } fGrammarRegistry->put((void*) grammarKey, gramToCache); @@ -226,7 +229,7 @@ Grammar* XMLGrammarPoolImpl::orphanGrammar(const XMLCh* const nameSpaceKey) RefHashTableOfEnumerator<Grammar> XMLGrammarPoolImpl::getGrammarEnumerator() const { - return RefHashTableOfEnumerator<Grammar>(fGrammarRegistry); + return RefHashTableOfEnumerator<Grammar>(fGrammarRegistry, false, fGrammarRegistry->getMemoryManager()); } @@ -342,10 +345,10 @@ XMLStringPool *XMLGrammarPoolImpl::getURIStringPool() ***/ void XMLGrammarPoolImpl::serializeGrammars(BinOutputStream* const binOut) { - RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry); + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry, false, getMemoryManager()); if (!(grammarEnum.hasMoreElements())) { - ThrowXML(XSerializationException, XMLExcepts::XSer_GrammarPool_Empty); + ThrowXMLwithMemMgr(XSerializationException, XMLExcepts::XSer_GrammarPool_Empty, getMemoryManager()); } XSerializeEngine serEng(binOut, getMemoryManager()); @@ -374,6 +377,7 @@ void XMLGrammarPoolImpl::serializeGrammars(BinOutputStream* const binOut) ***/ void XMLGrammarPoolImpl::deserializeGrammars(BinInputStream* const binIn) { + MemoryManager *memMgr = getMemoryManager(); unsigned int stringCount = fStringPool->getStringCount(); if (stringCount) { @@ -388,17 +392,17 @@ void XMLGrammarPoolImpl::deserializeGrammars(BinInputStream* const binIn) } else { - ThrowXML(XSerializationException, XMLExcepts::XSer_StringPool_NotEmpty); + ThrowXMLwithMemMgr(XSerializationException, XMLExcepts::XSer_StringPool_NotEmpty, memMgr); } } - RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry); + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarRegistry, false, memMgr); if (grammarEnum.hasMoreElements()) { - ThrowXML(XSerializationException, XMLExcepts::XSer_GrammarPool_NotEmpty); + ThrowXMLwithMemMgr(XSerializationException, XMLExcepts::XSer_GrammarPool_NotEmpty, memMgr); } - MemoryManager *memMgr = getMemoryManager(); + try { XSerializeEngine serEng(binIn, memMgr); @@ -424,15 +428,16 @@ void XMLGrammarPoolImpl::deserializeGrammars(BinInputStream* const binIn) XMLCh MajVerChar[4]; XMLCh MinVerChar[4]; XMLCh RevisionChar[4]; - XMLString::binToText(MajVer, MajVerChar, 4, 10); - XMLString::binToText(MinVer, MinVerChar, 4, 10); - XMLString::binToText(Revision, RevisionChar, 4, 10); + XMLString::binToText(MajVer, MajVerChar, 4, 10, memMgr); + XMLString::binToText(MinVer, MinVerChar, 4, 10, memMgr); + XMLString::binToText(Revision, RevisionChar, 4, 10, memMgr); - ThrowXML3(XSerializationException + ThrowXMLwithMemMgr3(XSerializationException , XMLExcepts::XSer_BinaryData_Version_NotSupported , MajVerChar , MinVerChar - , RevisionChar); + , RevisionChar + , memMgr); } //lock status serEng>>fLocked; diff --git a/src/xercesc/internal/XMLReader.cpp b/src/xercesc/internal/XMLReader.cpp index a8b54769a83be07ebc342b23209dc99b43879b9c..cacead230a99abcad54552da44a27e8b3432168b 100644 --- a/src/xercesc/internal/XMLReader.cpp +++ b/src/xercesc/internal/XMLReader.cpp @@ -179,11 +179,11 @@ XMLReader::XMLReader(const XMLCh* const pubId if ((fEncoding < XMLRecognizer::Encodings_Min) || (fEncoding > XMLRecognizer::Encodings_Max)) { - ThrowXML(RuntimeException, XMLExcepts::Reader_BadAutoEncoding); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Reader_BadAutoEncoding, fMemoryManager); } #endif - fEncodingStr = XMLString::replicate(XMLRecognizer::nameForEncoding(fEncoding), fMemoryManager); + fEncodingStr = XMLString::replicate(XMLRecognizer::nameForEncoding(fEncoding, fMemoryManager), fMemoryManager); // Check whether the fSwapped flag should be set or not checkForSwapped(); @@ -299,11 +299,12 @@ XMLReader::XMLReader(const XMLCh* const pubId if (!fTranscoder) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , fEncodingStr + , fMemoryManager ); } @@ -373,7 +374,7 @@ XMLReader::XMLReader(const XMLCh* const pubId // Use the passed encoding code // fEncoding = encodingEnum; - fEncodingStr = XMLString::replicate(XMLRecognizer::nameForEncoding(fEncoding), fMemoryManager); + fEncodingStr = XMLString::replicate(XMLRecognizer::nameForEncoding(fEncoding, fMemoryManager), fMemoryManager); // Check whether the fSwapped flag should be set or not checkForSwapped(); @@ -393,11 +394,12 @@ XMLReader::XMLReader(const XMLCh* const pubId if (!fTranscoder) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , fEncodingStr + , fMemoryManager ); } @@ -434,7 +436,7 @@ XMLReader::~XMLReader() unsigned int XMLReader::getSrcOffset() const { if (!fSrcOfsSupported || !fCalculateSrcOfs) - ThrowXML(RuntimeException, XMLExcepts::Reader_SrcOfsNotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Reader_SrcOfsNotSupported, fMemoryManager); // // Take the current source offset and add in the sizes that we've @@ -475,7 +477,7 @@ bool XMLReader::refreshCharBuffer() if (!fTranscoder) { if (fEncoding == XMLRecognizer::EBCDIC) - ThrowXML(RuntimeException, XMLExcepts::Reader_EncodingStrRequired); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Reader_EncodingStrRequired, fMemoryManager); // Ask the transcoding service to make use a transcoder XMLTransService::Codes failReason; @@ -489,11 +491,12 @@ bool XMLReader::refreshCharBuffer() if (!fTranscoder) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Trans_CantCreateCvtrFor , fEncodingStr + , fMemoryManager ); } } @@ -1230,7 +1233,7 @@ bool XMLReader::setEncoding(const XMLCh* const newEncoding) ); if (!fTranscoder) - ThrowXML1(TranscodingException, XMLExcepts::Trans_CantCreateCvtrFor, fEncodingStr); + ThrowXMLwithMemMgr1(TranscodingException, XMLExcepts::Trans_CantCreateCvtrFor, fEncodingStr, fMemoryManager); } // Update the base encoding member with the new base encoding found @@ -1318,11 +1321,12 @@ void XMLReader::doInitDecode() { fCharsAvail = 0; fRawBufIndex = 0; - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Reader_CouldNotDecodeFirstLine , fSystemId + , fMemoryManager ); } @@ -1393,11 +1397,12 @@ void XMLReader::doInitDecode() { fCharsAvail = 0; fRawBufIndex = 0; - ThrowXML1 + ThrowXMLwithMemMgr1 ( TranscodingException , XMLExcepts::Reader_CouldNotDecodeFirstLine , fSystemId + , fMemoryManager ); } } @@ -1509,7 +1514,7 @@ void XMLReader::doInitDecode() default : // It should never be anything else here - ThrowXML(TranscodingException, XMLExcepts::Reader_BadAutoEncoding); + ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Reader_BadAutoEncoding, fMemoryManager); break; } diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp index 971766e5ddbe03be2a0a7c42648b551ff28389d8..af95576a90233197299d386ee7589ada203440cc 100644 --- a/src/xercesc/internal/XMLScanner.cpp +++ b/src/xercesc/internal/XMLScanner.cpp @@ -362,9 +362,9 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { - // since this is the top of the try/catch, cannot call ThrowXML + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); fInException = true; emitError ( @@ -378,7 +378,7 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) else { if (fStandardUriConformant && tmpURL.hasInvalidChar()) { - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); fInException = true; emitError ( @@ -396,10 +396,10 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { - // since this is the top of the try/catch, cannot call ThrowXML + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly // lazy bypass ... since all MalformedURLException are fatal, no need to check the type - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); fInException = true; emitError ( @@ -483,9 +483,9 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { - // since this is the top of the try/catch, cannot call ThrowXML + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); fInException = true; emitError ( @@ -499,7 +499,7 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId else { if (fStandardUriConformant && tmpURL.hasInvalidChar()) { - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); fInException = true; emitError ( @@ -517,7 +517,7 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { - // since this is the top of the try/catch, cannot call ThrowXML + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly // lazy bypass ... since all MalformedURLException are fatal, no need to check the type fInException = true; @@ -693,7 +693,7 @@ void XMLScanner::scanReset(XMLPScanToken& token) { // Make sure this token is still legal if (!isLegalToken(token)) - ThrowXML(RuntimeException, XMLExcepts::Scan_BadPScanToken); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Scan_BadPScanToken, fMemoryManager); // Reset the reader manager fReaderMgr.reset(); @@ -888,7 +888,7 @@ void XMLScanner::emitError( const XMLErrs::Codes toEmit const unsigned int maxChars = 2047; XMLCh errText[maxChars + 1]; - if (!gScannerMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4)) + if (!gScannerMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4, fMemoryManager)) { // <TBD> Should probably load a default message here } @@ -1104,7 +1104,7 @@ void XMLScanner::scanPI() if (!nextCh) { emitError(XMLErrs::UnterminatedPI); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } // Watch for potential terminating character @@ -1140,6 +1140,7 @@ void XMLScanner::scanPI() , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -1635,9 +1636,9 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { - // since this is the top of the try/catch, cannot call ThrowXML + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); fInException = true; emitError ( @@ -1651,7 +1652,7 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId else { if (fStandardUriConformant && tmpURL.hasInvalidChar()) { - MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL); + MalformedURLException e(__FILE__, __LINE__, XMLExcepts::URL_MalformedURL, fMemoryManager); fInException = true; emitError ( @@ -1669,7 +1670,7 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId if (!fStandardUriConformant) srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { - // since this is the top of the try/catch, cannot call ThrowXML + // since this is the top of the try/catch, cannot call ThrowXMLwithMemMgr // emit the error directly // lazy bypass ... since all MalformedURLException are fatal, no need to check the type fInException = true; @@ -1760,7 +1761,7 @@ void XMLScanner::checkIDRefs() { // Iterate the id ref list. If we find any entries here which are used // but not declared, then that's an error. - RefHashTableOfEnumerator<XMLRefInfo> refEnum(fValidationContext->getIdRefList()); + RefHashTableOfEnumerator<XMLRefInfo> refEnum(fValidationContext->getIdRefList(), false, fMemoryManager); while (refEnum.hasMoreElements()) { // Get a ref to the current element @@ -1933,7 +1934,7 @@ bool XMLScanner::scanCharRef(XMLCh& toFill, XMLCh& second) // Watch for EOF if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Break out on the terminating semicolon if (nextCh == chSemiColon) @@ -2048,7 +2049,7 @@ void XMLScanner::scanComment() if (!nextCh) { emitError(XMLErrs::UnterminatedComment); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } // Check for correct surrogate pairs @@ -2076,6 +2077,7 @@ void XMLScanner::scanComment() , tmpBuf , 8 , 16 + , fMemoryManager ); emitError(XMLErrs::InvalidCharacter, tmpBuf); } diff --git a/src/xercesc/internal/XObjectComparator.cpp b/src/xercesc/internal/XObjectComparator.cpp index 6800a46ff2ecd458c3e9feb7f8c7411ab5cdfbeb..9a0ea3a7096114d5088c21a364fa4f2e1fe292ff 100644 --- a/src/xercesc/internal/XObjectComparator.cpp +++ b/src/xercesc/internal/XObjectComparator.cpp @@ -57,6 +57,9 @@ /* * * $Log$ + * Revision 1.5 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/12/16 18:42:27 knoaman * fMayMatch is no longer a data member of IC_Field * @@ -97,7 +100,7 @@ void XObjectComparator::dumpContent(XMLGrammarPoolImpl* const gramPool) { RefHashTableOf<Grammar>* gramReg = gramPool->fGrammarRegistry; - RefHashTableOfEnumerator<Grammar> eNum(gramReg); + RefHashTableOfEnumerator<Grammar> eNum(gramReg, false, gramPool->getMemoryManager()); int itemNumber = 0; while (eNum.hasMoreElements()) { diff --git a/src/xercesc/internal/XProtoType.cpp b/src/xercesc/internal/XProtoType.cpp index adbe3c634e4532080a4576447a3a2a12a9563e01..83b131a4567a6d11856f3caab3fcb7e273f7a8fc 100644 --- a/src/xercesc/internal/XProtoType.cpp +++ b/src/xercesc/internal/XProtoType.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.2 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.1 2003/09/18 18:31:24 peiyongz * OSU: Object Serialization Utilities * @@ -92,12 +95,13 @@ void XProtoType::store(XSerializeEngine& serEng) const * ***/ void XProtoType::load(XSerializeEngine& serEng - , XMLByte* const inName) + , XMLByte* const inName + , MemoryManager* const manager) { if (!inName) { - ThrowXML(XSerializationException - , XMLExcepts::XSer_ProtoType_Null_ClassName); + ThrowXMLwithMemMgr(XSerializationException + , XMLExcepts::XSer_ProtoType_Null_ClassName, manager); } // read and check class name length @@ -109,13 +113,14 @@ void XProtoType::load(XSerializeEngine& serEng { XMLCh value1[16]; XMLCh value2[16]; - XMLString::binToText(inNameLen, value1, 16, 10); - XMLString::binToText(classNameLen, value2, 16, 10); + XMLString::binToText(inNameLen, value1, 16, 10, manager); + XMLString::binToText(classNameLen, value2, 16, 10, manager); - ThrowXML2(XSerializationException + ThrowXMLwithMemMgr2(XSerializationException , XMLExcepts::XSer_ProtoType_NameLen_Dif , value1 - , value2); + , value2 + , manager); } // read and check class name @@ -131,10 +136,11 @@ void XProtoType::load(XSerializeEngine& serEng XMLString::transcode((char*)inName, name1, 255); XMLString::transcode((char*)className, name2, 255); - ThrowXML2(XSerializationException + ThrowXMLwithMemMgr2(XSerializationException , XMLExcepts::XSer_ProtoType_Name_Dif , name1 - , name2); + , name2 + , manager); } return; diff --git a/src/xercesc/internal/XProtoType.hpp b/src/xercesc/internal/XProtoType.hpp index 371e7f19f84abcdad117cf98a27a613bffc9cefd..3d5ef60ed267b5d221bff02dafe764eb418afdc1 100644 --- a/src/xercesc/internal/XProtoType.hpp +++ b/src/xercesc/internal/XProtoType.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.3 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2003/09/23 18:12:19 peiyongz * Macro re-organized: provide create/nocreate macros for abstract and * nonabstract classes @@ -70,7 +73,7 @@ #if !defined(XPROTOTYPE_HPP) #define XPROTOTYPE_HPP -#include <xercesc/framework/MemoryManager.hpp> +#include <xercesc/util/PlatformUtils.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -84,7 +87,9 @@ public: void store(XSerializeEngine& serEng) const; static void load(XSerializeEngine& serEng - , XMLByte* const name); + , XMLByte* const name + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); // ------------------------------------------------------------------------------- // data diff --git a/src/xercesc/internal/XSObjectFactory.cpp b/src/xercesc/internal/XSObjectFactory.cpp index 6037f5deb500f8e6806b40593b55777b50ad4ea1..2b36fc09ca07f376a7323bdcd43ede048cac3f8a 100644 --- a/src/xercesc/internal/XSObjectFactory.cpp +++ b/src/xercesc/internal/XSObjectFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/12/10 05:14:00 neilg * fix seg fault caused when a complex type had simple content; we were not processing the complex type itself, only its base * @@ -387,12 +390,13 @@ XSObjectFactory::addOrFind(DatatypeValidator* const validator, { typeVariety = XSSimpleTypeDefinition::VARIETY_LIST; - while (baseDV->getType() == DatatypeValidator::List) + while (baseDV && (baseDV->getType() == DatatypeValidator::List)) { addOrFind(baseDV, xsModel); baseDV = baseDV->getBaseValidator(); } - primitiveOrItemType = addOrFind(baseDV, xsModel); + if (baseDV) + primitiveOrItemType = addOrFind(baseDV, xsModel); } else { @@ -845,7 +849,7 @@ void XSObjectFactory::processFacets(DatatypeValidator* const dv, xsFacetList = new (fMemoryManager) RefVectorOf<XSFacet>(10, true, fMemoryManager); // NOTE: Don't need to add facet to "ObjectMap -> getObjectFromMap/putObjectInMap); - RefHashTableOfEnumerator<KVStringPair> e(facets); + RefHashTableOfEnumerator<KVStringPair> e(facets, false, fMemoryManager); while (e.hasMoreElements()) { KVStringPair& pair = e.nextElement(); diff --git a/src/xercesc/internal/XSerializeEngine.cpp b/src/xercesc/internal/XSerializeEngine.cpp index 52c9cb2b85c69dab2d7b4561926fffcd8d395bb8..5a4b8dc999dda3901f94708531bca7029fbaf2cf 100644 --- a/src/xercesc/internal/XSerializeEngine.cpp +++ b/src/xercesc/internal/XSerializeEngine.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/25 20:37:40 jberry * Cleanup build errors/warnings from CodeWarrior * @@ -116,21 +119,23 @@ static XMLCh value2[16]; #define TEST_THROW_ARG1(condition, data, err_msg) \ if (condition) \ { \ - XMLString::binToText(data, value1, 16, 10); \ - ThrowXML1(XSerializationException \ + XMLString::binToText(data, value1, 16, 10, fMemoryManager); \ + ThrowXMLwithMemMgr1(XSerializationException \ , err_msg \ - , value1); \ + , value1 \ + , fMemoryManager); \ } #define TEST_THROW_ARG2(condition, data1, data2, err_msg) \ if (condition) \ { \ - XMLString::binToText(data1, value1, 16, 10); \ - XMLString::binToText(data2, value2, 16, 10); \ - ThrowXML2(XSerializationException \ + XMLString::binToText(data1, value1, 16, 10, fMemoryManager); \ + XMLString::binToText(data2, value2, 16, 10, fMemoryManager); \ + ThrowXMLwithMemMgr2(XSerializationException \ , err_msg \ , value1 \ - , value2); \ + , value2 \ + , fMemoryManager); \ } // --------------------------------------------------------------------------- @@ -435,7 +440,7 @@ bool XSerializeEngine::read(XProtoType* const protoType { // what follows fgNewClassTag is the prototype object info // for the object anticipated, go and verify the info - XProtoType::load(*this, protoType->fClassName); + XProtoType::load(*this, protoType->fClassName, fMemoryManager); addLoadPool((void*)protoType); } diff --git a/src/xercesc/internal/XSerializeEngine.hpp b/src/xercesc/internal/XSerializeEngine.hpp index faaa94913074e784635431ff276b0ce5a09c8d17..16e64056e8867455772e30d3c0c5c9b6c8f67f3c 100644 --- a/src/xercesc/internal/XSerializeEngine.hpp +++ b/src/xercesc/internal/XSerializeEngine.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/25 20:37:40 jberry * Cleanup build errors/warnings from CodeWarrior * @@ -664,7 +667,7 @@ inline void XSerializeEngine::Assert(bool toEval { if (!toEval) { - ThrowXML(XSerializationException, toThrow); + ThrowXMLwithMemMgr(XSerializationException, toThrow, fMemoryManager); } } diff --git a/src/xercesc/internal/XTemplateComparator.cpp b/src/xercesc/internal/XTemplateComparator.cpp index 6cfe598a98358eb497f561c58dfda8b3b50291f8..4a1dd0354d39ad56ab380536f6f7ea89705fa501 100644 --- a/src/xercesc/internal/XTemplateComparator.cpp +++ b/src/xercesc/internal/XTemplateComparator.cpp @@ -57,6 +57,9 @@ /* /* * $Log$ + * Revision 1.2 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.1 2003/10/29 16:14:15 peiyongz * XObjectComparator/XTemplateComparator * @@ -401,7 +404,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<KVStringPair>* const lValu { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<KVStringPair> lEnum(lValue); + RefHashTableOfEnumerator<KVStringPair> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -409,7 +412,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<KVStringPair>* const lValu lItemNumber++; } - RefHashTableOfEnumerator<KVStringPair> rEnum(lValue); + RefHashTableOfEnumerator<KVStringPair> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -442,7 +445,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLAttDef>* const lValue { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<XMLAttDef> lEnum(lValue); + RefHashTableOfEnumerator<XMLAttDef> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -450,7 +453,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLAttDef>* const lValue lItemNumber++; } - RefHashTableOfEnumerator<XMLAttDef> rEnum(lValue); + RefHashTableOfEnumerator<XMLAttDef> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -485,7 +488,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<DTDAttDef>* const lValue { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<DTDAttDef> lEnum(lValue); + RefHashTableOfEnumerator<DTDAttDef> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -493,7 +496,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<DTDAttDef>* const lValue lItemNumber++; } - RefHashTableOfEnumerator<DTDAttDef> rEnum(lValue); + RefHashTableOfEnumerator<DTDAttDef> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -527,7 +530,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<ComplexTypeInfo>* const lV { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<ComplexTypeInfo> lEnum(lValue); + RefHashTableOfEnumerator<ComplexTypeInfo> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -535,7 +538,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<ComplexTypeInfo>* const lV lItemNumber++; } - RefHashTableOfEnumerator<ComplexTypeInfo> rEnum(lValue); + RefHashTableOfEnumerator<ComplexTypeInfo> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -568,7 +571,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesGroupInfo>* const lV { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<XercesGroupInfo> lEnum(lValue); + RefHashTableOfEnumerator<XercesGroupInfo> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -576,7 +579,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesGroupInfo>* const lV lItemNumber++; } - RefHashTableOfEnumerator<XercesGroupInfo> rEnum(lValue); + RefHashTableOfEnumerator<XercesGroupInfo> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -609,7 +612,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesAttGroupInfo>* const { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<XercesAttGroupInfo> lEnum(lValue); + RefHashTableOfEnumerator<XercesAttGroupInfo> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -617,7 +620,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XercesAttGroupInfo>* const lItemNumber++; } - RefHashTableOfEnumerator<XercesAttGroupInfo> rEnum(lValue); + RefHashTableOfEnumerator<XercesAttGroupInfo> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -650,7 +653,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLRefInfo>* const lValue { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<XMLRefInfo> lEnum(lValue); + RefHashTableOfEnumerator<XMLRefInfo> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -658,7 +661,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<XMLRefInfo>* const lValue lItemNumber++; } - RefHashTableOfEnumerator<XMLRefInfo> rEnum(lValue); + RefHashTableOfEnumerator<XMLRefInfo> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -691,7 +694,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<DatatypeValidator>* const { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<DatatypeValidator> lEnum(lValue); + RefHashTableOfEnumerator<DatatypeValidator> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -699,7 +702,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<DatatypeValidator>* const lItemNumber++; } - RefHashTableOfEnumerator<DatatypeValidator> rEnum(lValue); + RefHashTableOfEnumerator<DatatypeValidator> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -732,7 +735,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<Grammar>* const lValue { IS_EQUIVALENT(lValue, rValue); - RefHashTableOfEnumerator<Grammar> lEnum(lValue); + RefHashTableOfEnumerator<Grammar> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -740,7 +743,7 @@ bool XTemplateComparator::isEquivalent(RefHashTableOf<Grammar>* const lValue lItemNumber++; } - RefHashTableOfEnumerator<Grammar> rEnum(lValue); + RefHashTableOfEnumerator<Grammar> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -781,7 +784,7 @@ bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<SchemaAttDef>* const { IS_EQUIVALENT(lValue, rValue); - RefHash2KeysTableOfEnumerator<SchemaAttDef> lEnum(lValue); + RefHash2KeysTableOfEnumerator<SchemaAttDef> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -789,7 +792,7 @@ bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<SchemaAttDef>* const lItemNumber++; } - RefHash2KeysTableOfEnumerator<SchemaAttDef> rEnum(lValue); + RefHash2KeysTableOfEnumerator<SchemaAttDef> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -827,7 +830,7 @@ bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<ElemVector>* const lV IS_EQUIVALENT(lValue, rValue); - RefHash2KeysTableOfEnumerator<ElemVector> lEnum(lValue); + RefHash2KeysTableOfEnumerator<ElemVector> lEnum(lValue, false, lValue->getMemoryManager()); int lItemNumber = 0; while (lEnum.hasMoreElements()) { @@ -835,7 +838,7 @@ bool XTemplateComparator::isEquivalent(RefHash2KeysTableOf<ElemVector>* const lV lItemNumber++; } - RefHash2KeysTableOfEnumerator<ElemVector> rEnum(lValue); + RefHash2KeysTableOfEnumerator<ElemVector> rEnum(rValue, false, rValue->getMemoryManager()); int rItemNumber = 0; while (rEnum.hasMoreElements()) { @@ -880,8 +883,8 @@ bool XTemplateComparator::isEquivalent(RefHash3KeysIdPool<SchemaElementDecl>* co IS_EQUIVALENT(lValue, rValue) - RefHash3KeysIdPoolEnumerator<SchemaElementDecl> lEnum(lValue); - RefHash3KeysIdPoolEnumerator<SchemaElementDecl> rEnum(rValue); + RefHash3KeysIdPoolEnumerator<SchemaElementDecl> lEnum(lValue, false, lValue->getMemoryManager()); + RefHash3KeysIdPoolEnumerator<SchemaElementDecl> rEnum(rValue, false, rValue->getMemoryManager()); if (lEnum.size() != rEnum.size()) return false; @@ -914,8 +917,8 @@ bool XTemplateComparator::isEquivalent(NameIdPool<DTDElementDecl>* const lValue IS_EQUIVALENT(lValue, rValue) - NameIdPoolEnumerator<DTDElementDecl> lEnum(lValue); - NameIdPoolEnumerator<DTDElementDecl> rEnum(lValue); + NameIdPoolEnumerator<DTDElementDecl> lEnum(lValue, lValue->getMemoryManager()); + NameIdPoolEnumerator<DTDElementDecl> rEnum(rValue, rValue->getMemoryManager()); if (lEnum.size() != rEnum.size()) return false; @@ -940,8 +943,8 @@ bool XTemplateComparator::isEquivalent(NameIdPool<DTDEntityDecl>* const lValue IS_EQUIVALENT(lValue, rValue) - NameIdPoolEnumerator<DTDEntityDecl> lEnum(lValue); - NameIdPoolEnumerator<DTDEntityDecl> rEnum(lValue); + NameIdPoolEnumerator<DTDEntityDecl> lEnum(lValue, lValue->getMemoryManager()); + NameIdPoolEnumerator<DTDEntityDecl> rEnum(rValue, rValue->getMemoryManager()); if (lEnum.size() != rEnum.size()) return false; @@ -965,8 +968,8 @@ bool XTemplateComparator::isEquivalent(NameIdPool<XMLNotationDecl>* const lValue { IS_EQUIVALENT(lValue, rValue) - NameIdPoolEnumerator<XMLNotationDecl> lEnum(lValue); - NameIdPoolEnumerator<XMLNotationDecl> rEnum(lValue); + NameIdPoolEnumerator<XMLNotationDecl> lEnum(lValue, lValue->getMemoryManager()); + NameIdPoolEnumerator<XMLNotationDecl> rEnum(rValue, rValue->getMemoryManager()); if (lEnum.size() != rEnum.size()) return false; diff --git a/src/xercesc/internal/XTemplateSerializer.cpp b/src/xercesc/internal/XTemplateSerializer.cpp index 4a917d252d6ddfedd1126e4416a25802b1c27fa2..6d4b15d344f32d816c79fa844defd27a86216851 100644 --- a/src/xercesc/internal/XTemplateSerializer.cpp +++ b/src/xercesc/internal/XTemplateSerializer.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/12/17 00:18:34 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/11/11 22:48:13 knoaman * Serialization of XSAnnotation. * @@ -777,7 +780,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<KVStringPair>* const objToS if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<KVStringPair> e(objToStore); + RefHashTableOfEnumerator<KVStringPair> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -845,7 +848,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<XMLAttDef>* const objToStor if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<XMLAttDef> e(objToStore); + RefHashTableOfEnumerator<XMLAttDef> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -918,7 +921,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<DTDAttDef>* const objToStor if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<DTDAttDef> e(objToStore); + RefHashTableOfEnumerator<DTDAttDef> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -987,7 +990,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<ComplexTypeInfo>* const obj if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<ComplexTypeInfo> e(objToStore); + RefHashTableOfEnumerator<ComplexTypeInfo> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -1056,7 +1059,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<XercesGroupInfo>* const obj if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<XercesGroupInfo> e(objToStore); + RefHashTableOfEnumerator<XercesGroupInfo> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -1124,7 +1127,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<XercesAttGroupInfo>* const if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<XercesAttGroupInfo> e(objToStore); + RefHashTableOfEnumerator<XercesAttGroupInfo> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -1192,7 +1195,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<XMLRefInfo>* const objToSto if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<XMLRefInfo> e(objToStore); + RefHashTableOfEnumerator<XMLRefInfo> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -1260,7 +1263,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<DatatypeValidator>* const o if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<DatatypeValidator> e(objToStore); + RefHashTableOfEnumerator<DatatypeValidator> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -1328,7 +1331,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<Grammar>* const objToStore if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<Grammar> e(objToStore); + RefHashTableOfEnumerator<Grammar> e(objToStore, false, objToStore->getMemoryManager()); int itemNumber = 0; while (e.hasMoreElements()) @@ -1397,7 +1400,7 @@ void XTemplateSerializer::storeObject(RefHashTableOf<XSAnnotation>* const objToS if (serEng.needToStoreObject(objToStore)) { - RefHashTableOfEnumerator<XSAnnotation> e(objToStore); + RefHashTableOfEnumerator<XSAnnotation> e(objToStore, false, objToStore->getMemoryManager()); ValueVectorOf<XSerializeEngine::XSerializedObjectId_t> ids(16, serEng.getMemoryManager()); ValueVectorOf<void*> keys(16, serEng.getMemoryManager()); @@ -1482,7 +1485,7 @@ void XTemplateSerializer::storeObject(RefHash2KeysTableOf<SchemaAttDef>* const o { int itemNumber = 0; - RefHash2KeysTableOfEnumerator<SchemaAttDef> e(objToStore); + RefHash2KeysTableOfEnumerator<SchemaAttDef> e(objToStore, false, objToStore->getMemoryManager()); while (e.hasMoreElements()) { @@ -1566,7 +1569,7 @@ void XTemplateSerializer::storeObject(RefHash2KeysTableOf<ElemVector>* const obj { int itemNumber = 0; - RefHash2KeysTableOfEnumerator<ElemVector> e(objToStore); + RefHash2KeysTableOfEnumerator<ElemVector> e(objToStore, false, objToStore->getMemoryManager()); while (e.hasMoreElements()) { @@ -1656,7 +1659,7 @@ void XTemplateSerializer::storeObject(RefHash3KeysIdPool<SchemaElementDecl>* con if (serEng.needToStoreObject(objToStore)) { int itemNumber = 0; - RefHash3KeysIdPoolEnumerator<SchemaElementDecl> e(objToStore); + RefHash3KeysIdPoolEnumerator<SchemaElementDecl> e(objToStore, false, objToStore->getMemoryManager()); XMLCh* key1; int key2; @@ -1753,7 +1756,7 @@ void XTemplateSerializer::storeObject(NameIdPool<DTDElementDecl>* const objToSto if (serEng.needToStoreObject(objToStore)) { int itemNumber = 0; - NameIdPoolEnumerator<DTDElementDecl> e(objToStore); + NameIdPoolEnumerator<DTDElementDecl> e(objToStore, objToStore->getMemoryManager()); while (e.hasMoreElements()) { @@ -1819,7 +1822,7 @@ void XTemplateSerializer::storeObject(NameIdPool<DTDEntityDecl>* const objToStor if (serEng.needToStoreObject(objToStore)) { int itemNumber = 0; - NameIdPoolEnumerator<DTDEntityDecl> e(objToStore); + NameIdPoolEnumerator<DTDEntityDecl> e(objToStore, objToStore->getMemoryManager()); while (e.hasMoreElements()) { @@ -1885,7 +1888,7 @@ void XTemplateSerializer::storeObject(NameIdPool<XMLNotationDecl>* const objToSt if (serEng.needToStoreObject(objToStore)) { int itemNumber = 0; - NameIdPoolEnumerator<XMLNotationDecl> e(objToStore); + NameIdPoolEnumerator<XMLNotationDecl> e(objToStore, objToStore->getMemoryManager()); while (e.hasMoreElements()) { diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp index cd84f0107368315f8150c71740eb7a40a134a3a8..135a3afcb10cf1684c0f98eb4b194328d649b2ed 100644 --- a/src/xercesc/parsers/AbstractDOMParser.cpp +++ b/src/xercesc/parsers/AbstractDOMParser.cpp @@ -224,7 +224,7 @@ void AbstractDOMParser::resetPool() { // We cannot enter here while a regular parse is in progress. if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); if (fDocumentVector) fDocumentVector->removeAllElements(); @@ -406,7 +406,7 @@ void AbstractDOMParser::setSecurityManager(SecurityManager* const securityManage // since this could impact various components, don't permit it to change // during a parse if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); fScanner->setSecurityManager(securityManager); } @@ -452,7 +452,7 @@ void AbstractDOMParser::parse(const InputSource& source) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -475,7 +475,7 @@ void AbstractDOMParser::parse(const XMLCh* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -498,7 +498,7 @@ void AbstractDOMParser::parse(const char* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -530,7 +530,7 @@ bool AbstractDOMParser::parseFirst( const XMLCh* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -543,7 +543,7 @@ bool AbstractDOMParser::parseFirst( const char* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -556,7 +556,7 @@ bool AbstractDOMParser::parseFirst( const InputSource& source // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(source, toFill); } @@ -1356,7 +1356,7 @@ void AbstractDOMParser::endAttList else prefix = temp; - XMLString::subString(prefix ,qualifiedName, 0, index); + XMLString::subString(prefix ,qualifiedName, 0, index, fMemoryManager); if (XMLString::equals(prefix,XMLNS)) buf.append(XMLUni::fgXMLNSURIName); diff --git a/src/xercesc/parsers/DOMBuilderImpl.cpp b/src/xercesc/parsers/DOMBuilderImpl.cpp index b386893c8ef45b99f67a07c2af841e9e14323e23..09d84e6d0d22d17c512a88c7f17bb4d43422e22f 100644 --- a/src/xercesc/parsers/DOMBuilderImpl.cpp +++ b/src/xercesc/parsers/DOMBuilderImpl.cpp @@ -581,7 +581,7 @@ Grammar* DOMBuilderImpl::loadGrammar(const char* const systemId, { // Avoid multiple entrance if (getParseInProgress()) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -621,7 +621,7 @@ Grammar* DOMBuilderImpl::loadGrammar(const XMLCh* const systemId, { // Avoid multiple entrance if (getParseInProgress()) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -661,7 +661,7 @@ Grammar* DOMBuilderImpl::loadGrammar(const DOMInputSource& source, { // Avoid multiple entrance if (getParseInProgress()) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp index 5c2e7099fbc48c1fdba5eaca7542750b6867fd8f..1065c1c613929e2135b73368be7345eed65985a8 100644 --- a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp +++ b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.32 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.31 2003/11/21 22:38:50 neilg * Enable grammar pools and grammar resolvers to manufacture * XSModels. This also cleans up handling in the @@ -658,7 +661,7 @@ void SAX2XMLReaderImpl::parse (const InputSource& source) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -681,7 +684,7 @@ void SAX2XMLReaderImpl::parse (const XMLCh* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -704,7 +707,7 @@ void SAX2XMLReaderImpl::parse (const char* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -734,7 +737,7 @@ bool SAX2XMLReaderImpl::parseFirst( const XMLCh* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -747,7 +750,7 @@ bool SAX2XMLReaderImpl::parseFirst( const char* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -760,7 +763,7 @@ bool SAX2XMLReaderImpl::parseFirst( const InputSource& source // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(source, toFill); } @@ -1178,7 +1181,7 @@ void SAX2XMLReaderImpl::attDef( const DTDElementDecl& elemDecl if (defAttType == XMLAttDef::Fixed || defAttType == XMLAttDef::Implied || defAttType == XMLAttDef::Required) { - defAttTypeStr = attDef.getDefAttTypeString(defAttType); + defAttTypeStr = attDef.getDefAttTypeString(defAttType, fMemoryManager); } if (isEnumeration) { @@ -1207,7 +1210,7 @@ void SAX2XMLReaderImpl::attDef( const DTDElementDecl& elemDecl fDeclHandler->attributeDecl(elemDecl.getFullName(), attDef.getFullName(), (isEnumeration) ? enumBuf.getRawBuffer() - : attDef.getAttTypeString(attDef.getType()), + : attDef.getAttTypeString(attDef.getType(), fMemoryManager), defAttTypeStr, attDef.getValue()); } @@ -1719,7 +1722,7 @@ Grammar* SAX2XMLReaderImpl::loadGrammar(const char* const systemId, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -1747,7 +1750,7 @@ Grammar* SAX2XMLReaderImpl::loadGrammar(const XMLCh* const systemId, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -1775,7 +1778,7 @@ Grammar* SAX2XMLReaderImpl::loadGrammar(const InputSource& source, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try diff --git a/src/xercesc/parsers/SAXParser.cpp b/src/xercesc/parsers/SAXParser.cpp index 254a8281ead8960226431ded51ffc3ec79e27a64..4940e2083fa9c61d0ca34e2bf3a3251754471e59 100644 --- a/src/xercesc/parsers/SAXParser.cpp +++ b/src/xercesc/parsers/SAXParser.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.30 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.29 2003/11/21 22:38:50 neilg * Enable grammar pools and grammar resolvers to manufacture * XSModels. This also cleans up handling in the @@ -637,7 +640,7 @@ void SAXParser::setSecurityManager(SecurityManager* const securityManager) // since this could impact various components, don't permit it to change // during a parse if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); fScanner->setSecurityManager(securityManager); } @@ -698,7 +701,7 @@ void SAXParser::parse(const InputSource& source) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -721,7 +724,7 @@ void SAXParser::parse(const XMLCh* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -744,7 +747,7 @@ void SAXParser::parse(const char* const systemId) { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); try { @@ -861,7 +864,7 @@ bool SAXParser::parseFirst( const XMLCh* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -874,7 +877,7 @@ bool SAXParser::parseFirst( const char* const systemId // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(systemId, toFill); } @@ -887,7 +890,7 @@ bool SAXParser::parseFirst( const InputSource& source // is in progress. // if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); return fScanner->scanFirst(source, toFill); } @@ -1445,7 +1448,7 @@ Grammar* SAXParser::loadGrammar(const char* const systemId, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -1473,7 +1476,7 @@ Grammar* SAXParser::loadGrammar(const XMLCh* const systemId, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -1501,7 +1504,7 @@ Grammar* SAXParser::loadGrammar(const InputSource& source, { // Avoid multiple entrance if (fParseInProgress) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try diff --git a/src/xercesc/parsers/XercesDOMParser.cpp b/src/xercesc/parsers/XercesDOMParser.cpp index 19ab425f96f2c0ab67119844cb0d5f7e6e385d44..bc1a135538c7fdcbf714f5abee077918927beab1 100644 --- a/src/xercesc/parsers/XercesDOMParser.cpp +++ b/src/xercesc/parsers/XercesDOMParser.cpp @@ -291,7 +291,7 @@ Grammar* XercesDOMParser::loadGrammar(const char* const systemId, { // Avoid multiple entrance if (getParseInProgress()) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -325,7 +325,7 @@ Grammar* XercesDOMParser::loadGrammar(const XMLCh* const systemId, { // Avoid multiple entrance if (getParseInProgress()) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try @@ -359,7 +359,7 @@ Grammar* XercesDOMParser::loadGrammar(const InputSource& source, { // Avoid multiple entrance if (getParseInProgress()) - ThrowXML(IOException, XMLExcepts::Gen_ParseInProgress); + ThrowXMLwithMemMgr(IOException, XMLExcepts::Gen_ParseInProgress, fMemoryManager); Grammar* grammar = 0; try diff --git a/src/xercesc/sax/InputSource.hpp b/src/xercesc/sax/InputSource.hpp index 88bdf6c50d1a09d81627736a63a25cf8b8fe01ef..fafc029b610ff7100d82cf11fa274883488a9bf4 100644 --- a/src/xercesc/sax/InputSource.hpp +++ b/src/xercesc/sax/InputSource.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.10 2003/12/01 23:23:26 neilg * fix for bug 25118; thanks to Jeroen Witmond * @@ -394,7 +397,7 @@ private: // // fFatalErrorIfNotFound // ----------------------------------------------------------------------- - MemoryManager* fMemoryManager; + MemoryManager* const fMemoryManager; XMLCh* fEncoding; XMLCh* fPublicId; XMLCh* fSystemId; diff --git a/src/xercesc/util/Base64.cpp b/src/xercesc/util/Base64.cpp index 73209776bee61e8d57b1764136a02cf47946db96..145f4cd1fab5cd6eba3cdb5b2ef9b409be8af65d 100644 --- a/src/xercesc/util/Base64.cpp +++ b/src/xercesc/util/Base64.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.10 2003/05/20 22:10:02 peiyongz * To differentiate external/internal memory * @@ -211,7 +214,7 @@ const unsigned int Base64::quadsPerLine = 15; XMLByte* Base64::encode(const XMLByte* const inputData , const unsigned int inputLength - , unsigned int* outputLength + , unsigned int* outputLength , MemoryManager* const memMgr) { if (!isInitialized) @@ -318,16 +321,17 @@ XMLByte* Base64::encode(const XMLByte* const inputData // Since decode() has track of length of the decoded data, we // will get this length from decode(), instead of strLen(). // -int Base64::getDataLength(const XMLCh* const inputData) +int Base64::getDataLength(const XMLCh* const inputData + , MemoryManager* const manager) { unsigned int retLen = 0; - XMLCh* decodedData = decode(inputData, &retLen); + XMLCh* decodedData = decode(inputData, &retLen, manager); if ( !decodedData ) return -1; else { - returnExternalMemory(0, decodedData); + returnExternalMemory(manager, decodedData); return retLen; } } @@ -357,7 +361,7 @@ int Base64::getDataLength(const XMLCh* const inputData) */ XMLByte* Base64::decode(const XMLByte* const inputData - , unsigned int* decodedLength + , unsigned int* decodedLength , MemoryManager* const memMgr) { if (!isInitialized) @@ -365,13 +369,13 @@ XMLByte* Base64::decode(const XMLByte* const inputData if ((!inputData) || (!*inputData)) return 0; - + // // remove all XML whitespaces from the base64Data // int inputLength = XMLString::stringLen( (const char* const)inputData ); - XMLByte* rawInputData = (XMLByte*) getInternalMemory((inputLength+1) * sizeof(XMLByte)); - ArrayJanitor<XMLByte> jan(rawInputData, XMLPlatformUtils::fgMemoryManager); + XMLByte* rawInputData = (XMLByte*) getExternalMemory(memMgr, (inputLength+1) * sizeof(XMLByte)); + ArrayJanitor<XMLByte> jan(rawInputData, memMgr ? memMgr : XMLPlatformUtils::fgMemoryManager); int inputIndex = 0; int rawInputLength = 0; @@ -523,8 +527,8 @@ XMLCh* Base64::decode(const XMLCh* const inputData * Move input data to a XMLByte buffer */ unsigned int srcLen = XMLString::stringLen(inputData); - XMLByte *dataInByte = (XMLByte*) getInternalMemory((srcLen+1) * sizeof(XMLByte)); - ArrayJanitor<XMLByte> janFill(dataInByte, XMLPlatformUtils::fgMemoryManager); + XMLByte *dataInByte = (XMLByte*) getExternalMemory(memMgr, (srcLen+1) * sizeof(XMLByte)); + ArrayJanitor<XMLByte> janFill(dataInByte, memMgr ? memMgr : XMLPlatformUtils::fgMemoryManager); for (unsigned int i = 0; i < srcLen; i++) dataInByte[i] = (XMLByte)inputData[i]; @@ -556,7 +560,6 @@ XMLCh* Base64::decode(const XMLCh* const inputData returnExternalMemory(memMgr, DecodedBuf); return toRet; - } // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/Base64.hpp b/src/xercesc/util/Base64.hpp index f80b9716182b24988ed04627191fde8f17520b0f..28d28d8ec0dc701a64c31eb5cf7b30212815dd78 100644 --- a/src/xercesc/util/Base64.hpp +++ b/src/xercesc/util/Base64.hpp @@ -102,7 +102,7 @@ public : */ static XMLByte* encode(const XMLByte* const inputData , const unsigned int inputLength - , unsigned int* outputLength + , unsigned int* outputLength , MemoryManager* const memMgr = 0); /** @@ -123,7 +123,7 @@ public : * @see XMLString::release(XMLByte**) */ static XMLByte* decode(const XMLByte* const inputData - , unsigned int* outputLength + , unsigned int* outputLength , MemoryManager* const memMgr = 0); /** @@ -157,7 +157,8 @@ public : * @return Length of decoded data, * or -1 if input data can not be decoded. */ - static int getDataLength(const XMLCh* const inputData); + static int getDataLength(const XMLCh* const inputData + , MemoryManager* const memMgr = 0); //@} diff --git a/src/xercesc/util/BaseRefVectorOf.c b/src/xercesc/util/BaseRefVectorOf.c index b07b03ca9c73de22c1cd12f558b8bbedf45349b9..d438469a8aa7fd3f74387eaf8a11ba530de747b3 100644 --- a/src/xercesc/util/BaseRefVectorOf.c +++ b/src/xercesc/util/BaseRefVectorOf.c @@ -104,7 +104,7 @@ template <class TElem> void BaseRefVectorOf<TElem>::setElementAt(TElem* const toSet, const unsigned int setAt) { if (setAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); if (fAdoptedElems) delete fElemList[setAt]; @@ -121,7 +121,7 @@ insertElementAt(TElem* const toInsert, const unsigned int insertAt) } if (insertAt > fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); ensureExtraCapacity(1); @@ -138,7 +138,7 @@ template <class TElem> TElem* BaseRefVectorOf<TElem>:: orphanElementAt(const unsigned int orphanAt) { if (orphanAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); // Get the element we are going to orphan TElem* retVal = fElemList[orphanAt]; @@ -181,7 +181,7 @@ template <class TElem> void BaseRefVectorOf<TElem>:: removeElementAt(const unsigned int removeAt) { if (removeAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); if (fAdoptedElems) delete fElemList[removeAt]; @@ -278,7 +278,7 @@ template <class TElem> const TElem* BaseRefVectorOf<TElem>:: elementAt(const unsigned int getAt) const { if (getAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); return fElemList[getAt]; } @@ -286,7 +286,7 @@ template <class TElem> TElem* BaseRefVectorOf<TElem>::elementAt(const unsigned int getAt) { if (getAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); return fElemList[getAt]; } diff --git a/src/xercesc/util/CountedPointer.c b/src/xercesc/util/CountedPointer.c index 58be17071c15ffbe879b915574aeeaeece96252b..18cfa5a50b6559199ae0e606d67328b045599f71 100644 --- a/src/xercesc/util/CountedPointer.c +++ b/src/xercesc/util/CountedPointer.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.3 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2002/11/04 15:22:03 tng * C++ Namespace Support. * @@ -152,14 +155,14 @@ template <class T> T* CountedPointerTo<T>::operator->() template <class T> const T& CountedPointerTo<T>::operator*() const { if (!fPtr) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero); return *fPtr; } template <class T> T& CountedPointerTo<T>::operator*() { if (!fPtr) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero); return *fPtr; } diff --git a/src/xercesc/util/HashBase.hpp b/src/xercesc/util/HashBase.hpp index a2a0edc0bd4127e7f37292cf2705dbff5e07f7a3..8a6970f280d85fbe353607e7f8457af93e0ad5b0 100644 --- a/src/xercesc/util/HashBase.hpp +++ b/src/xercesc/util/HashBase.hpp @@ -58,6 +58,7 @@ #define HASHBASE_HPP #include <xercesc/util/XMemory.hpp> +#include <xercesc/util/PlatformUtils.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -79,7 +80,8 @@ public: * @param key the key to be hashed * @param mod the modulus the hasher should use */ - virtual unsigned int getHashVal(const void *const key, unsigned int mod) = 0; + virtual unsigned int getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0; /** * Compares two keys and determines if they are semantically equal diff --git a/src/xercesc/util/HashCMStateSet.hpp b/src/xercesc/util/HashCMStateSet.hpp index ea73ddcef059e86271ca3dc24310e7d52d27f9f3..1e36f1489ed5107f31f2fe4d4045d76429631bff 100644 --- a/src/xercesc/util/HashCMStateSet.hpp +++ b/src/xercesc/util/HashCMStateSet.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.3 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2002/11/04 15:22:03 tng * C++ Namespace Support. * @@ -92,7 +95,8 @@ class XMLUTIL_EXPORT HashCMStateSet : public HashBase public: HashCMStateSet(); virtual ~HashCMStateSet(); - virtual unsigned int getHashVal(const void *const key, unsigned int mod); + virtual unsigned int getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual bool equals(const void *const key1, const void *const key2); }; @@ -105,7 +109,8 @@ inline HashCMStateSet::~HashCMStateSet() { } -inline unsigned int HashCMStateSet::getHashVal(const void *const key, unsigned int mod) +inline unsigned int HashCMStateSet::getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager) { const CMStateSet* const pkey = (const CMStateSet* const) key; return ((pkey->hashCode()) % mod); diff --git a/src/xercesc/util/HashPtr.cpp b/src/xercesc/util/HashPtr.cpp index 7a6cc48cdee5963739218164fdd9fbe789a9fd8d..a27f84b9dc14e912334a05699813332dc2add331 100644 --- a/src/xercesc/util/HashPtr.cpp +++ b/src/xercesc/util/HashPtr.cpp @@ -66,7 +66,8 @@ HashPtr::~HashPtr() { } -unsigned int HashPtr::getHashVal(const void *const key, unsigned int mod) +unsigned int HashPtr::getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager) { return ((long)key % (unsigned long)mod); } diff --git a/src/xercesc/util/HashPtr.hpp b/src/xercesc/util/HashPtr.hpp index b7cd5ad6371f2d51cff33932d20ad81b05447b95..8f46c31f18439fa6b39c2288663bba96255f67ae 100644 --- a/src/xercesc/util/HashPtr.hpp +++ b/src/xercesc/util/HashPtr.hpp @@ -74,7 +74,8 @@ class XMLUTIL_EXPORT HashPtr : public HashBase public: HashPtr(); virtual ~HashPtr(); - virtual unsigned int getHashVal(const void *const key, unsigned int mod); + virtual unsigned int getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual bool equals(const void *const key1, const void *const key2); }; diff --git a/src/xercesc/util/HashXMLCh.cpp b/src/xercesc/util/HashXMLCh.cpp index 3b173f7ad20e39cd3116d48ce8664fa5628fcf8b..c36af499b0ae7c9ac7c4caa6262bfda9472bd290 100644 --- a/src/xercesc/util/HashXMLCh.cpp +++ b/src/xercesc/util/HashXMLCh.cpp @@ -67,9 +67,10 @@ HashXMLCh::~HashXMLCh() { } -unsigned int HashXMLCh::getHashVal(const void *const key, unsigned int mod) +unsigned int HashXMLCh::getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager) { - return XMLString::hash((XMLCh*)key, mod); + return XMLString::hash((XMLCh*)key, mod, manager); } bool HashXMLCh::equals(const void *const key1, const void *const key2) diff --git a/src/xercesc/util/HashXMLCh.hpp b/src/xercesc/util/HashXMLCh.hpp index 080e787794f5c4e5351aceecd9bfae15215469b7..0381660e5507a1cde85a10b25fb46ee18780d0fd 100644 --- a/src/xercesc/util/HashXMLCh.hpp +++ b/src/xercesc/util/HashXMLCh.hpp @@ -74,7 +74,8 @@ class XMLUTIL_EXPORT HashXMLCh : public HashBase public: HashXMLCh(); virtual ~HashXMLCh(); - virtual unsigned int getHashVal(const void *const key, unsigned int mod); + virtual unsigned int getHashVal(const void *const key, unsigned int mod + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual bool equals(const void *const key1, const void *const key2); }; diff --git a/src/xercesc/util/LogicalPath.c b/src/xercesc/util/LogicalPath.c index 252c2400f1978540a6619a75d19b0b8c480bf5af..d15d7c14d9830f908b3a706283ad1801e9491c8a 100644 --- a/src/xercesc/util/LogicalPath.c +++ b/src/xercesc/util/LogicalPath.c @@ -38,11 +38,12 @@ * ***/ XMLCh* XMLPlatformUtils::weavePaths(const XMLCh* const basePath - , const XMLCh* const relativePath) + , const XMLCh* const relativePath + , MemoryManager* const manager) { // Create a buffer as large as both parts and empty it - XMLCh* tmpBuf = (XMLCh*) fgMemoryManager->allocate + XMLCh* tmpBuf = (XMLCh*) manager->allocate ( (XMLString::stringLen(basePath) + XMLString::stringLen(relativePath) + 2) * sizeof(XMLCh) @@ -80,13 +81,13 @@ XMLCh* XMLPlatformUtils::weavePaths(const XMLCh* const basePath // 3. remove all occurences of segment/../ where segment is not ../ // - XMLString::subString(tmpBuf, basePath, 0, (basePtr - basePath + 1)); + XMLString::subString(tmpBuf, basePath, 0, (basePtr - basePath + 1), manager); tmpBuf[basePtr - basePath + 1] = 0; XMLString::catString(tmpBuf, relativePath); - removeDotSlash(tmpBuf); + removeDotSlash(tmpBuf, manager); - removeDotDotSlash(tmpBuf); + removeDotDotSlash(tmpBuf, manager); return tmpBuf; @@ -99,14 +100,15 @@ XMLCh* XMLPlatformUtils::weavePaths(const XMLCh* const basePath // we can't make use of patterMatch(). // // -void XMLPlatformUtils::removeDotSlash(XMLCh* const path) +void XMLPlatformUtils::removeDotSlash(XMLCh* const path + , MemoryManager* const manager) { if ((!path) || (!*path)) return; - XMLCh* srcPtr = XMLString::replicate(path, fgMemoryManager); + XMLCh* srcPtr = XMLString::replicate(path, manager); int srcLen = XMLString::stringLen(srcPtr); - ArrayJanitor<XMLCh> janName(srcPtr, fgMemoryManager); + ArrayJanitor<XMLCh> janName(srcPtr, manager); XMLCh* tarPtr = path; while (*srcPtr) @@ -151,20 +153,21 @@ void XMLPlatformUtils::removeDotSlash(XMLCh* const path) // // Cases with extra /../ is left to the underlying file system. // -void XMLPlatformUtils::removeDotDotSlash(XMLCh* const path) +void XMLPlatformUtils::removeDotDotSlash(XMLCh* const path + , MemoryManager* const manager) { int pathLen = XMLString::stringLen(path); - XMLCh* tmp1 = (XMLCh*) fgMemoryManager->allocate + XMLCh* tmp1 = (XMLCh*) manager->allocate ( (pathLen+1) * sizeof(XMLCh) );//new XMLCh [pathLen+1]; - ArrayJanitor<XMLCh> tmp1Name(tmp1, fgMemoryManager); + ArrayJanitor<XMLCh> tmp1Name(tmp1, manager); - XMLCh* tmp2 = (XMLCh*) fgMemoryManager->allocate + XMLCh* tmp2 = (XMLCh*) manager->allocate ( (pathLen+1) * sizeof(XMLCh) );//new XMLCh [pathLen+1]; - ArrayJanitor<XMLCh> tmp2Name(tmp2, fgMemoryManager); + ArrayJanitor<XMLCh> tmp2Name(tmp2, manager); // remove all "<segment>/../" where "<segment>" is a complete // path segment not equal to ".." @@ -178,7 +181,7 @@ void XMLPlatformUtils::removeDotDotSlash(XMLCh* const path) index += offset; // Find start of <segment> within substring ending at found point. - XMLString::subString(tmp1, path, 0, index-1); + XMLString::subString(tmp1, path, 0, index-1, manager); segIndex = index - 1; while ((segIndex >= 0) && (!isAnySlash(tmp1[segIndex]))) { @@ -192,8 +195,8 @@ void XMLPlatformUtils::removeDotDotSlash(XMLCh* const path) segIndex + 3 != index)) { - XMLString::subString(tmp1, path, 0, segIndex); - XMLString::subString(tmp2, path, index+3, XMLString::stringLen(path)); + XMLString::subString(tmp1, path, 0, segIndex, manager); + XMLString::subString(tmp2, path, index+3, XMLString::stringLen(path), manager); path[0] = 0; XMLString::catString(path, tmp1); diff --git a/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp b/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp index 9b1d972ba2efeaf22daae4523cf17a4c4016118d..232dab2d6b817fc87f35f74cd9ce61568c4967d3 100644 --- a/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp +++ b/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp @@ -243,8 +243,10 @@ bool Win32MsgLoader::loadMsg(const XMLMsgLoader::XMLMsgId msgToLoad , const char* const repText1 , const char* const repText2 , const char* const repText3 - , const char* const repText4) + , const char* const repText4 + , MemoryManager* const manager) { + MemoryManager* toUse = manager ? manager : XMLPlatformUtils::fgMemoryManager; // // Transcode the provided parameters and call the other version, // which will do the replacement work. @@ -256,24 +258,24 @@ bool Win32MsgLoader::loadMsg(const XMLMsgLoader::XMLMsgId msgToLoad bool bRet = false; if (repText1) - tmp1 = XMLString::transcode(repText1, XMLPlatformUtils::fgMemoryManager); + tmp1 = XMLString::transcode(repText1, toUse); if (repText2) - tmp2 = XMLString::transcode(repText2, XMLPlatformUtils::fgMemoryManager); + tmp2 = XMLString::transcode(repText2, toUse); if (repText3) - tmp3 = XMLString::transcode(repText3, XMLPlatformUtils::fgMemoryManager); + tmp3 = XMLString::transcode(repText3, toUse); if (repText4) - tmp4 = XMLString::transcode(repText4, XMLPlatformUtils::fgMemoryManager); + tmp4 = XMLString::transcode(repText4, toUse); bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4); if (tmp1) - XMLPlatformUtils::fgMemoryManager->deallocate(tmp1);//delete [] tmp1; + toUse->deallocate(tmp1);//delete [] tmp1; if (tmp2) - XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2; + toUse->deallocate(tmp2);//delete [] tmp2; if (tmp3) - XMLPlatformUtils::fgMemoryManager->deallocate(tmp3);//delete [] tmp3; + toUse->deallocate(tmp3);//delete [] tmp3; if (tmp4) - XMLPlatformUtils::fgMemoryManager->deallocate(tmp4);//delete [] tmp4; + toUse->deallocate(tmp4);//delete [] tmp4; return bRet; } diff --git a/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.hpp b/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.hpp index 4c3d66baea92f219e8e7d5211c279288388f1d69..5ed069912b16e9a41a2990cad50c67f1b2a58c76 100644 --- a/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.hpp +++ b/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/03/07 18:15:44 tng * Return a reference instead of void for operator= * @@ -137,6 +140,7 @@ public : , const char* const repText2 = 0 , const char* const repText3 = 0 , const char* const repText4 = 0 + , MemoryManager* const manager = 0 ); diff --git a/src/xercesc/util/NameIdPool.c b/src/xercesc/util/NameIdPool.c index 39224bbfdcbd86ee3be685d6cb9d0452e2b973c2..d273b3bc4fc91ab39378e3f2b906ee20a1c83d43 100644 --- a/src/xercesc/util/NameIdPool.c +++ b/src/xercesc/util/NameIdPool.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/10/29 16:18:05 peiyongz * size() added and Reset() bug fixed * @@ -139,7 +142,7 @@ NameIdPool<TElem>::NameIdPool( const unsigned int hashModulus , fHashModulus(hashModulus) { if (!fHashModulus) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus, fMemoryManager); // Allocate the bucket list and zero them fBucketList = (NameIdPoolBucketElem<TElem>**) fMemoryManager->allocate @@ -244,7 +247,7 @@ NameIdPool<TElem>::getById(const unsigned int elemId) { // If its either zero or beyond our current id, its an error if (!elemId || (elemId > fIdCounter)) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_InvalidId, fMemoryManager); return fIdPtrs[elemId]; } @@ -254,12 +257,16 @@ const TElem* NameIdPool<TElem>::getById(const unsigned int elemId) const { // If its either zero or beyond our current id, its an error if (!elemId || (elemId > fIdCounter)) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_InvalidId, fMemoryManager); return fIdPtrs[elemId]; } - +template <class TElem> +MemoryManager* NameIdPool<TElem>::getMemoryManager() const +{ + return fMemoryManager; +} // --------------------------------------------------------------------------- // NameIdPool: Setters @@ -271,11 +278,12 @@ unsigned int NameIdPool<TElem>::put(TElem* const elemToAdopt) unsigned int hashVal; if (findBucketElem(elemToAdopt->getKey(), hashVal)) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( IllegalArgumentException , XMLExcepts::Pool_ElemAlreadyExists , elemToAdopt->getKey() + , fMemoryManager ); } @@ -327,10 +335,10 @@ NameIdPoolBucketElem<TElem>* NameIdPool<TElem>:: findBucketElem(const XMLCh* const key, unsigned int& hashVal) { // Hash the key - hashVal = XMLString::hash(key, fHashModulus); + hashVal = XMLString::hash(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::Pool_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_BadHashFromKey, fMemoryManager); // Search that bucket for the key NameIdPoolBucketElem<TElem>* curElem = fBucketList[hashVal]; @@ -348,10 +356,10 @@ const NameIdPoolBucketElem<TElem>* NameIdPool<TElem>:: findBucketElem(const XMLCh* const key, unsigned int& hashVal) const { // Hash the key - hashVal = XMLString::hash(key, fHashModulus); + hashVal = XMLString::hash(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::Pool_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_BadHashFromKey, fMemoryManager); // Search that bucket for the key const NameIdPoolBucketElem<TElem>* curElem = fBucketList[hashVal]; @@ -371,11 +379,13 @@ findBucketElem(const XMLCh* const key, unsigned int& hashVal) const // NameIdPoolEnumerator: Constructors and Destructor // --------------------------------------------------------------------------- template <class TElem> NameIdPoolEnumerator<TElem>:: -NameIdPoolEnumerator(NameIdPool<TElem>* const toEnum) : +NameIdPoolEnumerator(NameIdPool<TElem>* const toEnum + , MemoryManager* const manager) : XMLEnumerator<TElem>() , fCurIndex(0) , fToEnum(toEnum) + , fMemoryManager(manager) { Reset(); } @@ -385,6 +395,7 @@ NameIdPoolEnumerator(const NameIdPoolEnumerator<TElem>& toCopy) : fCurIndex(toCopy.fCurIndex) , fToEnum(toCopy.fToEnum) + , fMemoryManager(toCopy.fMemoryManager) { } @@ -402,13 +413,12 @@ operator=(const NameIdPoolEnumerator<TElem>& toAssign) { if (this == &toAssign) return *this; - - fCurIndex = toAssign.fCurIndex; - fToEnum = toAssign.fToEnum; + fMemoryManager = toAssign.fMemoryManager; + fCurIndex = toAssign.fCurIndex; + fToEnum = toAssign.fToEnum; return *this; } - // --------------------------------------------------------------------------- // NameIdPoolEnumerator: Enum interface // --------------------------------------------------------------------------- @@ -425,7 +435,7 @@ template <class TElem> TElem& NameIdPoolEnumerator<TElem>::nextElement() { // If our index is zero or past the end, then we are done if (!fCurIndex || (fCurIndex > fToEnum->fIdCounter)) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // Return the current element and bump the index return *fToEnum->fIdPtrs[fCurIndex++]; diff --git a/src/xercesc/util/NameIdPool.hpp b/src/xercesc/util/NameIdPool.hpp index 9cfcec48cfc7de708eef098921d6207764bae960..ce6fa217a699192eaa5a00d7be95d6c6b97148cf 100644 --- a/src/xercesc/util/NameIdPool.hpp +++ b/src/xercesc/util/NameIdPool.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/10/29 16:17:48 peiyongz * size() added * @@ -191,7 +194,7 @@ public : TElem* getById(const unsigned elemId); const TElem* getById(const unsigned elemId) const; - + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- // Putters // @@ -278,6 +281,7 @@ public : NameIdPoolEnumerator ( NameIdPool<TElem>* const toEnum + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); NameIdPoolEnumerator @@ -294,8 +298,7 @@ public : ( const NameIdPoolEnumerator<TElem>& toAssign ); - - + // ----------------------------------------------------------------------- // Enum interface // ----------------------------------------------------------------------- @@ -315,8 +318,9 @@ private : // fToEnum // The name id pool that is being enumerated. // ----------------------------------------------------------------------- - unsigned int fCurIndex; - NameIdPool<TElem>* fToEnum; + unsigned int fCurIndex; + NameIdPool<TElem>* fToEnum; + MemoryManager* const fMemoryManager; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp b/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp index 258a37ff1805bd32c97494f20ec6e4d40fdfe01e..9df16677232a8eb8b8860b733d9fbb85a55999b4 100644 --- a/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp +++ b/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/12/02 14:12:20 amassari * Make the code compilable on Windows when UNICODE is defined (bug#16055) * @@ -157,7 +160,7 @@ LPFN_WSACLEANUP gWSACleanup = NULL; bool BinHTTPURLInputStream::fInitialized = false; XMLMutex* BinHTTPURLInputStream::fInitMutex = 0; -void BinHTTPURLInputStream::Initialize() { +void BinHTTPURLInputStream::Initialize(MemoryManager* const manager) { // // Initialize the WinSock library here. // @@ -168,7 +171,7 @@ void BinHTTPURLInputStream::Initialize() { if(gWinsockLib == NULL) { gWinsockLib = LoadLibrary(_T("WSOCK32")); if(gWinsockLib == NULL) { - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed); + ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_InitFailed, manager); } else { startup = (LPFN_WSASTARTUP) GetProcAddress(gWinsockLib,"WSAStartup"); @@ -199,7 +202,7 @@ void BinHTTPURLInputStream::Initialize() { { gWSACleanup = NULL; Cleanup(); - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed); + ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_InitFailed, manager); } } } @@ -208,7 +211,7 @@ void BinHTTPURLInputStream::Initialize() { if (err != 0) { // Call WSAGetLastError() to get the last error. - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed); + ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_InitFailed, manager); } fInitialized = true; } @@ -307,10 +310,11 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) XMLMutexLock lock(fInitMutex); if (!fInitialized) { - Initialize(); + Initialize(urlSource.getMemoryManager()); } } + fMemoryManager = urlSource.getMemoryManager(); // // Pull all of the parts of the URL out of th urlSource object, and transcode them // and transcode them back to ASCII. @@ -350,16 +354,16 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) if (numAddress == INADDR_NONE) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, - XMLExcepts::NetAcc_TargetResolution, hostName); + ThrowXMLwithMemMgr1(NetAccessorException, + XMLExcepts::NetAcc_TargetResolution, hostName, fMemoryManager); } if ((hostEntPtr = gethostbyaddr((const char *) &numAddress, sizeof(unsigned long), AF_INET)) == NULL) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, - XMLExcepts::NetAcc_TargetResolution, hostName); + ThrowXMLwithMemMgr1(NetAccessorException, + XMLExcepts::NetAcc_TargetResolution, hostName, fMemoryManager); } } @@ -372,15 +376,15 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) if (s == INVALID_SOCKET) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, - XMLExcepts::NetAcc_CreateSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, + XMLExcepts::NetAcc_CreateSocket, urlSource.getURLText(), fMemoryManager); } if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) == SOCKET_ERROR) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, - XMLExcepts::NetAcc_ConnSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, + XMLExcepts::NetAcc_ConnSocket, urlSource.getURLText(), fMemoryManager); } @@ -427,8 +431,8 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) if ((aLent = send(s, fBuffer, lent, 0)) != lent) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, - XMLExcepts::NetAcc_WriteSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, + XMLExcepts::NetAcc_WriteSocket, urlSource.getURLText(), fMemoryManager); } @@ -440,7 +444,7 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) if (aLent == SOCKET_ERROR || aLent == 0) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText(), fMemoryManager); } fBufferEnd = fBuffer+aLent; @@ -475,7 +479,7 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) if (aLent == SOCKET_ERROR || aLent == 0) { // Call WSAGetLastError() to get the error number. - ThrowXML1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText(), fMemoryManager); } fBufferEnd = fBufferEnd + aLent; *fBufferEnd = 0; @@ -488,13 +492,13 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) char *p = strstr(fBuffer, "HTTP"); if (p == 0) { - ThrowXML1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText(), fMemoryManager); } p = strchr(p, ' '); if (p == 0) { - ThrowXML1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, urlSource.getURLText(), fMemoryManager); } int httpResponse = atoi(p); @@ -503,7 +507,7 @@ BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource) // Most likely a 404 Not Found error. // Should recognize and handle the forwarding responses. // - ThrowXML1(NetAccessorException, XMLExcepts::File_CouldNotOpenFile, urlSource.getURLText()); + ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::File_CouldNotOpenFile, urlSource.getURLText(), fMemoryManager); } fSocketHandle = (unsigned int) s; @@ -543,7 +547,7 @@ unsigned int BinHTTPURLInputStream::readBytes(XMLByte* const toFill if (len == SOCKET_ERROR) { // Call WSAGetLastError() to get the error number. - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_ReadSocket); + ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_ReadSocket, fMemoryManager); } } diff --git a/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.hpp b/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.hpp index ba06c94c8ac68a5e61c1010121db9d4e12620f2c..8a805f6e670ca62ec555ae5f62c0834a4c2b88b6 100644 --- a/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.hpp +++ b/src/xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2002/11/04 15:11:39 tng * C++ Namespace Support. * @@ -145,7 +148,7 @@ private : // Pointers into fBuffer, showing start and end+1 of content // that readBytes must return. // ----------------------------------------------------------------------- - + MemoryManager* fMemoryManager; unsigned int fSocketHandle; unsigned int fBytesProcessed; char fBuffer[4000]; @@ -154,7 +157,7 @@ private : static bool fInitialized; static XMLMutex* fInitMutex; - static void Initialize(); + static void Initialize(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); inline static hostent* gethostbyname(const char* name); inline static unsigned long inet_addr(const char* cp); diff --git a/src/xercesc/util/NetAccessors/WinSock/WinSockNetAccessor.cpp b/src/xercesc/util/NetAccessors/WinSock/WinSockNetAccessor.cpp index ccd64d2b1a54d1036a18f967b3053250530d1f77..f5258f9415b7b31d513cca4164c36c6bbeed30cc 100644 --- a/src/xercesc/util/NetAccessors/WinSock/WinSockNetAccessor.cpp +++ b/src/xercesc/util/NetAccessors/WinSock/WinSockNetAccessor.cpp @@ -110,7 +110,7 @@ BinInputStream* WinSockNetAccessor::makeNew(const XMLURL& urlSource) // unsupported protocol exception for the others. // default : - ThrowXML(MalformedURLException, XMLExcepts::URL_UnsupportedProto); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_UnsupportedProto, urlSource.getMemoryManager()); break; } return 0; diff --git a/src/xercesc/util/PlatformUtils.cpp b/src/xercesc/util/PlatformUtils.cpp index 4bf19c22ace55468e6c28b4e93c1331f35146b88..f82f61b28a9e9cbf56cde61f8fb8094a18e2eb00 100644 --- a/src/xercesc/util/PlatformUtils.cpp +++ b/src/xercesc/util/PlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.16 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.15 2003/12/03 17:30:19 neilg * uninitialize panic handlers so they will be ready for subsequent initalizations * @@ -446,7 +449,7 @@ XMLMsgLoader* XMLPlatformUtils::loadMsgSet(const XMLCh* const msgDomain) // --------------------------------------------------------------------------- // XMLPlatformUtils: NEL Character Handling // --------------------------------------------------------------------------- -void XMLPlatformUtils::recognizeNEL(bool state) { +void XMLPlatformUtils::recognizeNEL(bool state, MemoryManager* const manager) { //Make sure initialize has been called if (gInitFlag == 0) { @@ -462,7 +465,7 @@ void XMLPlatformUtils::recognizeNEL(bool state) { else { if (XMLChar1_0::isNELRecognized()) { - ThrowXML(RuntimeException, XMLExcepts::NEL_RepeatedCalls); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::NEL_RepeatedCalls, manager); } } } diff --git a/src/xercesc/util/PlatformUtils.hpp b/src/xercesc/util/PlatformUtils.hpp index 018657ce086b01e327c9996f5ddbd2682f5e0b48..bc1ca20f4216bce5fddf98e3deeaf17653c49d5e 100644 --- a/src/xercesc/util/PlatformUtils.hpp +++ b/src/xercesc/util/PlatformUtils.hpp @@ -249,7 +249,8 @@ public : * * @param theFile The file handle */ - static unsigned int curFilePos(FileHandle theFile); + static unsigned int curFilePos(FileHandle theFile + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Closes the file handle * @@ -260,7 +261,8 @@ public : * * @param theFile The file handle to close */ - static void closeFile(FileHandle theFile); + static void closeFile(FileHandle theFile + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Returns the file size * @@ -272,7 +274,8 @@ public : * * @return Returns the size of the file in bytes */ - static unsigned int fileSize(FileHandle theFile); + static unsigned int fileSize(FileHandle theFile + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Opens the file * @@ -331,7 +334,7 @@ public : * * @return The file handle of the standard input stream */ - static FileHandle openStdInHandle(); + static FileHandle openStdInHandle(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Reads the file buffer * @@ -353,6 +356,7 @@ public : FileHandle theFile , const unsigned int toRead , XMLByte* const toFill + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Writes the buffer to the file @@ -374,6 +378,7 @@ public : FileHandle const theFile , long toWrite , const XMLByte* const toFlush + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Resets the file handle @@ -384,7 +389,8 @@ public : * * @param theFile The file handle that you want to reset */ - static void resetFile(FileHandle theFile); + static void resetFile(FileHandle theFile + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} @@ -456,7 +462,8 @@ public : * * @return */ - static void removeDotSlash(XMLCh* const srcPath); + static void removeDotSlash(XMLCh* const srcPath + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Remove occurences of the dot dot slash * @@ -468,7 +475,8 @@ public : * * @return */ - static void removeDotDotSlash(XMLCh* const srcPath); + static void removeDotDotSlash(XMLCh* const srcPath + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Determines if a path is relative or absolute * @@ -508,6 +516,7 @@ public : ( const XMLCh* const basePath , const XMLCh* const relativePath + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -685,7 +694,8 @@ public : * which always recognize these two chars (0x85 and 0x2028) as newline characters. * */ - static void recognizeNEL(bool state); + static void recognizeNEL(bool state + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** * Return the value of fgNEL flag. diff --git a/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp b/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp index 1476a2e42d6d520465ab73e37766269645feede7..a249e32162141845fe34ee4deb1a0b328534d525 100644 --- a/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp +++ b/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp @@ -167,37 +167,40 @@ static bool isBackSlash(XMLCh c) { c == chWonSign; } -unsigned int XMLPlatformUtils::curFilePos(FileHandle theFile) +unsigned int XMLPlatformUtils::curFilePos(FileHandle theFile + , MemoryManager* const manager) { // Get the current position const unsigned int curPos = ::SetFilePointer(theFile, 0, 0, FILE_CURRENT); if (curPos == 0xFFFFFFFF) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetCurPos); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetCurPos, manager); return curPos; } -void XMLPlatformUtils::closeFile(FileHandle theFile) +void XMLPlatformUtils::closeFile(FileHandle theFile + , MemoryManager* const manager) { if (!::CloseHandle(theFile)) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotCloseFile); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotCloseFile, manager); } -unsigned int XMLPlatformUtils::fileSize(FileHandle theFile) +unsigned int XMLPlatformUtils::fileSize(FileHandle theFile + , MemoryManager* const manager) { // Get the current position const unsigned int curPos = ::SetFilePointer(theFile, 0, 0, FILE_CURRENT); if (curPos == 0xFFFFFFFF) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetCurPos); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotGetCurPos, manager); // Seek to the end and save that value for return const unsigned int retVal = ::SetFilePointer(theFile, 0, 0, FILE_END); if (retVal == 0xFFFFFFFF) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToEnd); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToEnd, manager); // And put the pointer back if (::SetFilePointer(theFile, curPos, 0, FILE_BEGIN) == 0xFFFFFFFF) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToPos); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotSeekToPos, manager); return retVal; } @@ -463,7 +466,7 @@ FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName) return retVal; } -FileHandle XMLPlatformUtils::openStdInHandle() +FileHandle XMLPlatformUtils::openStdInHandle(MemoryManager* const manager) { // // Get the standard input handle. Duplicate it and return that copy @@ -474,7 +477,7 @@ FileHandle XMLPlatformUtils::openStdInHandle() HANDLE stdInOrg = ::GetStdHandle(STD_INPUT_HANDLE); if (stdInOrg == INVALID_HANDLE_VALUE) { XMLCh stdinStr[] = {chLatin_s, chLatin_t, chLatin_d, chLatin_i, chLatin_n, chNull}; - ThrowXML1(XMLPlatformUtilsException, XMLExcepts::File_CouldNotOpenFile, stdinStr); + ThrowXMLwithMemMgr1(XMLPlatformUtilsException, XMLExcepts::File_CouldNotOpenFile, stdinStr, manager); } HANDLE retHandle; @@ -488,7 +491,7 @@ FileHandle XMLPlatformUtils::openStdInHandle() , FALSE , DUPLICATE_SAME_ACCESS)) { - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotDupHandle); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotDupHandle, manager); } return retHandle; } @@ -497,7 +500,8 @@ FileHandle XMLPlatformUtils::openStdInHandle() unsigned int XMLPlatformUtils::readFileBuffer( FileHandle theFile , const unsigned int toRead - , XMLByte* const toFill) + , XMLByte* const toFill + , MemoryManager* const manager) { unsigned long bytesRead = 0; if (!::ReadFile(theFile, toFill, toRead, &bytesRead, 0)) @@ -507,7 +511,7 @@ XMLPlatformUtils::readFileBuffer( FileHandle theFile // means no more data from the pipe, so return zero. // if (::GetLastError() != ERROR_BROKEN_PIPE) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile, manager); } return (unsigned int)bytesRead; } @@ -515,7 +519,8 @@ XMLPlatformUtils::readFileBuffer( FileHandle theFile void XMLPlatformUtils::writeBufferToFile( FileHandle const theFile , long toWrite - , const XMLByte* const toFlush) + , const XMLByte* const toFlush + , MemoryManager* const manager) { if (!theFile || (toWrite <= 0 ) || @@ -528,7 +533,7 @@ XMLPlatformUtils::writeBufferToFile( FileHandle const theFile while (true) { if (!::WriteFile(theFile, tmpFlush, toWrite, &bytesWritten, 0)) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile, manager); if (bytesWritten < (unsigned long) toWrite) //incomplete write { @@ -543,11 +548,13 @@ XMLPlatformUtils::writeBufferToFile( FileHandle const theFile return; } -void XMLPlatformUtils::resetFile(FileHandle theFile) +void XMLPlatformUtils::resetFile(FileHandle theFile + , MemoryManager* const manager) { // Seek to the start of the file if (::SetFilePointer(theFile, 0, 0, FILE_BEGIN) == 0xFFFFFFFF) - ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotResetFile); + ThrowXMLwithMemMgr(XMLPlatformUtilsException, XMLExcepts::File_CouldNotResetFile, manager); + } diff --git a/src/xercesc/util/RefArrayOf.c b/src/xercesc/util/RefArrayOf.c index 7e31f49ce760e959737eed05f8630e54af79a66a..de695547216974a266b9e9c38e03edc3e0c516b9 100644 --- a/src/xercesc/util/RefArrayOf.c +++ b/src/xercesc/util/RefArrayOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.5 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -149,7 +152,7 @@ template <class TElem> TElem*& RefArrayOf<TElem>:: operator[](const unsigned int index) { if (index >= fSize) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); return fArray[index]; } @@ -157,7 +160,7 @@ template <class TElem> const TElem* RefArrayOf<TElem>:: operator[](const unsigned int index) const { if (index >= fSize) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); return fArray[index]; } @@ -246,7 +249,7 @@ template <class TElem> TElem** RefArrayOf<TElem>::rawData() const template <class TElem> void RefArrayOf<TElem>::deleteAt(const unsigned int index) { if (index >= fSize) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); delete fArray[index]; fArray[index] = 0; @@ -267,7 +270,7 @@ template <class TElem> void RefArrayOf<TElem>::resize(const unsigned int newSize return; if (newSize < fSize) - ThrowXML(IllegalArgumentException, XMLExcepts::Array_BadNewSize); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Array_BadNewSize, fMemoryManager); // Allocate the new array TElem** newArray = (TElem**) fMemoryManager->allocate diff --git a/src/xercesc/util/RefArrayVectorOf.c b/src/xercesc/util/RefArrayVectorOf.c index 3829130011a4ba0fb59284461d5665d65c3471ef..5318b67bcb47518d7e15c19640410aa583ebb836 100644 --- a/src/xercesc/util/RefArrayVectorOf.c +++ b/src/xercesc/util/RefArrayVectorOf.c @@ -89,7 +89,7 @@ template <class TElem> void RefArrayVectorOf<TElem>::setElementAt(TElem* const toSet, const unsigned int setAt) { if (setAt >= this->fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, this->fMemoryManager); if (this->fAdoptedElems) this->fMemoryManager->deallocate(this->fElemList[setAt]); @@ -114,7 +114,7 @@ template <class TElem> void RefArrayVectorOf<TElem>:: removeElementAt(const unsigned int removeAt) { if (removeAt >= this->fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, this->fMemoryManager); if (this->fAdoptedElems) this->fMemoryManager->deallocate(this->fElemList[removeAt]); diff --git a/src/xercesc/util/RefHash2KeysTableOf.c b/src/xercesc/util/RefHash2KeysTableOf.c index c0262a2c33098d31838923e5cadeeb06425e071b..4a049342c99b642dd091e6eec981ecf56064b52b 100644 --- a/src/xercesc/util/RefHash2KeysTableOf.c +++ b/src/xercesc/util/RefHash2KeysTableOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.6 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/10/17 21:10:40 peiyongz * nextElementKey() added * @@ -154,7 +157,7 @@ template <class TVal> void RefHash2KeysTableOf<TVal>::initialize(const unsigned int modulus) { if (modulus == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager); // Allocate the bucket list and zero them fBucketList = (RefHash2KeysTableBucketElem<TVal>**) fMemoryManager->allocate @@ -257,7 +260,11 @@ get(const void* const key1, const int key2) const return findIt->fData; } - +template <class TVal> +MemoryManager* RefHash2KeysTableOf<TVal>::getMemoryManager() const +{ + return fMemoryManager; +} // --------------------------------------------------------------------------- // RefHash2KeysTableOf: Putters // --------------------------------------------------------------------------- @@ -295,9 +302,9 @@ template <class TVal> RefHash2KeysTableBucketElem<TVal>* RefHash2KeysTableOf<TVa findBucketElem(const void* const key1, const int key2, unsigned int& hashVal) { // Hash the key - hashVal = fHash->getHashVal(key1, fHashModulus); + hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -315,9 +322,9 @@ template <class TVal> const RefHash2KeysTableBucketElem<TVal>* RefHash2KeysTable findBucketElem(const void* const key1, const int key2, unsigned int& hashVal) const { // Hash the key - hashVal = fHash->getHashVal(key1, fHashModulus); + hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key const RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -338,7 +345,7 @@ removeBucketElem(const void* const key1, const int key2, unsigned int& hashVal) // Hash the key hashVal = fHash->getHashVal(key1, fHashModulus); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // // Search the given bucket for this key. Keep up with the previous @@ -378,7 +385,7 @@ removeBucketElem(const void* const key1, const int key2, unsigned int& hashVal) } // We never found that key - ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, fMemoryManager); } @@ -388,11 +395,14 @@ removeBucketElem(const void* const key1, const int key2, unsigned int& hashVal) // RefHash2KeysTableOfEnumerator: Constructors and Destructor // --------------------------------------------------------------------------- template <class TVal> RefHash2KeysTableOfEnumerator<TVal>:: -RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal>* const toEnum, const bool adopt) +RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal>* const toEnum + , const bool adopt + , MemoryManager* const manager) : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum) + , fMemoryManager(manager) { if (!toEnum) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, fMemoryManager); // // Find the next available bucket element in the hash table. If it @@ -429,7 +439,7 @@ template <class TVal> TVal& RefHash2KeysTableOfEnumerator<TVal>::nextElement() { // Make sure we have an element to return if (!hasMoreElements()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the @@ -445,7 +455,7 @@ template <class TVal> void RefHash2KeysTableOfEnumerator<TVal>::nextElementKey(v { // Make sure we have an element to return if (!hasMoreElements()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the diff --git a/src/xercesc/util/RefHash2KeysTableOf.hpp b/src/xercesc/util/RefHash2KeysTableOf.hpp index 7dd2ed340618ac6affeec53f7a6c3490c58d7d94..1b5a006b8e019910638aa85c9d23f001b29fc855 100644 --- a/src/xercesc/util/RefHash2KeysTableOf.hpp +++ b/src/xercesc/util/RefHash2KeysTableOf.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/10/20 11:45:06 gareth * Made enumerators inherit from XMemory. * @@ -186,7 +189,7 @@ public: TVal* get(const void* const key1, const int key2); const TVal* get(const void* const key1, const int key2) const; - + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- // Putters // ----------------------------------------------------------------------- @@ -199,6 +202,7 @@ private : // ----------------------------------------------------------------------- friend class RefHash2KeysTableOfEnumerator<TVal>; + private: // ----------------------------------------------------------------------- @@ -248,7 +252,9 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal>* const toEnum, const bool adopt = false); + RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal>* const toEnum + , const bool adopt = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual ~RefHash2KeysTableOfEnumerator(); @@ -289,10 +295,11 @@ private : // fToEnum // The value array being enumerated. // ----------------------------------------------------------------------- - bool fAdopted; - RefHash2KeysTableBucketElem<TVal>* fCurElem; - unsigned int fCurHash; - RefHash2KeysTableOf<TVal>* fToEnum; + bool fAdopted; + RefHash2KeysTableBucketElem<TVal>* fCurElem; + unsigned int fCurHash; + RefHash2KeysTableOf<TVal>* fToEnum; + MemoryManager* const fMemoryManager; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/RefHash3KeysIdPool.c b/src/xercesc/util/RefHash3KeysIdPool.c index bca424415d7934e098c8d1fbf7cd393e664a65f4..a6b0a8dc098814dce76386fd018f50aa81d11568 100644 --- a/src/xercesc/util/RefHash3KeysIdPool.c +++ b/src/xercesc/util/RefHash3KeysIdPool.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.9 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/11/03 22:00:31 peiyongz * RefHashTable-like enumeration accessing added * @@ -207,7 +210,7 @@ RefHash3KeysIdPool<TVal>::RefHash3KeysIdPool( const unsigned int modulus template <class TVal> void RefHash3KeysIdPool<TVal>::initialize(const unsigned int modulus) { if (modulus == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager); // Allocate the bucket list and zero them fBucketList = (RefHash3KeysTableBucketElem<TVal>**) fMemoryManager->allocate @@ -313,7 +316,7 @@ RefHash3KeysIdPool<TVal>::getById(const unsigned int elemId) { // If its either zero or beyond our current id, its an error if (!elemId || (elemId > fIdCounter)) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_InvalidId, fMemoryManager); return fIdPtrs[elemId]; } @@ -323,11 +326,16 @@ RefHash3KeysIdPool<TVal>::getById(const unsigned int elemId) const { // If its either zero or beyond our current id, its an error if (!elemId || (elemId > fIdCounter)) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_InvalidId, fMemoryManager); return fIdPtrs[elemId]; } +template <class TVal> +MemoryManager* RefHash3KeysIdPool<TVal>::getMemoryManager() const +{ + return fMemoryManager; +} // --------------------------------------------------------------------------- // RefHash3KeysIdPool: Putters // --------------------------------------------------------------------------- @@ -402,9 +410,9 @@ template <class TVal> RefHash3KeysTableBucketElem<TVal>* RefHash3KeysIdPool<TVal findBucketElem(const void* const key1, const int key2, const int key3, unsigned int& hashVal) { // Hash the key - hashVal = fHash->getHashVal(key1, fHashModulus); + hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key RefHash3KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -424,7 +432,7 @@ findBucketElem(const void* const key1, const int key2, const int key3, unsigned // Hash the key hashVal = fHash->getHashVal(key1, fHashModulus); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key const RefHash3KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -443,11 +451,13 @@ findBucketElem(const void* const key1, const int key2, const int key3, unsigned // RefHash3KeysIdPoolEnumerator: Constructors and Destructor // --------------------------------------------------------------------------- template <class TVal> RefHash3KeysIdPoolEnumerator<TVal>:: -RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal>* const toEnum, const bool adopt) - : fAdoptedElems(adopt), fCurIndex(0), fToEnum(toEnum) +RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal>* const toEnum + , const bool adopt + , MemoryManager* const manager) + : fAdoptedElems(adopt), fCurIndex(0), fToEnum(toEnum), fMemoryManager(manager) { if (!toEnum) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, fMemoryManager); Reset(); resetKey(); @@ -475,7 +485,7 @@ template <class TVal> TVal& RefHash3KeysIdPoolEnumerator<TVal>::nextElement() { // If our index is zero or past the end, then we are done if (!fCurIndex || (fCurIndex > fToEnum->fIdCounter)) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // Return the current element and bump the index return *fToEnum->fIdPtrs[fCurIndex++]; @@ -521,7 +531,7 @@ template <class TVal> void RefHash3KeysIdPoolEnumerator<TVal>::nextElementKey(vo { // Make sure we have an element to return if (!hasMoreKeys()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the diff --git a/src/xercesc/util/RefHash3KeysIdPool.hpp b/src/xercesc/util/RefHash3KeysIdPool.hpp index 9a2a7e0fe1cdd7661ccca70a5d3aebbd8c7dc9dc..ad502fb2afc567126ddc1cb6d49c78a74187082d 100644 --- a/src/xercesc/util/RefHash3KeysIdPool.hpp +++ b/src/xercesc/util/RefHash3KeysIdPool.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/03 22:00:31 peiyongz * RefHashTable-like enumeration accessing added * @@ -204,6 +207,7 @@ public: TVal* getById(const unsigned elemId); const TVal* getById(const unsigned elemId) const; + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- // Putters // ----------------------------------------------------------------------- @@ -281,7 +285,9 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal>* const toEnum, const bool adopt = false); + RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal>* const toEnum + , const bool adopt = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual ~RefHash3KeysIdPoolEnumerator(); @@ -321,12 +327,12 @@ private : // fToEnum // The name id pool that is being enumerated. // ----------------------------------------------------------------------- - bool fAdoptedElems; - unsigned int fCurIndex; - RefHash3KeysIdPool<TVal>* fToEnum; - - RefHash3KeysTableBucketElem<TVal>* fCurElem; - unsigned int fCurHash; + bool fAdoptedElems; + unsigned int fCurIndex; + RefHash3KeysIdPool<TVal>* fToEnum; + RefHash3KeysTableBucketElem<TVal>* fCurElem; + unsigned int fCurHash; + MemoryManager* const fMemoryManager; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/RefHashTableOf.c b/src/xercesc/util/RefHashTableOf.c index a8f14f86d6613496e8eae983c64c661a3c41f072..89c6f8d423851bbfcccf691549a14caf7e937e8f 100644 --- a/src/xercesc/util/RefHashTableOf.c +++ b/src/xercesc/util/RefHashTableOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.12 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/08/20 11:51:39 gareth * Reorderd initializer list to prevent compiler warning. * @@ -204,7 +207,7 @@ RefHashTableOf<TVal>::RefHashTableOf(const unsigned int modulus template <class TVal> void RefHashTableOf<TVal>::initialize(const unsigned int modulus) { if (modulus == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager); // Allocate the bucket list and zero them fBucketList = (RefHashTableBucketElem<TVal>**) fMemoryManager->allocate @@ -295,9 +298,9 @@ orphanKey(const void* const key) { // Hash the key TVal* retVal = 0; - unsigned int hashVal = fHash->getHashVal(key, fHashModulus); + unsigned int hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // // Search the given bucket for this key. Keep up with the previous @@ -335,7 +338,7 @@ orphanKey(const void* const key) // We never found that key if (!retVal) - ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, fMemoryManager); return retVal; } @@ -496,9 +499,9 @@ template <class TVal> void RefHashTableOf<TVal>::rehash() // Save the next element before we detach this one nextElem = curElem->fNext; - unsigned int hashVal = fHash->getHashVal(curElem->fKey, fHashModulus); + unsigned int hashVal = fHash->getHashVal(curElem->fKey, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); RefHashTableBucketElem<TVal>* newHeadElem = fBucketList[hashVal]; @@ -518,9 +521,9 @@ template <class TVal> RefHashTableBucketElem<TVal>* RefHashTableOf<TVal>:: findBucketElem(const void* const key, unsigned int& hashVal) { // Hash the key - hashVal = fHash->getHashVal(key, fHashModulus); + hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -538,9 +541,9 @@ template <class TVal> const RefHashTableBucketElem<TVal>* RefHashTableOf<TVal>:: findBucketElem(const void* const key, unsigned int& hashVal) const { // Hash the key - hashVal = fHash->getHashVal(key, fHashModulus); + hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key const RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -559,9 +562,9 @@ template <class TVal> void RefHashTableOf<TVal>:: removeBucketElem(const void* const key, unsigned int& hashVal) { // Hash the key - hashVal = fHash->getHashVal(key, fHashModulus); + hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // // Search the given bucket for this key. Keep up with the previous @@ -603,7 +606,7 @@ removeBucketElem(const void* const key, unsigned int& hashVal) } // We never found that key - ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, fMemoryManager); } @@ -612,11 +615,14 @@ removeBucketElem(const void* const key, unsigned int& hashVal) // RefHashTableOfEnumerator: Constructors and Destructor // --------------------------------------------------------------------------- template <class TVal> RefHashTableOfEnumerator<TVal>:: -RefHashTableOfEnumerator(RefHashTableOf<TVal>* const toEnum, const bool adopt) +RefHashTableOfEnumerator(RefHashTableOf<TVal>* const toEnum + , const bool adopt + , MemoryManager* const manager) : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum) + , fMemoryManager(manager) { if (!toEnum) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, fMemoryManager); // // Find the next available bucket element in the hash table. If it @@ -653,7 +659,7 @@ template <class TVal> TVal& RefHashTableOfEnumerator<TVal>::nextElement() { // Make sure we have an element to return if (!hasMoreElements()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the @@ -669,7 +675,7 @@ template <class TVal> void* RefHashTableOfEnumerator<TVal>::nextElementKey() { // Make sure we have an element to return if (!hasMoreElements()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the diff --git a/src/xercesc/util/RefHashTableOf.hpp b/src/xercesc/util/RefHashTableOf.hpp index c6958d8c122136425c48c2a46f5ae77b6be22c81..0953de6c8bfc421aba89f685562822cdcbb799fc 100644 --- a/src/xercesc/util/RefHashTableOf.hpp +++ b/src/xercesc/util/RefHashTableOf.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/10/20 11:45:06 gareth * Made enumerators inherit from XMemory. * @@ -292,7 +295,9 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - RefHashTableOfEnumerator(RefHashTableOf<TVal>* const toEnum, const bool adopt = false); + RefHashTableOfEnumerator(RefHashTableOf<TVal>* const toEnum + , const bool adopt = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual ~RefHashTableOfEnumerator(); @@ -337,6 +342,7 @@ private : RefHashTableBucketElem<TVal>* fCurElem; unsigned int fCurHash; RefHashTableOf<TVal>* fToEnum; + MemoryManager* const fMemoryManager; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/RefStackOf.c b/src/xercesc/util/RefStackOf.c index d16ef9eb32cc72dd284da7fd18663c2a3acf708b..64ea8e2f8be52c31c73eea51b9ec4429a313263a 100644 --- a/src/xercesc/util/RefStackOf.c +++ b/src/xercesc/util/RefStackOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.4 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -115,7 +118,7 @@ template <class TElem> const TElem* RefStackOf<TElem>:: elementAt(const unsigned int index) const { if (index > fVector.size()) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Stack_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Stack_BadIndex, fVector.getMemoryManager()); return fVector.elementAt(index); } @@ -128,7 +131,7 @@ template <class TElem> const TElem* RefStackOf<TElem>::peek() const { const int curSize = fVector.size(); if (curSize == 0) - ThrowXML(EmptyStackException, XMLExcepts::Stack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::Stack_EmptyStack, fVector.getMemoryManager()); return fVector.elementAt(curSize-1); } @@ -137,7 +140,7 @@ template <class TElem> TElem* RefStackOf<TElem>::pop() { const int curSize = fVector.size(); if (curSize == 0) - ThrowXML(EmptyStackException, XMLExcepts::Stack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::Stack_EmptyStack, fVector.getMemoryManager()); // Orphan off the element from the last slot in the vector return fVector.orphanElementAt(curSize-1); diff --git a/src/xercesc/util/StringPool.cpp b/src/xercesc/util/StringPool.cpp index 1d240b6c32d1a3235387f7b079218857cbb5b9fa..57a7a608786dc240c68650c5618aa6923052f83a 100644 --- a/src/xercesc/util/StringPool.cpp +++ b/src/xercesc/util/StringPool.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/10/29 16:18:41 peiyongz * Implement serialization/deserialization * @@ -220,7 +223,7 @@ unsigned int XMLStringPool::getId(const XMLCh* const toFind) const const XMLCh* XMLStringPool::getValueForId(const unsigned int id) const { if (!id || (id >= fCurId)) - ThrowXML(IllegalArgumentException, XMLExcepts::StrPool_IllegalId); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::StrPool_IllegalId, fMemoryManager); // Just index the id map and return that element's string return fIdMap[id]->fString; diff --git a/src/xercesc/util/TransENameMap.c b/src/xercesc/util/TransENameMap.c index 31dd67b385e8e61386eb02c0c4f5d7146135b5d8..86ec0f815c946362bb0eb91fe1622950cc456edf 100644 --- a/src/xercesc/util/TransENameMap.c +++ b/src/xercesc/util/TransENameMap.c @@ -86,7 +86,7 @@ template <class TType> XMLTranscoder* ENameMapFor<TType>::makeNew(const unsigned int blockSize, MemoryManager* const manager) const { - return new (manager) TType(getKey(), blockSize); + return new (manager) TType(getKey(), blockSize, manager); } @@ -114,7 +114,7 @@ template <class TType> XMLTranscoder* EEndianNameMapFor<TType>::makeNew(const unsigned int blockSize, MemoryManager* const manager) const { - return new (manager) TType(getKey(), blockSize, fSwapped); + return new (manager) TType(getKey(), blockSize, fSwapped, manager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/TransService.cpp b/src/xercesc/util/TransService.cpp index 3ae05688ba77015f654ede8f34ac95a6ff384d4c..50946fb9a0c8afe5a38a55e448544f7434303573 100644 --- a/src/xercesc/util/TransService.cpp +++ b/src/xercesc/util/TransService.cpp @@ -250,7 +250,7 @@ XMLTransService::makeNewTranscoderFor( XMLRecognizer::Encodings encoding return temp; } else { - XMLTranscoder* temp = makeNewXMLTranscoder(XMLRecognizer::nameForEncoding(encodingEnum), resValue, blockSize, manager); + XMLTranscoder* temp = makeNewXMLTranscoder(XMLRecognizer::nameForEncoding(encodingEnum, manager), resValue, blockSize, manager); // if successful, set resValue to OK // if failed, the makeNewXMLTranscoder has already set the proper failing resValue diff --git a/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp b/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp index c9c422b2ffa6023734c2bd8a1de63511eba328d5..d585d126e4ecbe08206820787c8d479eef148d75 100644 --- a/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp +++ b/src/xercesc/util/Transcoders/Win32/Win32TransService.cpp @@ -669,18 +669,19 @@ Win32Transcoder::transcodeFrom( const XMLByte* const srcData if (toEat == 1) { XMLCh tmpBuf[16]; - XMLString::binToText((unsigned int)(*inPtr), tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText((unsigned int)(*inPtr), tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_BadSrcCP , tmpBuf , getEncodingName() + , getMemoryManager() ); } else { - ThrowXML(TranscodingException, XMLExcepts::Trans_BadSrcSeq); + ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Trans_BadSrcSeq, getMemoryManager()); } } @@ -750,13 +751,14 @@ Win32Transcoder::transcodeTo(const XMLCh* const srcData if (usedDef && (options == UnRep_Throw)) { XMLCh tmpBuf[16]; - XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() + , getMemoryManager() ); } diff --git a/src/xercesc/util/ValueArrayOf.c b/src/xercesc/util/ValueArrayOf.c index 30b5ec2128621792627fdbf285b125c6bb40933e..512c3fe9a82e8ae2c88f29db1512749f945a43a7 100644 --- a/src/xercesc/util/ValueArrayOf.c +++ b/src/xercesc/util/ValueArrayOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.5 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -148,7 +151,7 @@ template <class TElem> TElem& ValueArrayOf<TElem>:: operator[](const unsigned int index) { if (index >= fSize) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); return fArray[index]; } @@ -156,7 +159,7 @@ template <class TElem> const TElem& ValueArrayOf<TElem>:: operator[](const unsigned int index) const { if (index >= fSize) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); return fArray[index]; } @@ -252,7 +255,7 @@ resize(const unsigned int newSize) return; if (newSize < fSize) - ThrowXML(IllegalArgumentException, XMLExcepts::Array_BadNewSize); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Array_BadNewSize); // Allocate the new array TElem* newArray = (TElem*) fMemoryManager->allocate diff --git a/src/xercesc/util/ValueHashTableOf.c b/src/xercesc/util/ValueHashTableOf.c index b077da25f8b80bae8415f5dc0bd15d63d5cf9032..be339ef7fc6884580cacbbb0ddf61b77325dde3d 100644 --- a/src/xercesc/util/ValueHashTableOf.c +++ b/src/xercesc/util/ValueHashTableOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/12/16 18:37:14 knoaman * Add nextElementKey method * @@ -119,7 +122,7 @@ ValueHashTableOf<TVal>::ValueHashTableOf( const unsigned int modulus template <class TVal> void ValueHashTableOf<TVal>::initialize(const unsigned int modulus) { if (modulus == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager); // Allocate the bucket list and zero them fBucketList = (ValueHashTableBucketElem<TVal>**) fMemoryManager->allocate @@ -196,12 +199,12 @@ template <class TVal> void ValueHashTableOf<TVal>::removeAll() // --------------------------------------------------------------------------- // ValueHashTableOf: Getters // --------------------------------------------------------------------------- -template <class TVal> TVal& ValueHashTableOf<TVal>::get(const void* const key) +template <class TVal> TVal& ValueHashTableOf<TVal>::get(const void* const key, MemoryManager* const manager) { unsigned int hashVal; ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal); if (!findIt) - ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, manager); return findIt->fData; } @@ -212,7 +215,7 @@ get(const void* const key) const unsigned int hashVal; const ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal); if (!findIt) - ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, fMemoryManager); return findIt->fData; } @@ -252,9 +255,9 @@ template <class TVal> ValueHashTableBucketElem<TVal>* ValueHashTableOf<TVal>:: findBucketElem(const void* const key, unsigned int& hashVal) { // Hash the key - hashVal = fHash->getHashVal(key, fHashModulus); + hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -272,9 +275,9 @@ template <class TVal> const ValueHashTableBucketElem<TVal>* ValueHashTableOf<TVa findBucketElem(const void* const key, unsigned int& hashVal) const { // Hash the key - hashVal = fHash->getHashVal(key, fHashModulus); + hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // Search that bucket for the key const ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal]; @@ -295,7 +298,7 @@ removeBucketElem(const void* const key, unsigned int& hashVal) // Hash the key hashVal = fHash->getHashVal(key, fHashModulus); if (hashVal > fHashModulus) - ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager); // // Search the given bucket for this key. Keep up with the previous @@ -331,7 +334,7 @@ removeBucketElem(const void* const key, unsigned int& hashVal) } // We never found that key - ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists, fMemoryManager); } @@ -341,11 +344,13 @@ removeBucketElem(const void* const key, unsigned int& hashVal) // ValueHashTableOfEnumerator: Constructors and Destructor // --------------------------------------------------------------------------- template <class TVal> ValueHashTableOfEnumerator<TVal>:: -ValueHashTableOfEnumerator(ValueHashTableOf<TVal>* const toEnum, const bool adopt) - : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum) +ValueHashTableOfEnumerator(ValueHashTableOf<TVal>* const toEnum + , const bool adopt + , MemoryManager* const manager) + : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum), fMemoryManager(manager) { if (!toEnum) - ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero); + ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, manager); // // Find the next available bucket element in the hash table. If it @@ -382,7 +387,7 @@ template <class TVal> TVal& ValueHashTableOfEnumerator<TVal>::nextElement() { // Make sure we have an element to return if (!hasMoreElements()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the @@ -398,7 +403,7 @@ template <class TVal> void* ValueHashTableOfEnumerator<TVal>::nextElementKey() { // Make sure we have an element to return if (!hasMoreElements()) - ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements); + ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager); // // Save the current element, then move up to the next one for the diff --git a/src/xercesc/util/ValueHashTableOf.hpp b/src/xercesc/util/ValueHashTableOf.hpp index abe04180d711612ec329a89fd3992b6a359cf70e..8f93b6bcd1bb9659872628d95c42be0768ac751d 100644 --- a/src/xercesc/util/ValueHashTableOf.hpp +++ b/src/xercesc/util/ValueHashTableOf.hpp @@ -134,7 +134,7 @@ public: // ----------------------------------------------------------------------- // Getters // ----------------------------------------------------------------------- - TVal& get(const void* const key); + TVal& get(const void* const key, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); const TVal& get(const void* const key) const; @@ -193,7 +193,9 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - ValueHashTableOfEnumerator(ValueHashTableOf<TVal>* const toEnum, const bool adopt = false); + ValueHashTableOfEnumerator(ValueHashTableOf<TVal>* const toEnum + , const bool adopt = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); virtual ~ValueHashTableOfEnumerator(); @@ -239,6 +241,7 @@ private : ValueHashTableBucketElem<TVal>* fCurElem; unsigned int fCurHash; ValueHashTableOf<TVal>* fToEnum; + MemoryManager* const fMemoryManager; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/ValueStackOf.c b/src/xercesc/util/ValueStackOf.c index e3d5f59096b5043ed4e62742be712ddef5809b50..b58d8ba56d2b784b93cb3570a0ccdd5b68ec84f1 100644 --- a/src/xercesc/util/ValueStackOf.c +++ b/src/xercesc/util/ValueStackOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.5 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/05/29 13:26:44 knoaman * Fix memory leak when using deprecated dom. * @@ -124,7 +127,7 @@ template <class TElem> const TElem& ValueStackOf<TElem>::peek() const { const int curSize = fVector.size(); if (curSize == 0) - ThrowXML(EmptyStackException, XMLExcepts::Stack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::Stack_EmptyStack, fVector.getMemoryManager()); return fVector.elementAt(curSize-1); } @@ -133,7 +136,7 @@ template <class TElem> TElem ValueStackOf<TElem>::pop() { const int curSize = fVector.size(); if (curSize == 0) - ThrowXML(EmptyStackException, XMLExcepts::Stack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::Stack_EmptyStack, fVector.getMemoryManager()); TElem retVal = fVector.elementAt(curSize-1); fVector.removeElementAt(curSize-1); diff --git a/src/xercesc/util/ValueVectorOf.c b/src/xercesc/util/ValueVectorOf.c index ade5831b38c4b80ce8aa53a5dd6eddf9454bf54b..9c29d8dd4c260ec7a682349270671672119d67fa 100644 --- a/src/xercesc/util/ValueVectorOf.c +++ b/src/xercesc/util/ValueVectorOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.9 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/11/21 15:44:12 amassari * insertElementAt was not checking if there was room for the new element (bug#24714) * @@ -207,7 +210,7 @@ template <class TElem> void ValueVectorOf<TElem>:: setElementAt(const TElem& toSet, const unsigned int setAt) { if (setAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); fElemList[setAt] = toSet; } @@ -221,7 +224,7 @@ insertElementAt(const TElem& toInsert, const unsigned int insertAt) } if (insertAt > fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); // Make room for the newbie ensureExtraCapacity(1); @@ -237,7 +240,7 @@ template <class TElem> void ValueVectorOf<TElem>:: removeElementAt(const unsigned int removeAt) { if (removeAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); if (removeAt == fCurCount-1) { @@ -279,7 +282,7 @@ template <class TElem> const TElem& ValueVectorOf<TElem>:: elementAt(const unsigned int getAt) const { if (getAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); return fElemList[getAt]; } @@ -287,7 +290,7 @@ template <class TElem> TElem& ValueVectorOf<TElem>:: elementAt(const unsigned int getAt) { if (getAt >= fCurCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); return fElemList[getAt]; } diff --git a/src/xercesc/util/XML256TableTranscoder.cpp b/src/xercesc/util/XML256TableTranscoder.cpp index 295ed89a13a5a68692b893b6206f73ed41dbb3a8..fa1df436d6132caa4973ae8cf34c1f9ff7c6a10c 100644 --- a/src/xercesc/util/XML256TableTranscoder.cpp +++ b/src/xercesc/util/XML256TableTranscoder.cpp @@ -174,13 +174,14 @@ XML256TableTranscoder::transcodeTo( const XMLCh* const srcData if (options == UnRep_Throw) { XMLCh tmpBuf[16]; - XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() + , getMemoryManager() ); } @@ -211,9 +212,10 @@ XML256TableTranscoder( const XMLCh* const encodingName , const unsigned int blockSize , const XMLCh* const fromTable , const XMLTransService::TransRec* const toTable - , const unsigned int toTableSize) : + , const unsigned int toTableSize + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) , fFromTable(fromTable) , fToSize(toTableSize) , fToTable(toTable) diff --git a/src/xercesc/util/XML256TableTranscoder.hpp b/src/xercesc/util/XML256TableTranscoder.hpp index 31215357933d6acc7d3def1b0a1fe6cb1625a7e3..fa51be5a3cca297e4f7c1d3215a7619454752a95 100644 --- a/src/xercesc/util/XML256TableTranscoder.hpp +++ b/src/xercesc/util/XML256TableTranscoder.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/03/07 18:11:55 tng * Return a reference instead of void for operator= * @@ -133,6 +136,7 @@ protected : , const XMLCh* const fromTable , const XMLTransService::TransRec* const toTable , const unsigned int toTableSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); diff --git a/src/xercesc/util/XML88591Transcoder.cpp b/src/xercesc/util/XML88591Transcoder.cpp index a022060f6e27b2f6aaa5e8167fec5326e54504ba..b73e287108a8674b09856c58569e0d7081bfe9f4 100644 --- a/src/xercesc/util/XML88591Transcoder.cpp +++ b/src/xercesc/util/XML88591Transcoder.cpp @@ -69,9 +69,10 @@ XERCES_CPP_NAMESPACE_BEGIN // XML88591Transcoder: Constructors and Destructor // --------------------------------------------------------------------------- XML88591Transcoder::XML88591Transcoder( const XMLCh* const encodingName - , const unsigned int blockSize) : + , const unsigned int blockSize + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) { } @@ -164,13 +165,14 @@ XML88591Transcoder::transcodeTo(const XMLCh* const srcData if (options == UnRep_Throw) { XMLCh tmpBuf[16]; - XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() + , getMemoryManager() ); } *destPtr++ = 0x1A; diff --git a/src/xercesc/util/XML88591Transcoder.hpp b/src/xercesc/util/XML88591Transcoder.hpp index 790a493d9a9d47defd0b2aac6e9d696167402d20..55d870e51d833948a19af3acb858cf1413ff199e 100644 --- a/src/xercesc/util/XML88591Transcoder.hpp +++ b/src/xercesc/util/XML88591Transcoder.hpp @@ -80,6 +80,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XML88591Transcoder(); diff --git a/src/xercesc/util/XMLASCIITranscoder.cpp b/src/xercesc/util/XMLASCIITranscoder.cpp index 348c6bc706daa4490b511ec4495cb99918d91c61..86b371ad91aee7055cc36f33fe14578f638297c6 100644 --- a/src/xercesc/util/XMLASCIITranscoder.cpp +++ b/src/xercesc/util/XMLASCIITranscoder.cpp @@ -69,9 +69,10 @@ XERCES_CPP_NAMESPACE_BEGIN // XMLASCIITranscoder: Constructors and Destructor // --------------------------------------------------------------------------- XMLASCIITranscoder::XMLASCIITranscoder( const XMLCh* const encodingName - , const unsigned int blockSize) : + , const unsigned int blockSize + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) { } @@ -129,13 +130,14 @@ XMLASCIITranscoder::transcodeFrom( const XMLByte* const srcData break; XMLCh tmpBuf[16]; - XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() + , getMemoryManager() ); } @@ -187,13 +189,14 @@ XMLASCIITranscoder::transcodeTo(const XMLCh* const srcData if (options == UnRep_Throw) { XMLCh tmpBuf[16]; - XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() + , getMemoryManager() ); } diff --git a/src/xercesc/util/XMLASCIITranscoder.hpp b/src/xercesc/util/XMLASCIITranscoder.hpp index 3b907c316201543821118047c60243d90db77548..08a8b51546bc0e965ec7c6bf2c18ad9c7d98d969 100644 --- a/src/xercesc/util/XMLASCIITranscoder.hpp +++ b/src/xercesc/util/XMLASCIITranscoder.hpp @@ -80,6 +80,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLASCIITranscoder(); diff --git a/src/xercesc/util/XMLAbstractDoubleFloat.cpp b/src/xercesc/util/XMLAbstractDoubleFloat.cpp index a53eaabb74b23ed6ccb507f248079799f206d070..439b9a6927cbd06f3de18a6d36c3317662bed278 100644 --- a/src/xercesc/util/XMLAbstractDoubleFloat.cpp +++ b/src/xercesc/util/XMLAbstractDoubleFloat.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.20 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.19 2003/12/12 04:51:29 peiyongz * trailing zeros for double/float w/o decimal point * @@ -170,7 +173,7 @@ XMLAbstractDoubleFloat::~XMLAbstractDoubleFloat() void XMLAbstractDoubleFloat::init(const XMLCh* const strValue) { if ((!strValue) || (!*strValue)) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_emptyString); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_emptyString, fMemoryManager); fRawData = XMLString::replicate(strValue, fMemoryManager); // preserve the raw data form @@ -284,7 +287,8 @@ int XMLAbstractDoubleFloat::getSign() const // // int XMLAbstractDoubleFloat::compareValues(const XMLAbstractDoubleFloat* const lValue - , const XMLAbstractDoubleFloat* const rValue) + , const XMLAbstractDoubleFloat* const rValue + , MemoryManager* const manager) { // // case#1: lValue normal @@ -338,7 +342,7 @@ int XMLAbstractDoubleFloat::compareValues(const XMLAbstractDoubleFloat* const lV if ((lValue->isSpecialValue()) && (!rValue->isSpecialValue()) ) { - return compareSpecial(lValue, rValue); + return compareSpecial(lValue, rValue, manager); } // // case#4: lValue normal @@ -346,14 +350,15 @@ int XMLAbstractDoubleFloat::compareValues(const XMLAbstractDoubleFloat* const lV // else { - return (-1) * compareSpecial(rValue, lValue); + return (-1) * compareSpecial(rValue, lValue, manager); } return 0; } int XMLAbstractDoubleFloat::compareSpecial(const XMLAbstractDoubleFloat* const specialValue - , const XMLAbstractDoubleFloat* const normalValue) + , const XMLAbstractDoubleFloat* const normalValue + , MemoryManager* const manager) { switch (specialValue->fType) { @@ -366,10 +371,10 @@ int XMLAbstractDoubleFloat::compareSpecial(const XMLAbstractDoubleFloat* const s return INDETERMINATE; default: - XMLString::binToText(specialValue->fType, value1, 16, 10); - ThrowXML1(NumberFormatException + XMLString::binToText(specialValue->fType, value1, 16, 10, manager); + ThrowXMLwithMemMgr1(NumberFormatException , XMLExcepts::XMLNUM_DBL_FLT_InvalidType - , value1); + , value1, manager); //internal error return 0; } @@ -514,7 +519,7 @@ XMLCh* XMLAbstractDoubleFloat::getCanonicalRepresentation(const XMLCh* c ***/ if (!ePosition) { - XMLBigDecimal::parseDecimal(rawData, manBuf, sign, totalDigits, fractDigits); + XMLBigDecimal::parseDecimal(rawData, manBuf, sign, totalDigits, fractDigits, memMgr); expValue = 0; } else @@ -522,7 +527,7 @@ XMLCh* XMLAbstractDoubleFloat::getCanonicalRepresentation(const XMLCh* c int manLen = ePosition - rawData; XMLString::copyNString(manStr, rawData, manLen); *(manStr + manLen) = chNull; - XMLBigDecimal::parseDecimal(manStr, manBuf, sign, totalDigits, fractDigits); + XMLBigDecimal::parseDecimal(manStr, manBuf, sign, totalDigits, fractDigits, memMgr); int expLen = strLen - manLen - 1; ePosition++; @@ -592,7 +597,7 @@ XMLCh* XMLAbstractDoubleFloat::getCanonicalRepresentation(const XMLCh* c * ***/ expValue += (totalDigits - 1) - fractDigits ; - XMLString::binToText(expValue, expStr, strLen, 10); + XMLString::binToText(expValue, expStr, strLen, 10, memMgr); *retPtr++ = chLatin_E; *retPtr = chNull; diff --git a/src/xercesc/util/XMLAbstractDoubleFloat.hpp b/src/xercesc/util/XMLAbstractDoubleFloat.hpp index fd4d10b881f54adbc30f914270d7cda3ea0e7a3d..32695a6c6d743b3757beb2ffeda870f73b218515 100644 --- a/src/xercesc/util/XMLAbstractDoubleFloat.hpp +++ b/src/xercesc/util/XMLAbstractDoubleFloat.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.17 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.16 2003/12/11 21:38:12 peiyongz * support for Canonical Representation for Datatype * @@ -232,7 +235,8 @@ protected: */ static int compareValues(const XMLAbstractDoubleFloat* const lValue - , const XMLAbstractDoubleFloat* const rValue); + , const XMLAbstractDoubleFloat* const rValue + , MemoryManager* const manager); // // to be overwritten by derived class @@ -254,7 +258,8 @@ private: inline bool isSpecialValue() const; static int compareSpecial(const XMLAbstractDoubleFloat* const specialValue - , const XMLAbstractDoubleFloat* const normalValue); + , const XMLAbstractDoubleFloat* const normalValue + , MemoryManager* const manager); void formatString(); diff --git a/src/xercesc/util/XMLBigDecimal.cpp b/src/xercesc/util/XMLBigDecimal.cpp index 683b901a51a44accf59daee170e89c88e706ea69..7ed67d838e8bdf038f9f3c652a210cbf1c6192db 100644 --- a/src/xercesc/util/XMLBigDecimal.cpp +++ b/src/xercesc/util/XMLBigDecimal.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.16 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.15 2003/12/11 21:38:12 peiyongz * support for Canonical Representation for Datatype * @@ -167,7 +170,7 @@ XMLBigDecimal::XMLBigDecimal(const XMLCh* const strValue, , fMemoryManager(manager) { if ((!strValue) || (!*strValue)) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_emptyString); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_emptyString, fMemoryManager); try { @@ -178,7 +181,7 @@ XMLBigDecimal::XMLBigDecimal(const XMLCh* const strValue, ); memcpy(fRawData, strValue, (fRawDataLen+1) * sizeof(XMLCh)); fIntVal = fRawData + fRawDataLen + 1; - parseDecimal(strValue, fIntVal, fSign, (int&) fTotalDigits, (int&) fScale); + parseDecimal(strValue, fIntVal, fSign, (int&) fTotalDigits, (int&) fScale, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -222,7 +225,7 @@ void XMLBigDecimal::setDecimalValue(const XMLCh* const strValue) } memcpy(fRawData, strValue, (valueLen + 1) * sizeof(XMLCh)); - parseDecimal(strValue, fIntVal, fSign, (int&) fTotalDigits, (int&) fScale); + parseDecimal(strValue, fIntVal, fSign, (int&) fTotalDigits, (int&) fScale, fMemoryManager); } @@ -242,7 +245,7 @@ XMLCh* XMLBigDecimal::getCanonicalRepresentation(const XMLCh* const rawD ArrayJanitor<XMLCh> janName(retBuf, memMgr); int sign, totalDigits, fractDigits; - XMLBigDecimal::parseDecimal(rawData, retBuf, sign, totalDigits, fractDigits); + XMLBigDecimal::parseDecimal(rawData, retBuf, sign, totalDigits, fractDigits, memMgr); //Extra space reserved in case strLen is zero int strLen = XMLString::stringLen(retBuf); @@ -301,7 +304,8 @@ void XMLBigDecimal::parseDecimal(const XMLCh* const toParse , XMLCh* const retBuffer , int& sign , int& totalDigits - , int& fractDigits) + , int& fractDigits + , MemoryManager* const manager) { //init retBuffer[0] = chNull; @@ -315,7 +319,7 @@ void XMLBigDecimal::parseDecimal(const XMLCh* const toParse // If we hit the end, then return failure if (!*startPtr) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_WSString); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_WSString, manager); // Strip tailing white space, if any. const XMLCh* endPtr = toParse + XMLString::stringLen(toParse); @@ -363,12 +367,12 @@ void XMLBigDecimal::parseDecimal(const XMLCh* const toParse continue; } else // '.' is allowed only once - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_2ManyDecPoint); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_2ManyDecPoint, manager); } // If not valid decimal digit, then an error if ((*startPtr < chDigit_0) || (*startPtr > chDigit_9)) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, manager); // copy over *retPtr++ = *startPtr++; @@ -396,10 +400,11 @@ void XMLBigDecimal::parseDecimal(const XMLCh* const toParse } int XMLBigDecimal::compareValues( const XMLBigDecimal* const lValue - , const XMLBigDecimal* const rValue) + , const XMLBigDecimal* const rValue + , MemoryManager* const manager) { if ((!lValue) || (!rValue) ) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_null_ptr); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_null_ptr, manager); return lValue->toCompare(*rValue); } diff --git a/src/xercesc/util/XMLBigDecimal.hpp b/src/xercesc/util/XMLBigDecimal.hpp index acfd91a44108b2cbd57f38eefd1f1d67491c39d3..33a8e8612983d47cc56060bc6317d328c69de688 100644 --- a/src/xercesc/util/XMLBigDecimal.hpp +++ b/src/xercesc/util/XMLBigDecimal.hpp @@ -92,7 +92,8 @@ public: ~XMLBigDecimal(); static int compareValues(const XMLBigDecimal* const lValue - , const XMLBigDecimal* const rValue); + , const XMLBigDecimal* const rValue + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); static XMLCh* getCanonicalRepresentation ( @@ -107,6 +108,7 @@ public: , int& sign , int& totalDigits , int& fractDigits + , MemoryManager* const manager ); /** @@ -145,6 +147,8 @@ public: */ void setDecimalValue(const XMLCh* const strValue); + MemoryManager* getMemoryManager() const; + /*** * Support for Serialization/De-serialization ***/ @@ -224,6 +228,11 @@ inline const XMLCh* XMLBigDecimal::getFormattedString() const return fRawData; } +inline MemoryManager* XMLBigDecimal::getMemoryManager() const +{ + return fMemoryManager; +} + // // The caller needs to de-allocate the memory allocated by this function // diff --git a/src/xercesc/util/XMLBigInteger.cpp b/src/xercesc/util/XMLBigInteger.cpp index 3d239137b88519f93ac65f0c15e4a005c2dd1a04..952eb0b34a7180bd488aa376d3addc49677dae6a 100644 --- a/src/xercesc/util/XMLBigInteger.cpp +++ b/src/xercesc/util/XMLBigInteger.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/12/11 21:38:12 peiyongz * support for Canonical Representation for Datatype * @@ -165,11 +168,12 @@ XMLCh* XMLBigInteger::getCanonicalRepresentation(const XMLCh* const rawD void XMLBigInteger::parseBigInteger(const XMLCh* const toConvert , XMLCh* const retBuffer - , int& signValue) + , int& signValue + , MemoryManager* const manager) { // If no string, then its a failure if ((!toConvert) || (!*toConvert)) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_emptyString); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_emptyString, manager); // // Note: in Java's BigInteger, it seems any leading and/or trailing @@ -183,7 +187,7 @@ void XMLBigInteger::parseBigInteger(const XMLCh* const toConvert startPtr++; if (!*startPtr) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_WSString); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_WSString, manager); // Start at the end and work back through any whitespace const XMLCh* endPtr = toConvert + XMLString::stringLen(toConvert); @@ -227,7 +231,7 @@ void XMLBigInteger::parseBigInteger(const XMLCh* const toConvert { // If not valid decimal digit, then an error if ((*startPtr < chDigit_0) || (*startPtr > chDigit_9)) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, manager); // copy over *retPtr = *startPtr; @@ -255,7 +259,7 @@ XMLBigInteger::XMLBigInteger(const XMLCh* const strValue, , fMemoryManager(manager) { if (!strValue) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_emptyString); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_emptyString, fMemoryManager); XMLCh* ret_value = (XMLCh*) fMemoryManager->allocate ( @@ -263,7 +267,7 @@ XMLBigInteger::XMLBigInteger(const XMLCh* const strValue, );//new XMLCh[XMLString::stringLen(strValue)+1]; ArrayJanitor<XMLCh> janName(ret_value, fMemoryManager); - parseBigInteger(strValue, ret_value, fSign); + parseBigInteger(strValue, ret_value, fSign, fMemoryManager); if (fSign == 0) fMagnitude = XMLString::replicate(XMLUni::fgZeroLenString, fMemoryManager); @@ -295,10 +299,11 @@ XMLBigInteger::XMLBigInteger(const XMLBigInteger& toCopy) * than rValue. */ int XMLBigInteger::compareValues(const XMLBigInteger* const lValue - , const XMLBigInteger* const rValue) + , const XMLBigInteger* const rValue + , MemoryManager* const manager) { if ((!lValue) || (!rValue) ) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_null_ptr); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_null_ptr, manager); int lSign = lValue->getSign(); int rSign = rValue->getSign(); @@ -400,7 +405,7 @@ void XMLBigInteger::divide(const unsigned int byteToShift) int XMLBigInteger::intValue() const { unsigned int retVal; - XMLString::textToBin(fMagnitude, retVal); + XMLString::textToBin(fMagnitude, retVal, fMemoryManager); return retVal * getSign(); } diff --git a/src/xercesc/util/XMLBigInteger.hpp b/src/xercesc/util/XMLBigInteger.hpp index 6c241ec3b5552b4f09c51f852799b4ee932b9eda..947926f47d208f10e330ba34e76cf523b868dbe5 100644 --- a/src/xercesc/util/XMLBigInteger.hpp +++ b/src/xercesc/util/XMLBigInteger.hpp @@ -100,10 +100,12 @@ public: static void parseBigInteger(const XMLCh* const toConvert , XMLCh* const retBuffer - , int& signValue); + , int& signValue + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); static int compareValues(const XMLBigInteger* const lValue - ,const XMLBigInteger* const rValue); + ,const XMLBigInteger* const rValue + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); void multiply(const unsigned int byteToShift); @@ -192,7 +194,7 @@ inline int XMLBigInteger::getTotalDigit() const inline bool XMLBigInteger::operator==(const XMLBigInteger& toCompare) const { - return ( compareValues(this, &toCompare) ==0 ? true : false); + return ( compareValues(this, &toCompare, fMemoryManager) ==0 ? true : false); } inline void XMLBigInteger::setSign(int newSign) @@ -211,7 +213,7 @@ inline XMLCh* XMLBigInteger::getRawData() const inline XMLCh* XMLBigInteger::toString() const { // Return data using global operator new - return XMLString::replicate(fRawData); + return XMLString::replicate(fRawData, fMemoryManager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/XMLChTranscoder.cpp b/src/xercesc/util/XMLChTranscoder.cpp index 864e1c68e790a2f5810a3f9f6356be60bc4b04eb..088cdbaabff9ce073b97f9c02c0656848cdb70d3 100644 --- a/src/xercesc/util/XMLChTranscoder.cpp +++ b/src/xercesc/util/XMLChTranscoder.cpp @@ -68,9 +68,10 @@ XERCES_CPP_NAMESPACE_BEGIN // XMLChTranscoder: Constructors and Destructor // --------------------------------------------------------------------------- XMLChTranscoder::XMLChTranscoder(const XMLCh* const encodingName - , const unsigned int blockSize) : + , const unsigned int blockSize + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) { } diff --git a/src/xercesc/util/XMLChTranscoder.hpp b/src/xercesc/util/XMLChTranscoder.hpp index ded3e52edbb0711b30c32acd797d353979dd7e12..12ca2478cda8bc911d00d17f8461bf4f70ba9a62 100644 --- a/src/xercesc/util/XMLChTranscoder.hpp +++ b/src/xercesc/util/XMLChTranscoder.hpp @@ -77,6 +77,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLChTranscoder(); diff --git a/src/xercesc/util/XMLDateTime.cpp b/src/xercesc/util/XMLDateTime.cpp index 7207804d639407c59615466bd472eb442aa7936e..b11d55bdc26dbdbd271967e6642f4aedc5f0cae7 100644 --- a/src/xercesc/util/XMLDateTime.cpp +++ b/src/xercesc/util/XMLDateTime.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.19 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.18 2003/12/16 22:48:52 peiyongz * exception thrown upon invalid number, thanks Gareth Reakes. * @@ -463,6 +466,7 @@ int XMLDateTime::compareResult(const XMLDateTime* const pDate1 int XMLDateTime::compareOrder(const XMLDateTime* const lValue , const XMLDateTime* const rValue) + //, MemoryManager* const memMgr) { // // If any of the them is not normalized() yet, @@ -493,9 +497,9 @@ int XMLDateTime::compareOrder(const XMLDateTime* const lValue // ctor and dtor // --------------------------------------------------------------------------- XMLDateTime::~XMLDateTime() -{ +{ if (fBuffer) - fMemoryManager->deallocate(fBuffer);//delete[] fBuffer; + fMemoryManager->deallocate(fBuffer);//delete[] fBuffer; } XMLDateTime::XMLDateTime(MemoryManager* const manager) @@ -593,9 +597,10 @@ void XMLDateTime::parseDateTime() //fStart is supposed to point to 'T' if (fBuffer[fStart++] != DATETIME_SEPARATOR) - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dt_missingT - , fBuffer); + , fBuffer + , fMemoryManager); getTime(); validateDateTime(); @@ -641,9 +646,10 @@ void XMLDateTime::parseDay() fBuffer[1] != DATE_SEPARATOR || fBuffer[2] != DATE_SEPARATOR ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_gDay_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } //initialize values @@ -656,9 +662,10 @@ void XMLDateTime::parseDay() int sign = findUTCSign(DAY_SIZE); if ( sign < 0 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_gDay_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } else { @@ -682,9 +689,10 @@ void XMLDateTime::parseMonth() if (fBuffer[0] != DATE_SEPARATOR || fBuffer[1] != DATE_SEPARATOR ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_gMth_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } //set constants @@ -709,9 +717,10 @@ void XMLDateTime::parseMonth() int sign = findUTCSign(fStart); if ( sign < 0 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_gMth_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } else { @@ -765,9 +774,10 @@ void XMLDateTime::parseMonthDay() fBuffer[1] != DATE_SEPARATOR || fBuffer[4] != DATE_SEPARATOR ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_gMthDay_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } @@ -781,9 +791,10 @@ void XMLDateTime::parseMonthDay() int sign = findUTCSign(MONTHDAY_SIZE); if ( sign<0 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_gMthDay_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } else { @@ -826,18 +837,20 @@ void XMLDateTime::parseDuration() if ( (c != DURATION_STARTER) && (c != chDash) ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_Start_dashP - , fBuffer); + , fBuffer + , fMemoryManager); } // 'P' must ALWAYS be present in either case if ( (c == chDash) && (fBuffer[fStart++]!= DURATION_STARTER )) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_noP - , fBuffer); + , fBuffer + , fMemoryManager); } // java code @@ -854,9 +867,10 @@ void XMLDateTime::parseDuration() // if (indexOf(fStart, fEnd, chDash) != NOT_FOUND) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_DashNotFirst - , fBuffer); + , fBuffer + , fMemoryManager); } //at least one number and designator must be seen after P @@ -899,9 +913,10 @@ void XMLDateTime::parseDuration() if ( (fEnd == endDate) && // 'T' absent (fStart != fEnd) ) // something after Day { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_inv_b4T - , fBuffer); + , fBuffer + , fMemoryManager); } if ( fEnd != endDate ) // 'T' present @@ -947,9 +962,10 @@ void XMLDateTime::parseDuration() */ if ( mlsec+1 == end ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_inv_seconds - ,fBuffer); + , fBuffer + , fMemoryManager); } fValue[Second] = negate * parseInt(fStart, mlsec); @@ -969,17 +985,19 @@ void XMLDateTime::parseDuration() if ( (fStart != fEnd) || fBuffer[--fStart] == DATETIME_SEPARATOR ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_NoTimeAfterT - ,fBuffer); + , fBuffer + , fMemoryManager); } } if ( !designator ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_dur_NoElementAtAll - , fBuffer); + , fBuffer + , fMemoryManager); } } @@ -1001,18 +1019,20 @@ void XMLDateTime::getDate() // Ensure enough chars in buffer if ( (fStart+YMD_MIN_SIZE) > fEnd) - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_date_incomplete - , fBuffer); + , fBuffer + , fMemoryManager); getYearMonth(); // Scan YearMonth and // fStart point to the next '-' if (fBuffer[fStart++] != DATE_SEPARATOR) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_date_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //("CCYY-MM must be followed by '-' sign"); } @@ -1036,18 +1056,20 @@ void XMLDateTime::getTime() // Ensure enough chars in buffer if ( (fStart+TIME_MIN_SIZE) > fEnd) - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_time_incomplete - , fBuffer); + , fBuffer + , fMemoryManager); //"Imcomplete Time Format" // check (fixed) format first if ((fBuffer[fStart + 2] != TIME_SEPARATOR) || (fBuffer[fStart + 5] != TIME_SEPARATOR) ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_time_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //("Error in parsing time" ); } @@ -1074,9 +1096,10 @@ void XMLDateTime::getTime() // make sure we have some thing between the '.' and fEnd if (fStart >= fEnd) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_ms_noDigit - , fBuffer); + , fBuffer + , fMemoryManager); //("ms shall be present once '.' is present" ); } @@ -1098,9 +1121,10 @@ void XMLDateTime::getTime() else if(sign == 0 || sign != fStart) { // seconds has more than 2 digits - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_min_invalid - , fBuffer); + , fBuffer + , fMemoryManager); } //parse UTC time zone (hh:mm) @@ -1121,9 +1145,10 @@ void XMLDateTime::getYearMonth() // Ensure enough chars in buffer if ( (fStart+YMONTH_MIN_SIZE) > fEnd) - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_ym_incomplete - , fBuffer); + , fBuffer + , fMemoryManager); //"Imcomplete YearMonth Format"; // skip the first leading '-' @@ -1134,9 +1159,10 @@ void XMLDateTime::getYearMonth() // int yearSeparator = indexOf(start, fEnd, DATE_SEPARATOR); if ( yearSeparator == NOT_FOUND) - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_ym_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //("Year separator is missing or misplaced"); fValue[CentYear] = parseIntYear(yearSeparator); @@ -1146,9 +1172,10 @@ void XMLDateTime::getYearMonth() //gonna check we have enough byte for month // if ((fStart + 2) > fEnd ) - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_ym_noMonth - , fBuffer); + , fBuffer + , fMemoryManager); //"no month in buffer" fValue[Month] = parseInt(fStart, yearSeparator + 3); @@ -1164,9 +1191,10 @@ void XMLDateTime::parseTimeZone() int sign = findUTCSign(fStart); if ( sign < 0 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_tz_noUTCsign - , fBuffer); + , fBuffer + , fMemoryManager); //("Error in month parsing"); } else @@ -1192,9 +1220,10 @@ void XMLDateTime::getTimeZone(const int sign) { if ((sign + 1) != fEnd ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_tz_stuffAfterZ - , fBuffer); + , fBuffer + , fMemoryManager); //"Error in parsing time zone"); } @@ -1210,9 +1239,10 @@ void XMLDateTime::getTimeZone(const int sign) if ( ( ( sign + TIMEZONE_SIZE + 1) != fEnd ) || ( fBuffer[sign + 3] != TIMEZONE_SEPARATOR ) ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_tz_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //("Error in parsing time zone"); } @@ -1289,18 +1319,20 @@ void XMLDateTime::validateDateTime() const // or reporting an error message should be sufficient? if ( fValue[CentYear] == 0 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_year_zero - , fBuffer); + , fBuffer + , fMemoryManager); //"The year \"0000\" is an illegal year value"); } if ( fValue[Month] < 1 || fValue[Month] > 12 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_mth_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //"The month must have values 1 to 12"); } @@ -1308,9 +1340,10 @@ void XMLDateTime::validateDateTime() const if ( fValue[Day] > maxDayInMonthFor( fValue[CentYear], fValue[Month]) || fValue[Day] == 0 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_day_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //"The day must have values 1 to 31"); } @@ -1321,9 +1354,10 @@ void XMLDateTime::validateDateTime() const (fValue[Second] !=0) || (fValue[MiliSecond] !=0)))) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_hour_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //("Hour must have values 0-23"); } @@ -1331,9 +1365,10 @@ void XMLDateTime::validateDateTime() const if ( fValue[Minute] < 0 || fValue[Minute] > 59 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_min_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //"Minute must have values 0-59"); } @@ -1341,9 +1376,10 @@ void XMLDateTime::validateDateTime() const if ( fValue[Second] < 0 || fValue[Second] > 60 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_second_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //"Second must have values 0-60"); } @@ -1351,18 +1387,20 @@ void XMLDateTime::validateDateTime() const if ( (abs(fTimeZone[hh]) > 14) || ((abs(fTimeZone[hh]) == 14) && (fTimeZone[mm] != 0)) ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_tz_hh_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //"Time zone should have range -14..+14"); } //validate time-zone minutes if ( abs(fTimeZone[mm]) > 59 ) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_min_invalid - , fBuffer); + , fBuffer + , fMemoryManager); //("Minute must have values 0-59"); } @@ -1409,12 +1447,12 @@ int XMLDateTime::parseInt(const int start, const int end) const for (int i=start; i < end; i++) { if (fBuffer[i] < chDigit_0 || fBuffer[i] > chDigit_9) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, fMemoryManager); retVal = (retVal * 10) + (unsigned int) (fBuffer[i] - chDigit_0); } - return (int) retVal;; + return (int) retVal; } // @@ -1432,17 +1470,19 @@ int XMLDateTime::parseIntYear(const int end) const int length = end - start; if (length < 4) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_year_tooShort - , fBuffer); + , fBuffer + , fMemoryManager); //"Year must have 'CCYY' format"); } else if (length > 4 && fBuffer[start] == chDigit_0) { - ThrowXML1(SchemaDateTimeException + ThrowXMLwithMemMgr1(SchemaDateTimeException , XMLExcepts::DateTime_year_leadingZero - , fBuffer); + , fBuffer + , fMemoryManager); //"Leading zeros are required if the year value would otherwise have fewer than four digits; // otherwise they are forbidden"); } diff --git a/src/xercesc/util/XMLDateTime.hpp b/src/xercesc/util/XMLDateTime.hpp index b3c63e0ebfad47a176f96ff929c93b9bc78b3bc1..2c6b2cae11b7b12ca08bcd6a13c4262a54f38f4a 100644 --- a/src/xercesc/util/XMLDateTime.hpp +++ b/src/xercesc/util/XMLDateTime.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.12 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/12/11 21:38:12 peiyongz * support for Canonical Representation for Datatype * @@ -218,6 +221,7 @@ public: static int compareOrder(const XMLDateTime* const , const XMLDateTime* const); + // , MemoryManager* const memMgr);// = XMLPlatformUtils::fgMemoryManager); /*** * Support for Serialization/De-serialization @@ -402,8 +406,9 @@ inline void XMLDateTime::assertBuffer() const if ( ( !fBuffer ) || ( fBuffer[0] == chNull ) ) { - ThrowXML(SchemaDateTimeException - , XMLExcepts::DateTime_Assert_Buffer_Fail); + ThrowXMLwithMemMgr(SchemaDateTimeException + , XMLExcepts::DateTime_Assert_Buffer_Fail + , fMemoryManager); } } diff --git a/src/xercesc/util/XMLDouble.cpp b/src/xercesc/util/XMLDouble.cpp index 86339b6af9cb3e8ff9a172573a05a73fa86471b3..73e04f3b72888eac066ea1cabc7e9aca960731e5 100644 --- a/src/xercesc/util/XMLDouble.cpp +++ b/src/xercesc/util/XMLDouble.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.13 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.12 2003/10/15 14:50:01 peiyongz * Bugzilla#22821: locale-sensitive function used to validate 'double' type, patch * from jsweeney@spss.com (Jeff Sweeney) @@ -187,7 +190,7 @@ void XMLDouble::checkBoundary(const XMLCh* const strValue) // check if all chars are valid char if ( (endptr - nptr) != strLen) { - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, getMemoryManager()); } // check if overflow/underflow occurs diff --git a/src/xercesc/util/XMLDouble.hpp b/src/xercesc/util/XMLDouble.hpp index 7a6dd4b2ed52f5982b47689d87a9552c97ba2c31..3357d1eb0dff621e3ccc72283498a578829f535a 100644 --- a/src/xercesc/util/XMLDouble.hpp +++ b/src/xercesc/util/XMLDouble.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/12/01 23:23:27 neilg * fix for bug 25118; thanks to Jeroen Witmond * @@ -180,7 +183,8 @@ inline int XMLDouble::compareValues(const XMLDouble* const lValue , const XMLDouble* const rValue) { return XMLAbstractDoubleFloat::compareValues((const XMLAbstractDoubleFloat* const) lValue, - (const XMLAbstractDoubleFloat* const) rValue ); + (const XMLAbstractDoubleFloat* const) rValue + , ((XMLAbstractDoubleFloat*)lValue)->getMemoryManager()); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/XMLEBCDICTranscoder.cpp b/src/xercesc/util/XMLEBCDICTranscoder.cpp index bbc9aa6b1d0fbf100997308be351e921af56eac6..f76b726081140a47b8109d06b07274503716e0d8 100644 --- a/src/xercesc/util/XMLEBCDICTranscoder.cpp +++ b/src/xercesc/util/XMLEBCDICTranscoder.cpp @@ -221,7 +221,8 @@ XMLCh XMLEBCDICTranscoder::xlatThisOne(const XMLByte toXlat) // XMLEBCDICTranscoder: Constructors and Destructor // --------------------------------------------------------------------------- XMLEBCDICTranscoder::XMLEBCDICTranscoder(const XMLCh* const encodingName - , const unsigned int blockSize) : + , const unsigned int blockSize + , MemoryManager* const manager) : XML256TableTranscoder ( @@ -230,6 +231,7 @@ XMLEBCDICTranscoder::XMLEBCDICTranscoder(const XMLCh* const encodingName , gFromTable , gToTable , gToTableSz + , manager ) { } diff --git a/src/xercesc/util/XMLEBCDICTranscoder.hpp b/src/xercesc/util/XMLEBCDICTranscoder.hpp index 176b5dd430f6381d6856864ad5ccc4c551652a72..3cb9a98bf49fe30eb62941a8cb6021cc10ac0526 100644 --- a/src/xercesc/util/XMLEBCDICTranscoder.hpp +++ b/src/xercesc/util/XMLEBCDICTranscoder.hpp @@ -88,6 +88,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLEBCDICTranscoder(); diff --git a/src/xercesc/util/XMLException.cpp b/src/xercesc/util/XMLException.cpp index 35087675fd94484c5785e59cd7a99fc73bed8ce6..7433d1cbab462984d1ace325ce5d9612d00c375c 100644 --- a/src/xercesc/util/XMLException.cpp +++ b/src/xercesc/util/XMLException.cpp @@ -161,8 +161,8 @@ static XMLMsgLoader& gGetMsgLoader() // --------------------------------------------------------------------------- XMLException::~XMLException() { - XMLPlatformUtils::fgMemoryManager->deallocate(fMsg); - XMLPlatformUtils::fgMemoryManager->deallocate(fSrcFile); + fMemoryManager->deallocate(fMsg); + fMemoryManager->deallocate(fSrcFile); } @@ -186,19 +186,24 @@ XMLException::XMLException() : , fSrcFile(0) , fSrcLine(0) , fMsg(0) + , fMemoryManager(0) { } XMLException::XMLException( const char* const srcFile - , const unsigned int srcLine) : + , const unsigned int srcLine + , MemoryManager* const memoryManager) : fCode(XMLExcepts::NoError) , fSrcFile(0) , fSrcLine(srcLine) , fMsg(0) + , fMemoryManager(memoryManager) { - fSrcFile = XMLString::replicate(srcFile, XMLPlatformUtils::fgMemoryManager); + if (!memoryManager) + fMemoryManager = XMLPlatformUtils::fgMemoryManager; + fSrcFile = XMLString::replicate(srcFile, fMemoryManager); } @@ -207,13 +212,14 @@ XMLException::XMLException(const XMLException& toCopy) : fCode(toCopy.fCode) , fSrcFile(0) , fSrcLine(toCopy.fSrcLine) - , fMsg(XMLString::replicate(toCopy.fMsg, XMLPlatformUtils::fgMemoryManager)) + , fMemoryManager(toCopy.fMemoryManager) + , fMsg(XMLString::replicate(toCopy.fMsg, fMemoryManager)) { if (toCopy.fSrcFile) { fSrcFile = XMLString::replicate ( toCopy.fSrcFile - , XMLPlatformUtils::fgMemoryManager + , fMemoryManager ); } } @@ -223,9 +229,10 @@ XMLException& XMLException::operator=(const XMLException& toAssign) { if (this != &toAssign) { - XMLPlatformUtils::fgMemoryManager->deallocate(fSrcFile); + fMemoryManager = toAssign.fMemoryManager; + fMemoryManager->deallocate(fSrcFile); fSrcFile = 0; - XMLPlatformUtils::fgMemoryManager->deallocate(fMsg); + fMemoryManager->deallocate(fMsg); fMsg = 0; fSrcLine = toAssign.fSrcLine; @@ -235,7 +242,7 @@ XMLException& XMLException::operator=(const XMLException& toAssign) fMsg = XMLString::replicate ( toAssign.fMsg - , XMLPlatformUtils::fgMemoryManager + , fMemoryManager ); } @@ -243,7 +250,7 @@ XMLException& XMLException::operator=(const XMLException& toAssign) fSrcFile = XMLString::replicate ( toAssign.fSrcFile - , XMLPlatformUtils::fgMemoryManager + , fMemoryManager ); } } @@ -270,13 +277,13 @@ void XMLException::loadExceptText(const XMLExcepts::Codes toLoad) fMsg = XMLString::replicate ( gDefErrMsg - , XMLPlatformUtils::fgMemoryManager + , fMemoryManager ); return; } // We got the text so replicate it into the message member - fMsg = XMLString::replicate(errText, XMLPlatformUtils::fgMemoryManager); + fMsg = XMLString::replicate(errText, fMemoryManager); } @@ -300,13 +307,13 @@ XMLException::loadExceptText(const XMLExcepts::Codes toLoad fMsg = XMLString::replicate ( gDefErrMsg - , XMLPlatformUtils::fgMemoryManager + , fMemoryManager ); return; } // We got the text so replicate it into the message member - fMsg = XMLString::replicate(errText, XMLPlatformUtils::fgMemoryManager); + fMsg = XMLString::replicate(errText, fMemoryManager); } @@ -325,18 +332,18 @@ XMLException::loadExceptText(const XMLExcepts::Codes toLoad XMLCh errText[msgSize + 1]; // load the text - if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize, text1, text2, text3, text4)) + if (!gGetMsgLoader().loadMsg(toLoad, errText, msgSize, text1, text2, text3, text4, fMemoryManager)) { fMsg = XMLString::replicate ( gDefErrMsg - , XMLPlatformUtils::fgMemoryManager + , fMemoryManager ); return; } // We got the text so replicate it into the message member - fMsg = XMLString::replicate(errText, XMLPlatformUtils::fgMemoryManager); + fMsg = XMLString::replicate(errText, fMemoryManager); } // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/XMLException.hpp b/src/xercesc/util/XMLException.hpp index b6b250a986f24e47a066325188a110c9834d7981..9b02211e62710295e2675185eb1aaa8aa2b5b78c 100644 --- a/src/xercesc/util/XMLException.hpp +++ b/src/xercesc/util/XMLException.hpp @@ -118,7 +118,7 @@ public: // of IE 5.0. // ----------------------------------------------------------------------- XMLException(); - XMLException(const char* const srcFile, const unsigned int srcLine); + XMLException(const char* const srcFile, const unsigned int srcLine, MemoryManager* const memoryManager = 0); XMLException(const XMLException& toCopy); XMLException& operator=(const XMLException& toAssign); @@ -170,10 +170,13 @@ private : // fMsg // The loaded message text for this exception. // ----------------------------------------------------------------------- - XMLExcepts::Codes fCode; - char* fSrcFile; - unsigned int fSrcLine; - XMLCh* fMsg; + XMLExcepts::Codes fCode; + char* fSrcFile; + unsigned int fSrcLine; + XMLCh* fMsg; + +protected: + MemoryManager* fMemoryManager; }; // --------------------------------------------------------------------------- @@ -224,8 +227,9 @@ public: \ \ theType(const char* const srcFile \ , const unsigned int srcLine \ - , const XMLExcepts::Codes toThrow) : \ - XMLException(srcFile, srcLine) \ + , const XMLExcepts::Codes toThrow \ + , MemoryManager* memoryManager = 0) : \ + XMLException(srcFile, srcLine, memoryManager) \ { \ loadExceptText(toThrow); \ } \ @@ -238,24 +242,26 @@ public: \ \ theType(const char* const srcFile \ , const unsigned int srcLine \ - , const XMLExcepts::Codes toThrow \ + , const XMLExcepts::Codes toThrow \ , const XMLCh* const text1 \ , const XMLCh* const text2 = 0 \ , const XMLCh* const text3 = 0 \ - , const XMLCh* const text4 = 0) : \ - XMLException(srcFile, srcLine) \ + , const XMLCh* const text4 = 0 \ + , MemoryManager* memoryManager = 0) : \ + XMLException(srcFile, srcLine, memoryManager) \ { \ loadExceptText(toThrow, text1, text2, text3, text4); \ } \ \ theType(const char* const srcFile \ , const unsigned int srcLine \ - , const XMLExcepts::Codes toThrow \ + , const XMLExcepts::Codes toThrow \ , const char* const text1 \ , const char* const text2 = 0 \ , const char* const text3 = 0 \ - , const char* const text4 = 0) : \ - XMLException(srcFile, srcLine) \ + , const char* const text4 = 0 \ + , MemoryManager* memoryManager = 0) : \ + XMLException(srcFile, srcLine, memoryManager) \ { \ loadExceptText(toThrow, text1, text2, text3, text4); \ } \ @@ -270,7 +276,7 @@ public: \ \ virtual XMLException* duplicate() const \ { \ - return new theType(*this); \ + return new (fMemoryManager) theType(*this); \ } \ \ virtual const XMLCh* getType() const \ @@ -289,16 +295,27 @@ private : \ // to make sure that source code line/col info is stored correctly, and to // give flexibility for other stuff in the future. // --------------------------------------------------------------------------- + #define ThrowXML(type,code) throw type(__FILE__, __LINE__, code) -#define ThrowXML1(type,code,p1) throw type(__FILE__, __LINE__, code, p1) +#define ThrowXML1(type,code,p1) throw type(__FILE__, __LINE__, code, p1, 0, 0, 0) -#define ThrowXML2(type,code,p1,p2) throw type(__FILE__, __LINE__, code, p1, p2) +#define ThrowXML2(type,code,p1,p2) throw type(__FILE__, __LINE__, code, p1, p2, 0, 0) -#define ThrowXML3(type,code,p1,p2,p3) throw type(__FILE__, __LINE__, code, p1, p2, p3) +#define ThrowXML3(type,code,p1,p2,p3) throw type(__FILE__, __LINE__, code, p1, p2, p3, 0) #define ThrowXML4(type,code,p1,p2,p3,p4) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4) +#define ThrowXMLwithMemMgr(type,code,memMgr) throw type(__FILE__, __LINE__, code, memMgr) + +#define ThrowXMLwithMemMgr1(type,code,p1,memMgr) throw type(__FILE__, __LINE__, code, p1, 0, 0, 0, memMgr) + +#define ThrowXMLwithMemMgr2(type,code,p1,p2,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, 0, 0, memMgr) + +#define ThrowXMLwithMemMgr3(type,code,p1,p2,p3,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, p3, 0, memMgr) + +#define ThrowXMLwithMemMgr4(type,code,p1,p2,p3,p4,memMgr) throw type(__FILE__, __LINE__, code, p1, p2, p3, p4, memMgr) + XERCES_CPP_NAMESPACE_END #endif diff --git a/src/xercesc/util/XMLFloat.cpp b/src/xercesc/util/XMLFloat.cpp index 3f4094553677ae9d0129e11a9d21f0391b63f068..215a8ce851deda4cf28234eb1443054fde8da8d7 100644 --- a/src/xercesc/util/XMLFloat.cpp +++ b/src/xercesc/util/XMLFloat.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.14 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.13 2003/10/15 14:50:01 peiyongz * Bugzilla#22821: locale-sensitive function used to validate 'double' type, patch * from jsweeney@spss.com (Jeff Sweeney) @@ -182,7 +185,7 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) // check if all chars are valid char if ( (endptr - nptr) != strLen) { - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, getMemoryManager()); } // check if overflow/underflow occurs diff --git a/src/xercesc/util/XMLFloat.hpp b/src/xercesc/util/XMLFloat.hpp index 2f88ef5f2afa44f69de66c15bb155053c3baf4a0..4f1b1748df61aaf26e12318e5578ce36505d2d3a 100644 --- a/src/xercesc/util/XMLFloat.hpp +++ b/src/xercesc/util/XMLFloat.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/12/01 23:23:27 neilg * fix for bug 25118; thanks to Jeroen Witmond * @@ -174,7 +177,8 @@ inline int XMLFloat::compareValues(const XMLFloat* const lValue , const XMLFloat* const rValue) { return XMLAbstractDoubleFloat::compareValues((const XMLAbstractDoubleFloat* const) lValue, - (const XMLAbstractDoubleFloat* const) rValue ); + (const XMLAbstractDoubleFloat* const) rValue + , ((XMLAbstractDoubleFloat*)lValue)->getMemoryManager()); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/XMLIBM1047Transcoder.cpp b/src/xercesc/util/XMLIBM1047Transcoder.cpp index c91f7059afa360b5fd34cc594d355468d3b72abb..a8962559071b8e2d81fdc25542db9637eb220e91 100644 --- a/src/xercesc/util/XMLIBM1047Transcoder.cpp +++ b/src/xercesc/util/XMLIBM1047Transcoder.cpp @@ -220,8 +220,9 @@ XMLCh XMLIBM1047Transcoder::xlatThisOne(const XMLByte toXlat) // --------------------------------------------------------------------------- // XMLIBM1047Transcoder: Constructors and Destructor // --------------------------------------------------------------------------- -XMLIBM1047Transcoder::XMLIBM1047Transcoder(const XMLCh* const encodingName - , const unsigned int blockSize) : +XMLIBM1047Transcoder::XMLIBM1047Transcoder(const XMLCh* const encodingName + , const unsigned int blockSize + , MemoryManager* const manager) : XML256TableTranscoder ( @@ -230,6 +231,7 @@ XMLIBM1047Transcoder::XMLIBM1047Transcoder(const XMLCh* const encodingName , gFromTable , gToTable , gToTableSz + , manager ) { } diff --git a/src/xercesc/util/XMLIBM1047Transcoder.hpp b/src/xercesc/util/XMLIBM1047Transcoder.hpp index a1f92867f7b19f12c034be352207e0a641d9ca5f..508a2cd91defa6e0e307fe2093315528064bbc70 100644 --- a/src/xercesc/util/XMLIBM1047Transcoder.hpp +++ b/src/xercesc/util/XMLIBM1047Transcoder.hpp @@ -87,6 +87,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLIBM1047Transcoder(); diff --git a/src/xercesc/util/XMLIBM1140Transcoder.cpp b/src/xercesc/util/XMLIBM1140Transcoder.cpp index c70aa7a8f6e7de5b740db37e4b1a8bb1606717f7..abcbc298ae7bb2d1198251eb10d917df2d9044e4 100644 --- a/src/xercesc/util/XMLIBM1140Transcoder.cpp +++ b/src/xercesc/util/XMLIBM1140Transcoder.cpp @@ -222,8 +222,9 @@ XMLCh XMLIBM1140Transcoder::xlatThisOne(const XMLByte toXlat) // --------------------------------------------------------------------------- // XMLIBM1140Transcoder: Constructors and Destructor // --------------------------------------------------------------------------- -XMLIBM1140Transcoder::XMLIBM1140Transcoder( const XMLCh* const encodingName - , const unsigned int blockSize) : +XMLIBM1140Transcoder::XMLIBM1140Transcoder( const XMLCh* const encodingName + , const unsigned int blockSize + , MemoryManager* const manager) : XML256TableTranscoder ( encodingName @@ -231,6 +232,7 @@ XMLIBM1140Transcoder::XMLIBM1140Transcoder( const XMLCh* const encodingName , gFromTable , gToTable , gToTableSz + , manager ) { } diff --git a/src/xercesc/util/XMLIBM1140Transcoder.hpp b/src/xercesc/util/XMLIBM1140Transcoder.hpp index f0fd1d0d92192b93b081acefc1059e4d3fcabbf9..fb745d32d9402feab07ec7ff34037ab614a2bc73 100644 --- a/src/xercesc/util/XMLIBM1140Transcoder.hpp +++ b/src/xercesc/util/XMLIBM1140Transcoder.hpp @@ -86,6 +86,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLIBM1140Transcoder(); diff --git a/src/xercesc/util/XMLMsgLoader.hpp b/src/xercesc/util/XMLMsgLoader.hpp index caada727bde5a9eb04eecd534c7fca3a22913398..c51032757c640f377c4e7a68c9c544a1995ebacc 100644 --- a/src/xercesc/util/XMLMsgLoader.hpp +++ b/src/xercesc/util/XMLMsgLoader.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/05/15 19:07:46 knoaman * Partial implementation of the configurable memory manager. * @@ -171,6 +174,7 @@ public : , const char* const repText2 = 0 , const char* const repText3 = 0 , const char* const repText4 = 0 + , MemoryManager* const manager = 0 ) = 0; /** @name Locale Handling */ diff --git a/src/xercesc/util/XMLString.cpp b/src/xercesc/util/XMLString.cpp index 4ac3a0f9d3c7abc412b59863a30454654a169648..29d6bb47f8cc65a3c5167ea4594826698a6ae94d 100644 --- a/src/xercesc/util/XMLString.cpp +++ b/src/xercesc/util/XMLString.cpp @@ -105,7 +105,8 @@ MemoryManager* XMLString::fgMemoryManager = 0; void XMLString::binToText( const unsigned long toFormat , char* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { static const char digitList[16] = { @@ -114,7 +115,7 @@ void XMLString::binToText( const unsigned long toFormat }; if (!maxChars) - ThrowXML(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf, manager); // Handle special case if (!toFormat) @@ -173,12 +174,12 @@ void XMLString::binToText( const unsigned long toFormat } else { - ThrowXML(RuntimeException, XMLExcepts::Str_UnknownRadix); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Str_UnknownRadix, manager); } // See if have enough room in the caller's buffer if (tmpIndex > maxChars) - ThrowXML(IllegalArgumentException, XMLExcepts::Str_TargetBufTooSmall); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Str_TargetBufTooSmall, manager); // Reverse the tmp buffer into the caller's buffer unsigned int outIndex = 0; @@ -192,16 +193,18 @@ void XMLString::binToText( const unsigned long toFormat void XMLString::binToText( const unsigned int toFormat , char* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { // Just call the unsigned long version - binToText((unsigned long)toFormat, toFill, maxChars, radix); + binToText((unsigned long)toFormat, toFill, maxChars, radix, manager); } void XMLString::binToText( const long toFormat , char* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { // // If its negative, then put a negative sign into the output and flip @@ -221,13 +224,14 @@ void XMLString::binToText( const long toFormat } // And now call the unsigned long version - binToText(actualVal, &toFill[startInd], maxChars, radix); + binToText(actualVal, &toFill[startInd], maxChars, radix, manager); } void XMLString::binToText( const int toFormat , char* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { // // If its negative, then put a negative sign into the output and flip @@ -247,7 +251,7 @@ void XMLString::binToText( const int toFormat } // And now call the unsigned long version - binToText(actualVal, &toFill[startInd], maxChars, radix); + binToText(actualVal, &toFill[startInd], maxChars, radix, manager); } @@ -325,10 +329,11 @@ void XMLString::cut( XMLCh* const toCutFrom unsigned int XMLString::hash( const char* const tohash - , const unsigned int hashModulus) -{ + , const unsigned int hashModulus + , MemoryManager* const manager) +{ if (!hashModulus) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus, manager); unsigned int hashVal = 0; if (tohash) { @@ -360,13 +365,14 @@ int XMLString::indexOf(const char* const toSearch, const char ch) int XMLString::indexOf( const char* const toSearch , const char ch - , const unsigned int fromIndex) + , const unsigned int fromIndex + , MemoryManager* const manager) { const unsigned int len = strlen(toSearch); // Make sure the start index is within the XMLString bounds if ((int)fromIndex > len-1) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager); for (unsigned int i = fromIndex; i < len; i++) { @@ -389,13 +395,14 @@ int XMLString::lastIndexOf(const char* const toSearch, const char ch) int XMLString::lastIndexOf( const char* const toSearch , const char ch - , const unsigned int fromIndex) + , const unsigned int fromIndex + , MemoryManager* const manager) { const int len = strlen(toSearch); // Make sure the start index is within the XMLString bounds if ((int)fromIndex > len-1) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager); for (int i = (int)fromIndex; i >= 0; i--) { @@ -636,17 +643,18 @@ void XMLString::trim(char* const toTrim) void XMLString::subString(char* const targetStr, const char* const srcStr - , const int startIndex, const int endIndex) + , const int startIndex, const int endIndex + , MemoryManager* const manager) { if (targetStr == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf, manager); const int srcLen = strlen(srcStr); const int copySize = endIndex - startIndex; // Make sure the start index is within the XMLString bounds if ( startIndex < 0 || startIndex > endIndex || endIndex > srcLen) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager); for (int i= startIndex; i < endIndex; i++) { targetStr[i-startIndex] = srcStr[i]; @@ -756,7 +764,8 @@ bool XMLString::isAllWhiteSpace(const XMLCh* const toCheck) void XMLString::binToText( const unsigned long toFormat , XMLCh* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { static const XMLCh digitList[16] = { @@ -766,7 +775,7 @@ void XMLString::binToText( const unsigned long toFormat }; if (!maxChars) - ThrowXML(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf, manager); // Handle special case if (!toFormat) @@ -825,12 +834,12 @@ void XMLString::binToText( const unsigned long toFormat } else { - ThrowXML(RuntimeException, XMLExcepts::Str_UnknownRadix); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Str_UnknownRadix, manager); } // See if have enough room in the caller's buffer if (tmpIndex > maxChars) - ThrowXML(IllegalArgumentException, XMLExcepts::Str_TargetBufTooSmall); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Str_TargetBufTooSmall, manager); // Reverse the tmp buffer into the caller's buffer unsigned int outIndex = 0; @@ -844,16 +853,18 @@ void XMLString::binToText( const unsigned long toFormat void XMLString::binToText( const unsigned int toFormat , XMLCh* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { // Just call the unsigned long version - binToText((unsigned long)toFormat, toFill, maxChars, radix); + binToText((unsigned long)toFormat, toFill, maxChars, radix, manager); } void XMLString::binToText( const long toFormat , XMLCh* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { // // If its negative, then put a negative sign into the output and flip @@ -873,13 +884,14 @@ void XMLString::binToText( const long toFormat } // And now call the unsigned long version - binToText(actualVal, &toFill[startInd], maxChars, radix); + binToText(actualVal, &toFill[startInd], maxChars, radix, manager); } void XMLString::binToText( const int toFormat , XMLCh* const toFill , const unsigned int maxChars - , const unsigned int radix) + , const unsigned int radix + , MemoryManager* const manager) { // // If its negative, then put a negative sign into the output and flip @@ -899,7 +911,7 @@ void XMLString::binToText( const int toFormat } // And now call the unsigned long version - binToText(actualVal, &toFill[startInd], maxChars, radix); + binToText(actualVal, &toFill[startInd], maxChars, radix, manager); } @@ -1071,10 +1083,11 @@ bool XMLString::copyNString( XMLCh* const target unsigned int XMLString::hash( const XMLCh* const tohash - , const unsigned int hashModulus) -{ + , const unsigned int hashModulus + , MemoryManager* const manager) +{ if (!hashModulus) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus, manager); unsigned int hashVal = 0; if (tohash) { @@ -1165,10 +1178,11 @@ int XMLString::patternMatch( const XMLCh* const toSearch unsigned int XMLString::hashN( const XMLCh* const tohash , const unsigned int n - , const unsigned int hashModulus) + , const unsigned int hashModulus + , MemoryManager* const manager) { if (!hashModulus) - ThrowXML(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Pool_ZeroModulus, manager); unsigned int hashVal = 0; if (tohash) { @@ -1206,13 +1220,14 @@ int XMLString::indexOf(const XMLCh* const toSearch, const XMLCh ch) int XMLString::indexOf( const XMLCh* const toSearch , const XMLCh ch - , const unsigned int fromIndex) + , const unsigned int fromIndex + , MemoryManager* const manager) { const int len = stringLen(toSearch); // Make sure the start index is within the XMLString bounds if ((int)fromIndex > len-1) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager); for (int i = (int)fromIndex; i < len; i++) { @@ -1236,11 +1251,12 @@ int XMLString::lastIndexOf(const XMLCh ch, int XMLString::lastIndexOf( const XMLCh* const toSearch , const XMLCh ch - , const unsigned int fromIndex) + , const unsigned int fromIndex + , MemoryManager* const manager) { const int len = stringLen(toSearch); if ((int)fromIndex > len-1) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager); for (int i = (int)fromIndex; i >= 0; i--) { @@ -1282,7 +1298,8 @@ XMLString::makeUName(const XMLCh* const pszURI, const XMLCh* const pszName) } -bool XMLString::textToBin(const XMLCh* const toConvert, unsigned int& toFill) +bool XMLString::textToBin(const XMLCh* const toConvert, unsigned int& toFill + , MemoryManager* const manager) { toFill = 0; @@ -1290,8 +1307,8 @@ bool XMLString::textToBin(const XMLCh* const toConvert, unsigned int& toFill) if ((!toConvert) || (!*toConvert)) return false; - XMLCh* trimmedStr = XMLString::replicate(toConvert); - ArrayJanitor<XMLCh> jan1(trimmedStr); + XMLCh* trimmedStr = XMLString::replicate(toConvert, manager); + ArrayJanitor<XMLCh> jan1(trimmedStr, manager); XMLString::trim(trimmedStr); unsigned int trimmedStrLen = XMLString::stringLen(trimmedStr); @@ -1299,14 +1316,14 @@ bool XMLString::textToBin(const XMLCh* const toConvert, unsigned int& toFill) return false; // we don't allow '-' sign - if (XMLString::indexOf(trimmedStr, chDash, 0) != -1) + if (XMLString::indexOf(trimmedStr, chDash, 0, manager) != -1) return false; //the errno set by previous run is NOT automatically cleared errno = 0; - char *nptr = XMLString::transcode(trimmedStr); - ArrayJanitor<char> jan2(nptr); + char *nptr = XMLString::transcode(trimmedStr, manager); + ArrayJanitor<char> jan2(nptr, manager); char *endptr; // @@ -1323,36 +1340,37 @@ bool XMLString::textToBin(const XMLCh* const toConvert, unsigned int& toFill) return true; } -int XMLString::parseInt(const XMLCh* const toConvert) +int XMLString::parseInt(const XMLCh* const toConvert + , MemoryManager* const manager) { // If no string, or empty string, then it is a failure if ((!toConvert) || (!*toConvert)) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_null_ptr); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_null_ptr, manager); - XMLCh* trimmedStr = XMLString::replicate(toConvert); - ArrayJanitor<XMLCh> jan1(trimmedStr); + XMLCh* trimmedStr = XMLString::replicate(toConvert, manager); + ArrayJanitor<XMLCh> jan1(trimmedStr, manager); XMLString::trim(trimmedStr); unsigned int trimmedStrLen = XMLString::stringLen(trimmedStr); if ( !trimmedStrLen ) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_null_ptr); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_null_ptr, manager); //the errno set by previous run is NOT automatically cleared errno = 0; - char *nptr = XMLString::transcode(trimmedStr); - ArrayJanitor<char> jan2(nptr); + char *nptr = XMLString::transcode(trimmedStr, manager); + ArrayJanitor<char> jan2(nptr, manager); char *endptr; long retVal = strtol(nptr, &endptr, 10); // check if all chars are valid char if ( (endptr - nptr) != (int) trimmedStrLen) - ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, manager); // check if overflow/underflow occurs if (errno == ERANGE) - ThrowXML(NumberFormatException, XMLExcepts::Str_ConvertOverflow); + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::Str_ConvertOverflow, manager); // // REVISIT: conversion of (long) to (int) @@ -1409,20 +1427,21 @@ void XMLString::lowerCase(XMLCh* const toLowerCase) void XMLString::subString(XMLCh* const targetStr, const XMLCh* const srcStr - , const int startIndex, const int endIndex) + , const int startIndex, const int endIndex + , MemoryManager* const manager) { //if (startIndex < 0 || endIndex < 0) - // ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_NegativeIndex); + // ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_NegativeIndex); if (targetStr == 0) - ThrowXML(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Str_ZeroSizedTargetBuf, manager); const int srcLen = stringLen(srcStr); const int copySize = endIndex - startIndex; // Make sure the start index is within the XMLString bounds if ( startIndex < 0 || startIndex > endIndex || endIndex > srcLen) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager); for (int i= startIndex; i < endIndex; i++) { targetStr[i-startIndex] = srcStr[i]; @@ -1431,13 +1450,14 @@ void XMLString::subString(XMLCh* const targetStr, const XMLCh* const srcStr targetStr[copySize] = 0; } -BaseRefVectorOf<XMLCh>* XMLString::tokenizeString(const XMLCh* const tokenizeSrc) +BaseRefVectorOf<XMLCh>* XMLString::tokenizeString(const XMLCh* const tokenizeSrc + , MemoryManager* const manager) { - XMLCh* orgText = replicate(tokenizeSrc, fgMemoryManager); - ArrayJanitor<XMLCh> janText(orgText, fgMemoryManager); + XMLCh* orgText = replicate(tokenizeSrc, manager); + ArrayJanitor<XMLCh> janText(orgText, manager); XMLCh* tokenizeStr = orgText; - RefArrayVectorOf<XMLCh>* tokenStack = new RefArrayVectorOf<XMLCh>(16, true); + RefArrayVectorOf<XMLCh>* tokenStack = new (manager) RefArrayVectorOf<XMLCh>(16, true, manager); unsigned int len = stringLen(tokenizeStr); unsigned int skip; @@ -1465,12 +1485,12 @@ BaseRefVectorOf<XMLCh>* XMLString::tokenizeString(const XMLCh* const tokenizeSrc // these tokens are adopted in the RefVector and will be deleted // when the vector is deleted by the caller - XMLCh* token = (XMLCh*) fgMemoryManager->allocate + XMLCh* token = (XMLCh*) manager->allocate ( (skip+1-index) * sizeof(XMLCh) );//new XMLCh[skip+1-index]; - XMLString::subString(token, tokenizeStr, index, skip); + XMLString::subString(token, tokenizeStr, index, skip, manager); tokenStack->addElement(token); index = skip; } @@ -1708,13 +1728,14 @@ void XMLString::collapseWS(XMLCh* const toConvert) // // remove whitespace // -void XMLString::removeWS(XMLCh* const toConvert) +void XMLString::removeWS(XMLCh* const toConvert + , MemoryManager* const manager) { // If no string, then its a failure if (( !toConvert ) || ( !*toConvert )) return; - XMLCh* retBuf = (XMLCh*) fgMemoryManager->allocate + XMLCh* retBuf = (XMLCh*) manager->allocate ( (XMLString::stringLen(toConvert) + 1) * sizeof(XMLCh) );//new XMLCh[ XMLString::stringLen(toConvert) + 1]; @@ -1737,7 +1758,7 @@ void XMLString::removeWS(XMLCh* const toConvert) *retPtr = chNull; XMLString::moveChars(toConvert, retBuf, stringLen(retBuf)+1); //copy the last chNull as well - fgMemoryManager->deallocate(retBuf);//delete[] retBuf; + manager->deallocate(retBuf);//delete[] retBuf; return; } diff --git a/src/xercesc/util/XMLString.hpp b/src/xercesc/util/XMLString.hpp index 4e3702bd0d0e52b5d5bc3ac15d6fc21f5e771752..4782e836f061f0f6f191ce3c18c923958ae95043 100644 --- a/src/xercesc/util/XMLString.hpp +++ b/src/xercesc/util/XMLString.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.21 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.20 2003/10/02 11:07:26 gareth * Made the non-memory manager version of replicate not inlined. Updated the documentation for the memory manager versions so they don't tell you you should call release. * @@ -619,6 +622,7 @@ public: ( const char* const toHash , const unsigned int hashModulus + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Hashes a string given a modulus @@ -631,6 +635,7 @@ public: ( const XMLCh* const toHash , const unsigned int hashModulus + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Hashes a string given a modulus taking a maximum number of characters @@ -647,6 +652,7 @@ public: const XMLCh* const toHash , const unsigned int numChars , const unsigned int hashModulus + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -688,6 +694,7 @@ public: const char* const toSearch , const char chToFind , const unsigned int fromIndex + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -705,6 +712,7 @@ public: const XMLCh* const toSearch , const XMLCh chToFind , const unsigned int fromIndex + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -758,6 +766,7 @@ public: const char* const toSearch , const char chToFind , const unsigned int fromIndex + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -775,6 +784,7 @@ public: const XMLCh* const toSearch , const XMLCh ch , const unsigned int fromIndex + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -810,6 +820,7 @@ public: , const char* const srcStr , const int startIndex , const int endIndex + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Create a substring of a givend string. The substring begins at the @@ -826,6 +837,7 @@ public: , const XMLCh* const srcStr , const int startIndex , const int endIndex + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -843,8 +855,6 @@ public: */ static char* replicate(const char* const toRep); - - /** Replicates a string * NOTE: The returned buffer is allocated with the MemoryManager. It is the * responsibility of the caller to delete it when not longer needed. @@ -867,7 +877,6 @@ public: */ static XMLCh* replicate(const XMLCh* const toRep); - /** Replicates a string * NOTE: The returned buffer is allocated with the MemoryManager. It is the * responsibility of the caller to delete it when not longer needed. @@ -1101,6 +1110,7 @@ public: , char* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1119,6 +1129,7 @@ public: , XMLCh* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1137,6 +1148,7 @@ public: , char* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1155,6 +1167,7 @@ public: , XMLCh* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1173,6 +1186,7 @@ public: , char* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1191,6 +1205,7 @@ public: , XMLCh* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1209,6 +1224,7 @@ public: , char* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Converts binary data to a text string based a given radix @@ -1227,6 +1243,7 @@ public: , XMLCh* const toFill , const unsigned int maxChars , const unsigned int radix + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -1243,6 +1260,7 @@ public: ( const XMLCh* const toConvert , unsigned int& toFill + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -1260,6 +1278,7 @@ public: static int parseInt ( const XMLCh* const toConvert + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Cut leading chars from a string @@ -1370,7 +1389,8 @@ public: * @param tokenizeSrc String to be tokenized * @return a vector of all the tokenized string */ - static BaseRefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc); + static BaseRefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} @@ -1387,7 +1407,7 @@ public: static XMLCh* makeUName ( const XMLCh* const pszURI - , const XMLCh* const pszName + , const XMLCh* const pszName ); /** @@ -1453,7 +1473,8 @@ public: * @param toConvert The string which needs to be whitespace removed. * On return , this buffer also holds the converted string */ - static void removeWS(XMLCh* const toConvert); + static void removeWS(XMLCh* const toConvert + , MemoryManager* const manager );//= XMLPlatformUtils::fgMemoryManager); /** * Fixes a platform dependent absolute path filename to standard URI form. diff --git a/src/xercesc/util/XMLStringTokenizer.cpp b/src/xercesc/util/XMLStringTokenizer.cpp index b242ef4265aa5604609f03c2e104a5e56b8b958a..e08b9650ae4301cc69f1ed8918ca5c915c8835c4 100644 --- a/src/xercesc/util/XMLStringTokenizer.cpp +++ b/src/xercesc/util/XMLStringTokenizer.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/01 16:32:39 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * @@ -193,7 +196,7 @@ XMLCh* XMLStringTokenizer::nextToken() { (endIndex - startIndex + 1) * sizeof(XMLCh) );//new XMLCh[(endIndex - startIndex) + 1]; - XMLString::subString(tokStr, fString, startIndex, endIndex); + XMLString::subString(tokStr, fString, startIndex, endIndex, fMemoryManager); fTokens->addElement(tokStr); return tokStr; diff --git a/src/xercesc/util/XMLUCS4Transcoder.hpp b/src/xercesc/util/XMLUCS4Transcoder.hpp index 16f538bf45d5429894d19395c897679afa826dfb..a86185557e2b95addf6e3a6000122768dfd0a5b6 100644 --- a/src/xercesc/util/XMLUCS4Transcoder.hpp +++ b/src/xercesc/util/XMLUCS4Transcoder.hpp @@ -81,6 +81,7 @@ public : const XMLCh* const encodingName , const unsigned int blockSize , const bool swapped + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLUCS4Transcoder(); diff --git a/src/xercesc/util/XMLUCSTranscoder.cpp b/src/xercesc/util/XMLUCSTranscoder.cpp index 366b4662e1422e5cac2a6aecb5429cb4b7548a4a..058bc5d5966d08170c8a4c4ef3ad795c36a860c4 100644 --- a/src/xercesc/util/XMLUCSTranscoder.cpp +++ b/src/xercesc/util/XMLUCSTranscoder.cpp @@ -70,9 +70,10 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- XMLUCS4Transcoder::XMLUCS4Transcoder(const XMLCh* const encodingName , const unsigned int blockSize - , const bool swapped) : + , const bool swapped + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) , fSwapped(swapped) { } @@ -246,7 +247,7 @@ XMLUCS4Transcoder::transcodeTo( const XMLCh* const srcData // an exception. // if ( !( (trailCh >= 0xDC00) && (trailCh <= 0xDFFF) ) ) - ThrowXML(TranscodingException, XMLExcepts::Trans_BadTrailingSurrogate); + ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Trans_BadTrailingSurrogate, getMemoryManager()); // And now combine the two into a single output char *outPtr++ = ((curCh - 0xD800) << 10) diff --git a/src/xercesc/util/XMLURL.cpp b/src/xercesc/util/XMLURL.cpp index 92f25b03000e9412ca7a8cb317fe6d938317ae3f..7387093962d0b029a16d560f03995d4001de0d16 100644 --- a/src/xercesc/util/XMLURL.cpp +++ b/src/xercesc/util/XMLURL.cpp @@ -495,7 +495,7 @@ const XMLCh* XMLURL::getProtocolName() const { // Check to see if its ever been set if (fProtocol == Unknown) - ThrowXML(MalformedURLException, XMLExcepts::URL_NoProtocolPresent); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); return gProtoList[fProtocol].prefix; } @@ -533,7 +533,7 @@ void XMLURL::setURL(const XMLCh* const baseURL if (!conglomerateWithBase(basePart, false)) { cleanup(); - ThrowXML(MalformedURLException, XMLExcepts::URL_RelativeBaseURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_RelativeBaseURL, fMemoryManager); } } } @@ -598,7 +598,7 @@ BinInputStream* XMLURL::makeNewStream() const // HTTP protocol will be done automatically by the netaccessor // int end = XMLString::stringLen(realPath); - int percentIndex = XMLString::indexOf(realPath, chPercent, 0); + int percentIndex = XMLString::indexOf(realPath, chPercent, 0, fMemoryManager); while (percentIndex != -1) { @@ -609,10 +609,11 @@ BinInputStream* XMLURL::makeNewStream() const XMLCh value1[4]; XMLString::moveChars(value1, &(realPath[percentIndex]), 3); value1[3] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_EscapeSequence , realPath - , value1); + , value1 + , fMemoryManager); } unsigned int value = (xlatHexDigit(realPath[percentIndex+1]) * 16) + xlatHexDigit(realPath[percentIndex+2]); @@ -625,7 +626,7 @@ BinInputStream* XMLURL::makeNewStream() const realPath[i] = chNull; end = i; - percentIndex = XMLString::indexOf(realPath, chPercent, percentIndex); + percentIndex = XMLString::indexOf(realPath, chPercent, percentIndex, fMemoryManager); } @@ -644,7 +645,7 @@ BinInputStream* XMLURL::makeNewStream() const // have to just throw here. // if (!XMLPlatformUtils::fgNetAccessor) - ThrowXML(MalformedURLException, XMLExcepts::URL_UnsupportedProto); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_UnsupportedProto, fMemoryManager); // Else ask the net accessor to create the stream return XMLPlatformUtils::fgNetAccessor->makeNew(*this); @@ -736,7 +737,7 @@ void XMLURL::buildFullText() *outPtr++ = chColon; XMLCh tmpBuf[16]; - XMLString::binToText(fPortNum, tmpBuf, 16, 10); + XMLString::binToText(fPortNum, tmpBuf, 16, 10, fMemoryManager); XMLString::copyString(outPtr, tmpBuf); outPtr += XMLString::stringLen(tmpBuf); } @@ -804,7 +805,7 @@ bool XMLURL::conglomerateWithBase(const XMLURL& baseURL, bool useExceptions) if (baseURL.isRelative()) { if (useExceptions) - ThrowXML(MalformedURLException, XMLExcepts::URL_RelativeBaseURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_RelativeBaseURL, fMemoryManager); else return false; } @@ -883,7 +884,7 @@ bool XMLURL::conglomerateWithBase(const XMLURL& baseURL, bool useExceptions) // Its a relative path, so weave them together. if (baseURL.fPath) { - XMLCh* temp = XMLPlatformUtils::weavePaths(baseURL.fPath, fPath); + XMLCh* temp = XMLPlatformUtils::weavePaths(baseURL.fPath, fPath ,fMemoryManager); fMemoryManager->deallocate(fPath);//delete [] fPath; fPath = temp; } @@ -908,7 +909,7 @@ void XMLURL::parse(const XMLCh* const urlText) { // Simplify things by checking for the psycho scenarios first if (!*urlText) - ThrowXML(MalformedURLException, XMLExcepts::URL_NoProtocolPresent); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); // Before we start, check if this urlText contains valid uri characters if (!XMLUri::isURIString(urlText)) @@ -929,7 +930,7 @@ void XMLURL::parse(const XMLCh* const urlText) if ((*(urlText + 2) == chForwardSlash) || (*(urlText + 2) == chBackSlash)) { - ThrowXML(MalformedURLException, XMLExcepts::URL_NoProtocolPresent); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); } } } @@ -954,7 +955,7 @@ void XMLURL::parse(const XMLCh* const urlText) // Make sure it wasn't all space if (!*srcPtr) - ThrowXML(MalformedURLException, XMLExcepts::URL_NoProtocolPresent); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_NoProtocolPresent, fMemoryManager); // // Ok, the next thing we have to do is to find either a / or : character. @@ -977,11 +978,12 @@ void XMLURL::parse(const XMLCh* const urlText) if (fProtocol == Unknown) { - ThrowXML1 + ThrowXMLwithMemMgr1 ( MalformedURLException , XMLExcepts::URL_UnsupportedProto1 , srcPtr + , fMemoryManager ); } @@ -1046,10 +1048,11 @@ void XMLURL::parse(const XMLCh* const urlText) // we didn't get them, so throw an exception // if (fProtocol == HTTP) { - ThrowXML + ThrowXMLwithMemMgr ( MalformedURLException , XMLExcepts::URL_ExpectingTwoSlashes + , fMemoryManager ); } } @@ -1104,8 +1107,8 @@ void XMLURL::parse(const XMLCh* const urlText) // Try to convert it to a numeric port value and store it ptr1++; - if (!XMLString::textToBin(ptr1, fPortNum)) - ThrowXML(MalformedURLException, XMLExcepts::URL_BadPortField); + if (!XMLString::textToBin(ptr1, fPortNum, fMemoryManager)) + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_BadPortField, fMemoryManager); } // If the host ended up empty, then toss is @@ -1378,7 +1381,7 @@ bool XMLURL::parse(const XMLCh* const urlText, XMLURL& xmlURL) // Try to convert it to a numeric port value and store it ptr1++; - if (!XMLString::textToBin(ptr1, xmlURL.fPortNum)) + if (!XMLString::textToBin(ptr1, xmlURL.fPortNum, xmlURL.fMemoryManager)) return false; } diff --git a/src/xercesc/util/XMLUTF16Transcoder.cpp b/src/xercesc/util/XMLUTF16Transcoder.cpp index f1f24c7afd2d8924a71ec35d59790f195e0c0030..86c1ad09af9246c3d6c4abf48a652532cbd588ba 100644 --- a/src/xercesc/util/XMLUTF16Transcoder.cpp +++ b/src/xercesc/util/XMLUTF16Transcoder.cpp @@ -72,9 +72,10 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- XMLUTF16Transcoder::XMLUTF16Transcoder( const XMLCh* const encodingName , const unsigned int blockSize - , const bool swapped) : + , const bool swapped + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) , fSwapped(swapped) { } diff --git a/src/xercesc/util/XMLUTF16Transcoder.hpp b/src/xercesc/util/XMLUTF16Transcoder.hpp index f9c69b832e8cd80bbbf1f84796f0f1813fb7cefb..2b2e4b48fb4f628347dd6212eafbf202fd0f8fbc 100644 --- a/src/xercesc/util/XMLUTF16Transcoder.hpp +++ b/src/xercesc/util/XMLUTF16Transcoder.hpp @@ -82,6 +82,7 @@ public : const XMLCh* const encodingName , const unsigned int blockSize , const bool swapped + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLUTF16Transcoder(); diff --git a/src/xercesc/util/XMLUTF8Transcoder.cpp b/src/xercesc/util/XMLUTF8Transcoder.cpp index ebdd3618fc6707667f9d970e09cff3eae85bac69..c8c78aedd299309202190613bb67633ddb670b11 100644 --- a/src/xercesc/util/XMLUTF8Transcoder.cpp +++ b/src/xercesc/util/XMLUTF8Transcoder.cpp @@ -139,9 +139,10 @@ static const XMLByte gFirstByteMark[7] = // XMLUTF8Transcoder: Constructors and Destructor // --------------------------------------------------------------------------- XMLUTF8Transcoder::XMLUTF8Transcoder(const XMLCh* const encodingName - , const unsigned int blockSize) : + , const unsigned int blockSize + , MemoryManager* const manager) : - XMLTranscoder(encodingName, blockSize) + XMLTranscoder(encodingName, blockSize, manager) { } @@ -219,7 +220,7 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData char pos[2] = {(char)0x31, 0}; char len[2] = {(char)trailingBytes+0x31, 0}; char byte[2] = {*srcPtr,0}; - ThrowXML3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len); + ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager()); } XMLUInt32 tmpVal = *srcPtr++; @@ -236,7 +237,7 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData char len[2] = {(char)trailingBytes+0x31, 0}; char pos[2]= {(char)i+0x31, 0}; char byte[2] = {*srcPtr,0}; - ThrowXML3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len); + ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, pos, byte, len, getMemoryManager()); } } if((*srcPtr & 0xC0) == 0x80) @@ -247,11 +248,11 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData { char len[2] = {(char)trailingBytes+0x31, 0}; char byte[2] = {*srcPtr,0}; - ThrowXML3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, len, byte, len); + ThrowXMLwithMemMgr3(UTFDataFormatException, XMLExcepts::UTF8_FormatError, len, byte, len, getMemoryManager()); } // since trailingBytes comes from an array, this logic is redundant // default : - // ThrowXML(TranscodingException, XMLExcepts::Trans_BadSrcSeq); + // ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Trans_BadSrcSeq); //} tmpVal -= gUTFOffsets[trailingBytes]; @@ -277,7 +278,7 @@ XMLUTF8Transcoder::transcodeFrom(const XMLByte* const srcData if ((outPtr - toFill) > 32) break; - ThrowXML(TranscodingException, XMLExcepts::Trans_BadSrcSeq); + ThrowXMLwithMemMgr(TranscodingException, XMLExcepts::Trans_BadSrcSeq, getMemoryManager()); } else { @@ -381,13 +382,14 @@ XMLUTF8Transcoder::transcodeTo( const XMLCh* const srcData if (options == UnRep_Throw) { XMLCh tmpBuf[16]; - XMLString::binToText(curVal, tmpBuf, 16, 16); - ThrowXML2 + XMLString::binToText(curVal, tmpBuf, 16, 16, getMemoryManager()); + ThrowXMLwithMemMgr2 ( TranscodingException , XMLExcepts::Trans_Unrepresentable , tmpBuf , getEncodingName() + , getMemoryManager() ); } diff --git a/src/xercesc/util/XMLUTF8Transcoder.hpp b/src/xercesc/util/XMLUTF8Transcoder.hpp index 336a223a12077502f64ca91b83a3450a9c0639e3..4b76ae27deda12908f06404d6b011d9008b52ab6 100644 --- a/src/xercesc/util/XMLUTF8Transcoder.hpp +++ b/src/xercesc/util/XMLUTF8Transcoder.hpp @@ -80,6 +80,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLUTF8Transcoder(); diff --git a/src/xercesc/util/XMLUri.cpp b/src/xercesc/util/XMLUri.cpp index e99dbd9a30e3d80383ebe02e01634eabf291a037..662b7c713c84b4a7408903fa4d5917be63c16df3 100644 --- a/src/xercesc/util/XMLUri.cpp +++ b/src/xercesc/util/XMLUri.cpp @@ -431,9 +431,10 @@ void XMLUri::initialize(const XMLUri* const baseURI if ( !baseURI && (!trimmedUriSpec || trimmedUriSpecLen == 0)) { - ThrowXML1(MalformedURLException + ThrowXMLwithMemMgr1(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Empty - , errMsg_PARAMS); + , errMsg_PARAMS + , fMemoryManager); } // just make a copy of the base if spec is empty @@ -462,7 +463,7 @@ void XMLUri::initialize(const XMLUri* const baseURI // A standalone base is a valid URI according to spec if ( colonIdx == 0 || (!baseURI && fragmentIdx != 0) ) { - ThrowXML(MalformedURLException, XMLExcepts::XMLNUM_URI_No_Scheme); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::XMLNUM_URI_No_Scheme, fMemoryManager); } } else @@ -475,9 +476,10 @@ void XMLUri::initialize(const XMLUri* const baseURI // It's an error if we stop here if (index == trimmedUriSpecLen || (foundScheme && (trimmedUriSpec[index] == chPound))) { - ThrowXML1(MalformedURLException + ThrowXMLwithMemMgr1(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Empty - , errMsg_PATH); + , errMsg_PATH + , fMemoryManager); } // two slashes means generic URI syntax, so we get the authority @@ -486,7 +488,7 @@ void XMLUri::initialize(const XMLUri* const baseURI (trimmedUriSpecLen+1) * sizeof(XMLCh) );//new XMLCh[trimmedUriSpecLen+1]; ArrayJanitor<XMLCh> authName(authUriSpec, fMemoryManager); - XMLString::subString(authUriSpec, trimmedUriSpec, index, trimmedUriSpecLen); + XMLString::subString(authUriSpec, trimmedUriSpec, index, trimmedUriSpecLen, fMemoryManager); if (((index+1) < trimmedUriSpecLen) && XMLString::startsWith(authUriSpec, DOUBLE_SLASH)) @@ -513,7 +515,7 @@ void XMLUri::initialize(const XMLUri* const baseURI // host to empty string if (index > startPos) { - XMLString::subString(authUriSpec, trimmedUriSpec, startPos, index); + XMLString::subString(authUriSpec, trimmedUriSpec, startPos, index, fMemoryManager); initializeAuthority(authUriSpec); } else @@ -532,7 +534,7 @@ void XMLUri::initialize(const XMLUri* const baseURI (trimmedUriSpecLen+1) * sizeof(XMLCh) );//new XMLCh[trimmedUriSpecLen+1]; ArrayJanitor<XMLCh> pathUriSpecName(pathUriSpec, fMemoryManager); - XMLString::subString(pathUriSpec, trimmedUriSpec, index, trimmedUriSpecLen); + XMLString::subString(pathUriSpec, trimmedUriSpec, index, trimmedUriSpecLen, fMemoryManager); initializePath(pathUriSpec); @@ -625,7 +627,7 @@ void XMLUri::initialize(const XMLUri* const baseURI int lastSlash = XMLString::lastIndexOf(basePath, chForwardSlash); if (lastSlash != -1) { - XMLString::subString(path, basePath, 0, lastSlash+1); + XMLString::subString(path, basePath, 0, lastSlash+1, fMemoryManager); } } @@ -636,8 +638,8 @@ void XMLUri::initialize(const XMLUri* const baseURI index = -1; while ((index = XMLString::patternMatch(path, SLASH_DOT_SLASH)) != -1) { - XMLString::subString(tmp1, path, 0, index); - XMLString::subString(tmp2, path, index+2, XMLString::stringLen(path)); + XMLString::subString(tmp1, path, 0, index, fMemoryManager); + XMLString::subString(tmp2, path, index+2, XMLString::stringLen(path), fMemoryManager); path[0] = 0; XMLString::catString(path, tmp1); @@ -662,7 +664,7 @@ void XMLUri::initialize(const XMLUri* const baseURI index += offset; // Find start of <segment> within substring ending at found point. - XMLString::subString(tmp1, path, 0, index-1); + XMLString::subString(tmp1, path, 0, index-1, fMemoryManager); segIndex = XMLString::lastIndexOf(tmp1, chForwardSlash); // Ensure <segment> exists and != ".." @@ -672,8 +674,8 @@ void XMLUri::initialize(const XMLUri* const baseURI segIndex + 3 != index)) { - XMLString::subString(tmp1, path, 0, segIndex); - XMLString::subString(tmp2, path, index+3, XMLString::stringLen(path)); + XMLString::subString(tmp1, path, 0, segIndex, fMemoryManager); + XMLString::subString(tmp2, path, index+3, XMLString::stringLen(path), fMemoryManager); path[0] = 0; XMLString::catString(path, tmp1); @@ -693,7 +695,7 @@ void XMLUri::initialize(const XMLUri* const baseURI { // Find start of <segment> within substring ending at found point. index = XMLString::stringLen(path) - 3; - XMLString::subString(tmp1, path, 0, index-1); + XMLString::subString(tmp1, path, 0, index-1, fMemoryManager); segIndex = XMLString::lastIndexOf(tmp1, chForwardSlash); if (segIndex != -1 && @@ -749,7 +751,7 @@ void XMLUri::initializeAuthority(const XMLCh* const uriSpec) if ( index != -1) { - XMLString::subString(userinfo, &(uriSpec[start]), 0, index); + XMLString::subString(userinfo, &(uriSpec[start]), 0, index, fMemoryManager); index++; // skip the @ start += index; } @@ -787,13 +789,13 @@ void XMLUri::initializeAuthority(const XMLCh* const uriSpec) if ( index != -1 ) { - XMLString::subString(host, &(uriSpec[start]), 0, index); + XMLString::subString(host, &(uriSpec[start]), 0, index, fMemoryManager); index++; // skip the : start +=index; } else { - XMLString::subString(host, &(uriSpec[start]), 0, end-start); + XMLString::subString(host, &(uriSpec[start]), 0, end-start, fMemoryManager); start = end; } @@ -810,13 +812,13 @@ void XMLUri::initializeAuthority(const XMLCh* const uriSpec) (index != -1) && // ":" found (start < end) ) // ":" is not the last { - XMLString::subString(portStr, &(uriSpec[start]), 0, end-start); + XMLString::subString(portStr, &(uriSpec[start]), 0, end-start, fMemoryManager); if (portStr && *portStr) { try { - port = XMLString::parseInt(portStr); + port = XMLString::parseInt(portStr, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -830,7 +832,7 @@ void XMLUri::initializeAuthority(const XMLCh* const uriSpec) } // if > 0 // Check if we have server based authority. - if (isValidServerBasedAuthority(host, port, userinfo)) + if (isValidServerBasedAuthority(host, port, userinfo, fMemoryManager)) { if (fHost) fMemoryManager->deallocate(fHost);//delete [] fHost; @@ -855,7 +857,7 @@ void XMLUri::initializeScheme(const XMLCh* const uriSpec) if ( !tmpPtr ) { - ThrowXML(MalformedURLException, XMLExcepts::XMLNUM_URI_No_Scheme); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::XMLNUM_URI_No_Scheme, fMemoryManager); } else { @@ -864,7 +866,7 @@ void XMLUri::initializeScheme(const XMLCh* const uriSpec) (XMLString::stringLen(uriSpec) + 1) * sizeof(XMLCh) );//new XMLCh[XMLString::stringLen(uriSpec)+1]; ArrayJanitor<XMLCh> tmpName(scheme, fMemoryManager); - XMLString::subString(scheme, uriSpec, 0, (tmpPtr - uriSpec)); + XMLString::subString(scheme, uriSpec, 0, (tmpPtr - uriSpec), fMemoryManager); setScheme(scheme); } @@ -874,9 +876,10 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { if ( !uriSpec ) { - ThrowXML1(MalformedURLException + ThrowXMLwithMemMgr1(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Empty - , errMsg_PATH); + , errMsg_PATH + , fMemoryManager); } int index = 0; @@ -910,10 +913,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { XMLString::moveChars(value1, &(uriSpec[index]), 3); value1[3] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_EscapeSequence , errMsg_PATH - , value1); + , value1 + , fMemoryManager); } } else if (!isUnreservedCharacter(testChar) && @@ -921,10 +925,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { value1[0] = testChar; value1[1] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char , errMsg_PATH - , value1); + , value1 + , fMemoryManager); } index++; @@ -951,10 +956,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { XMLString::moveChars(value1, &(uriSpec[index]), 3); value1[3] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_EscapeSequence , errMsg_PATH - , value1); + , value1 + , fMemoryManager); } } // If the scheme specific part is opaque, it can contain '[' @@ -967,10 +973,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { value1[0] = testChar; value1[1] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char , errMsg_PATH - , value1); + , value1 + , fMemoryManager); } index++; @@ -984,7 +991,7 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) } fPath = (XMLCh*) fMemoryManager->allocate((index+1) * sizeof(XMLCh));//new XMLCh[index+1]; - XMLString::subString(fPath, uriSpec, start, index); + XMLString::subString(fPath, uriSpec, start, index, fMemoryManager); // query - starts with ? and up to fragment or end if (testChar == chQuestion) @@ -1007,10 +1014,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { XMLString::moveChars(value1, &(uriSpec[index]), 3); value1[3] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_EscapeSequence , errMsg_QUERY - , value1); + , value1 + , fMemoryManager); } } else if (!isUnreservedCharacter(testChar) && @@ -1018,10 +1026,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { value1[0] = testChar; value1[1] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char , errMsg_QUERY - , value1); + , value1 + , fMemoryManager); } index++; } @@ -1035,7 +1044,7 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) ( (index - start + 1) * sizeof(XMLCh) );//new XMLCh[index - start + 1]; - XMLString::subString(fQueryString, uriSpec, start, index); + XMLString::subString(fQueryString, uriSpec, start, index, fMemoryManager); } // fragment - starts with # @@ -1055,10 +1064,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { XMLString::moveChars(value1, &(uriSpec[index]), 3); value1[3] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_EscapeSequence , errMsg_FRAGMENT - , value1); + , value1 + , fMemoryManager); } } else if (!isUnreservedCharacter(testChar) && @@ -1066,10 +1076,11 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) { value1[0] = testChar; value1[1] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char , errMsg_FRAGMENT - , value1); + , value1 + , fMemoryManager); } index++; @@ -1086,7 +1097,7 @@ void XMLUri::initializePath(const XMLCh* const uriSpec) ( (index - start + 1) * sizeof(XMLCh) );//new XMLCh[index - start + 1]; - XMLString::subString(fFragment, uriSpec, start, index); + XMLString::subString(fFragment, uriSpec, start, index, fMemoryManager); } else { @@ -1110,17 +1121,19 @@ void XMLUri::setScheme(const XMLCh* const newScheme) { if ( !newScheme ) { - ThrowXML1(MalformedURLException + ThrowXMLwithMemMgr1(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Set_Null - , errMsg_SCHEME); + , errMsg_SCHEME + , fMemoryManager); } if (!isConformantSchemeName(newScheme)) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Not_Conformant , errMsg_SCHEME - , newScheme); + , newScheme + , fMemoryManager); } if (getScheme()) @@ -1128,7 +1141,7 @@ void XMLUri::setScheme(const XMLCh* const newScheme) fMemoryManager->deallocate(fScheme);//delete [] fScheme; } - fScheme = XMLString::replicate(newScheme, fMemoryManager); + fScheme = XMLString::replicate(newScheme, fMemoryManager); XMLString::lowerCase(fScheme); } @@ -1147,15 +1160,16 @@ void XMLUri::setUserInfo(const XMLCh* const newUserInfo) if ( newUserInfo && !getHost() ) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_NullHost , errMsg_USERINFO - , newUserInfo); + , newUserInfo + , fMemoryManager); } try { - isConformantUserInfo(newUserInfo); + isConformantUserInfo(newUserInfo, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -1195,12 +1209,13 @@ void XMLUri::setHost(const XMLCh* const newHost) return; } - if ( *newHost && !isWellFormedAddress(newHost)) + if ( *newHost && !isWellFormedAddress(newHost, fMemoryManager)) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Not_Conformant , errMsg_HOST - , newHost); + , newHost + , fMemoryManager); } if (getHost()) @@ -1218,19 +1233,21 @@ void XMLUri::setPort(int newPort) { if (!getHost()) { - XMLString::binToText(newPort, value1, BUF_LEN, 10); - ThrowXML2(MalformedURLException + XMLString::binToText(newPort, value1, BUF_LEN, 10, fMemoryManager); + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_NullHost , errMsg_PORT - , value1); + , value1 + , fMemoryManager); } } else if (newPort != -1) { - XMLString::binToText(newPort, value1, BUF_LEN, 10); - ThrowXML1(MalformedURLException + XMLString::binToText(newPort, value1, BUF_LEN, 10, fMemoryManager); + ThrowXMLwithMemMgr1(MalformedURLException , XMLExcepts::XMLNUM_URI_PortNo_Invalid - , value1); + , value1 + , fMemoryManager); } fPort = newPort; @@ -1250,10 +1267,11 @@ void XMLUri::setRegBasedAuthority(const XMLCh* const newRegAuth) // ";" | ":" | "@" | "&" | "=" | "+" ) else if ( !*newRegAuth || !isValidRegistryBasedAuthority(newRegAuth) ) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Not_Conformant , errMsg_REGNAME - , newRegAuth); + , newRegAuth + , fMemoryManager); } if (getRegBasedAuthority()) @@ -1298,23 +1316,26 @@ void XMLUri::setFragment(const XMLCh* const newFragment) } else if (!isGenericURI()) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_for_GenURI_Only , errMsg_FRAGMENT - , newFragment); + , newFragment + , fMemoryManager); } else if ( !getPath() ) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_NullPath , errMsg_FRAGMENT - , newFragment); + , newFragment + , fMemoryManager); } else if (!isURIString(newFragment)) { - ThrowXML1(MalformedURLException + ThrowXMLwithMemMgr1(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char - , errMsg_FRAGMENT); + , errMsg_FRAGMENT + , fMemoryManager); } else { @@ -1341,24 +1362,27 @@ void XMLUri::setQueryString(const XMLCh* const newQueryString) } else if (!isGenericURI()) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_for_GenURI_Only , errMsg_QUERY - , newQueryString); + , newQueryString + , fMemoryManager); } else if ( !getPath() ) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_NullPath , errMsg_QUERY - , newQueryString); + , newQueryString + , fMemoryManager); } else if (!isURIString(newQueryString)) { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char , errMsg_QUERY - , newQueryString); + , newQueryString + , fMemoryManager); } else { @@ -1406,7 +1430,8 @@ bool XMLUri::isConformantSchemeName(const XMLCh* const scheme) // userinfo = *( unreserved | escaped | // ";" | ":" | "&" | "=" | "+" | "$" | "," ) // -void XMLUri::isConformantUserInfo(const XMLCh* const userInfo) +void XMLUri::isConformantUserInfo(const XMLCh* const userInfo + , MemoryManager* const manager) { if ( !userInfo ) return; @@ -1433,18 +1458,20 @@ void XMLUri::isConformantUserInfo(const XMLCh* const userInfo) value1[2] = *(tmpStr+2); value1[3] = chNull; - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_EscapeSequence , errMsg_USERINFO - , value1); + , value1 + , manager); } } else { - ThrowXML2(MalformedURLException + ThrowXMLwithMemMgr2(MalformedURLException , XMLExcepts::XMLNUM_URI_Component_Invalid_Char , errMsg_USERINFO - , userInfo); + , userInfo + , manager); } } //while @@ -1489,12 +1516,13 @@ bool XMLUri::isValidServerBasedAuthority(const XMLCh* const host, return true; } -bool XMLUri::isValidServerBasedAuthority(const XMLCh* const host, - const int port, - const XMLCh* const userinfo) +bool XMLUri::isValidServerBasedAuthority(const XMLCh* const host + , const int port + , const XMLCh* const userinfo + , MemoryManager* const manager) { // The order is important, do not change - if (!isWellFormedAddress(host)) + if (!isWellFormedAddress(host, manager)) return false; // check port number @@ -1637,7 +1665,8 @@ bool XMLUri::isURIString(const XMLCh* const uricString) // // IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT // -bool XMLUri::isWellFormedAddress(const XMLCh* const addrString) +bool XMLUri::isWellFormedAddress(const XMLCh* const addrString + , MemoryManager* const manager) { // Check that we have a non-zero length string. if (!addrString || !*addrString) @@ -1670,13 +1699,13 @@ bool XMLUri::isWellFormedAddress(const XMLCh* const addrString) // get the second last "." if (lastPeriodPos + 1 == addrStrLen) { - XMLCh* tmp2 = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate + XMLCh* tmp2 = (XMLCh*) manager->allocate ( addrStrLen * sizeof(XMLCh) );//new XMLCh[addrStrLen]; - XMLString::subString(tmp2, addrString, 0, lastPeriodPos); + XMLString::subString(tmp2, addrString, 0, lastPeriodPos, manager); lastPeriodPos = XMLString::lastIndexOf(tmp2, chPeriod); - XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2; + manager->deallocate(tmp2);//delete [] tmp2; if ( XMLString::isDigit(addrString[lastPeriodPos + 1])) return false; @@ -1986,7 +2015,7 @@ void XMLUri::buildFullText() *outPtr++ = chColon; XMLCh tmpBuf[16]; - XMLString::binToText(fPort, tmpBuf, 16, 10); + XMLString::binToText(fPort, tmpBuf, 16, 10, fMemoryManager); XMLString::copyString(outPtr, tmpBuf); outPtr += XMLString::stringLen(tmpBuf); } @@ -2114,6 +2143,110 @@ bool XMLUri::isValidURI(const XMLUri* const baseURI } } + // we need to check if index has exceed the lenght or not + if (index < trimmedUriSpecLen) + { + if (!processPath(trimmedUriSpec + index, trimmedUriSpecLen - index, foundScheme)) + return false; + } + + return true; +} + +// NOTE: no check for NULL value of uriStr (caller responsiblilty) +// NOTE: this routine is the same as above, but it uses a flag to +// indicate the existance of a baseURI rather than an XMLuri. +bool XMLUri::isValidURI(bool haveBaseURI, const XMLCh* const uriStr) +{ + // get a trimmed version of uriStr + // uriStr will NO LONGER be used in this function. + const XMLCh* trimmedUriSpec = uriStr; + + while (XMLChar1_0::isWhitespace(*trimmedUriSpec)) + trimmedUriSpec++; + + int trimmedUriSpecLen = XMLString::stringLen(trimmedUriSpec); + + while (trimmedUriSpecLen) { + if (XMLChar1_0::isWhitespace(trimmedUriSpec[trimmedUriSpecLen-1])) + trimmedUriSpecLen--; + else + break; + } + + if (trimmedUriSpecLen == 0) + { + if (!haveBaseURI) + return false; + else + return true; + return true; + } + + int index = 0; + bool foundScheme = false; + + // Check for scheme, which must be before `/', '?' or '#'. + // Also handle names with DOS drive letters ('D:'), + // so 1-character schemes are not allowed. + int colonIdx = XMLString::indexOf(trimmedUriSpec, chColon); + int slashIdx = XMLString::indexOf(trimmedUriSpec, chForwardSlash); + int queryIdx = XMLString::indexOf(trimmedUriSpec, chQuestion); + int fragmentIdx = XMLString::indexOf(trimmedUriSpec, chPound); + + if ((colonIdx < 2) || + (colonIdx > slashIdx && slashIdx != -1) || + (colonIdx > queryIdx && queryIdx != -1) || + (colonIdx > fragmentIdx && fragmentIdx != -1)) + { + // A standalone base is a valid URI according to spec + if (colonIdx == 0 || (!haveBaseURI && fragmentIdx != 0)) + return false; + } + else + { + if (!processScheme(trimmedUriSpec, index)) + return false; + foundScheme = true; + ++index; + } + + // It's an error if we stop here + if (index == trimmedUriSpecLen || (foundScheme && (trimmedUriSpec[index] == chPound))) + return false; + + // two slashes means generic URI syntax, so we get the authority + const XMLCh* authUriSpec = trimmedUriSpec + index; + if (((index+1) < trimmedUriSpecLen) && + XMLString::startsWith(authUriSpec, DOUBLE_SLASH)) + { + index += 2; + int startPos = index; + + // get authority - everything up to path, query or fragment + XMLCh testChar; + while (index < trimmedUriSpecLen) + { + testChar = trimmedUriSpec[index]; + if (testChar == chForwardSlash || + testChar == chQuestion || + testChar == chPound ) + { + break; + } + + index++; + } + + // if we found authority, parse it out, otherwise we set the + // host to empty string + if (index > startPos) + { + if (!processAuthority(trimmedUriSpec + startPos, index - startPos)) + return false; + } + } + // we need to check if index has exceed the length or not if (index < trimmedUriSpecLen) { diff --git a/src/xercesc/util/XMLUri.hpp b/src/xercesc/util/XMLUri.hpp index 53ebc29b12b135d5a69688431bd34194c53e12c7..961bc1cb8a2490f0878c1894b5ea907da6e9c6ae 100644 --- a/src/xercesc/util/XMLUri.hpp +++ b/src/xercesc/util/XMLUri.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.15 2003/12/17 00:18:35 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.14 2003/12/11 22:21:25 neilg * fixes for the URI implementation to take registry names into account; much thanks to Michael Glavassevich * @@ -407,6 +410,11 @@ public: */ static bool isValidURI( const XMLUri* const baseURI , const XMLCh* const uriStr); + /** + * Determine whether a given string is a valid URI + */ + static bool isValidURI( bool haveBaseURI + , const XMLCh* const uriStr); /*** * Support for Serialization/De-serialization @@ -466,7 +474,8 @@ private: * * @return true if the scheme is conformant, false otherwise */ - static void isConformantUserInfo(const XMLCh* const userInfo); + static void isConformantUserInfo(const XMLCh* const userInfo + , MemoryManager* const manager); /** * Determines whether the components host, port, and user info @@ -490,7 +499,8 @@ private: */ static bool isValidServerBasedAuthority(const XMLCh* const host , const int port - , const XMLCh* const userinfo); + , const XMLCh* const userinfo + , MemoryManager* const manager); /** * Determines whether the given string is a registry based authority. @@ -528,7 +538,8 @@ private: * @return true if the string is a syntactically valid IPv4 address * or hostname */ - static bool isWellFormedAddress(const XMLCh* const addr); + static bool isWellFormedAddress(const XMLCh* const addr + , MemoryManager* const manager); /** * Determines whether a string is an IPv4 address as defined by diff --git a/src/xercesc/util/XMLWin1252Transcoder.cpp b/src/xercesc/util/XMLWin1252Transcoder.cpp index 17ae5d5db1a0ff9af0c4af344b009af172c4960c..2b8cf18a048e7ae6d28938bb6cbd2907d20b383c 100644 --- a/src/xercesc/util/XMLWin1252Transcoder.cpp +++ b/src/xercesc/util/XMLWin1252Transcoder.cpp @@ -213,7 +213,8 @@ static const unsigned int gToTableSz = 350; // XML1140Transcoder: Constructors and Destructor // --------------------------------------------------------------------------- XMLWin1252Transcoder::XMLWin1252Transcoder( const XMLCh* const encodingName - , const unsigned int blockSize) : + , const unsigned int blockSize + , MemoryManager* const manager) : XML256TableTranscoder ( encodingName @@ -221,6 +222,7 @@ XMLWin1252Transcoder::XMLWin1252Transcoder( const XMLCh* const encodingName , gFromTable , gToTable , gToTableSz + , manager ) { } diff --git a/src/xercesc/util/XMLWin1252Transcoder.hpp b/src/xercesc/util/XMLWin1252Transcoder.hpp index 4ab60a046f548afb9fcd4ce3c348da1f115e85bc..09571a1bad13839a8233c1f812c75e9cf31a6800 100644 --- a/src/xercesc/util/XMLWin1252Transcoder.hpp +++ b/src/xercesc/util/XMLWin1252Transcoder.hpp @@ -78,6 +78,7 @@ public : ( const XMLCh* const encodingName , const unsigned int blockSize + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLWin1252Transcoder(); diff --git a/src/xercesc/util/regx/CharToken.cpp b/src/xercesc/util/regx/CharToken.cpp index e0b590c9e922216ee2cf28725494e9b5b2f39e20..b59db964c6af434554ca66a02b3736378383e712 100644 --- a/src/xercesc/util/regx/CharToken.cpp +++ b/src/xercesc/util/regx/CharToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2002/11/04 15:17:00 tng * C++ Namespace Support. * @@ -80,8 +83,8 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // Token: Constructors and Destructors // --------------------------------------------------------------------------- -CharToken::CharToken(const unsigned short tokType, const XMLInt32 ch) - : Token(tokType) +CharToken::CharToken(const unsigned short tokType, const XMLInt32 ch, MemoryManager* const manager) + : Token(tokType, manager) , fCharData(ch) { diff --git a/src/xercesc/util/regx/CharToken.hpp b/src/xercesc/util/regx/CharToken.hpp index 374599e4ee27c4149ec7754c147b354cc7360814..22d32c5f4f834d11366372f02a13cf9b8f71adab 100644 --- a/src/xercesc/util/regx/CharToken.hpp +++ b/src/xercesc/util/regx/CharToken.hpp @@ -73,7 +73,8 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - CharToken(const unsigned short tokType, const XMLInt32 ch); + CharToken(const unsigned short tokType, const XMLInt32 ch + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~CharToken(); // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/ClosureToken.cpp b/src/xercesc/util/regx/ClosureToken.cpp index be076d907120e7e019ba71ad909101f7a874108b..04a279277aa20dcd26c8dbe201e0810eb270ee27 100644 --- a/src/xercesc/util/regx/ClosureToken.cpp +++ b/src/xercesc/util/regx/ClosureToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2002/11/04 15:17:00 tng * C++ Namespace Support. * @@ -80,8 +83,8 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // ClosureToken: Constructors and Destructors // --------------------------------------------------------------------------- -ClosureToken::ClosureToken(const unsigned short tokType, Token* const tok) - : Token(tokType) +ClosureToken::ClosureToken(const unsigned short tokType, Token* const tok, MemoryManager* const manager) + : Token(tokType, manager) , fChild(tok) , fMax(-1) , fMin(-1) diff --git a/src/xercesc/util/regx/ClosureToken.hpp b/src/xercesc/util/regx/ClosureToken.hpp index 4a2e7862fa6db651060ceaad52638cc6093bf35d..65891a8e07a60f22e4f2f9b28f6649768d23a6e5 100644 --- a/src/xercesc/util/regx/ClosureToken.hpp +++ b/src/xercesc/util/regx/ClosureToken.hpp @@ -73,7 +73,8 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - ClosureToken(const unsigned short tokType, Token* const tok); + ClosureToken(const unsigned short tokType, Token* const tok + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ClosureToken(); // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/ConcatToken.cpp b/src/xercesc/util/regx/ConcatToken.cpp index 5be16ead8e7ece89035d071c5e2aab0675e616b2..f0e1adc28267e97ee7291b670a9577766efcb409 100644 --- a/src/xercesc/util/regx/ConcatToken.cpp +++ b/src/xercesc/util/regx/ConcatToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2002/11/04 15:17:00 tng * C++ Namespace Support. * @@ -83,8 +86,8 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // Token: Constructors and Destructors // --------------------------------------------------------------------------- -ConcatToken::ConcatToken(Token* const tok1, Token* const tok2) - : Token(Token::T_CONCAT) +ConcatToken::ConcatToken(Token* const tok1, Token* const tok2, MemoryManager* const manager) + : Token(Token::T_CONCAT, manager) , fChild1(tok1) , fChild2(tok2) { diff --git a/src/xercesc/util/regx/ConcatToken.hpp b/src/xercesc/util/regx/ConcatToken.hpp index bf6723c82385001000a99d7dfaf65365fa1eb779..5298850eba6154f0110d103e8c92f22f1bf6e881 100644 --- a/src/xercesc/util/regx/ConcatToken.hpp +++ b/src/xercesc/util/regx/ConcatToken.hpp @@ -73,7 +73,8 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - ConcatToken(Token* const tok1, Token* const tok2); + ConcatToken(Token* const tok1, Token* const tok2 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ConcatToken(); // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/ConditionToken.cpp b/src/xercesc/util/regx/ConditionToken.cpp index 79aae9fea263ae83d48a37a12478146fe8308a22..0a26b645ae2326ff5b6af94e20f08f9017ba5f4a 100644 --- a/src/xercesc/util/regx/ConditionToken.cpp +++ b/src/xercesc/util/regx/ConditionToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2002/11/04 15:17:00 tng * C++ Namespace Support. * @@ -84,8 +87,8 @@ XERCES_CPP_NAMESPACE_BEGIN // ConditionToken: Constructors and Destructors // --------------------------------------------------------------------------- ConditionToken::ConditionToken(const unsigned int refNo, Token* const condTok, - Token* const yesTok, Token* const noTok) - : Token(Token::T_CONDITION) + Token* const yesTok, Token* const noTok, MemoryManager* const manager) + : Token(Token::T_CONDITION, manager) , fRefNo(refNo) , fConditionToken(condTok) , fYesToken(yesTok) diff --git a/src/xercesc/util/regx/ConditionToken.hpp b/src/xercesc/util/regx/ConditionToken.hpp index d68aef6a129a3bbd7ec820ec3a642553b581d117..2c1db160589f97e49eedc18a4893c99b4d494a9e 100644 --- a/src/xercesc/util/regx/ConditionToken.hpp +++ b/src/xercesc/util/regx/ConditionToken.hpp @@ -74,7 +74,8 @@ public: // Public Constructors and Destructor // ----------------------------------------------------------------------- ConditionToken(const unsigned int refNo, Token* const condTok, - Token* const yesTok, Token* const noTok); + Token* const yesTok, Token* const noTok + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ConditionToken(); // ----------------------------------------------------------------------- @@ -118,7 +119,7 @@ inline int ConditionToken::getReferenceNo() const { inline Token* ConditionToken::getChild(const int index) const { if (index < 0 || index > 1) - ThrowXML(RuntimeException, XMLExcepts::Regex_InvalidChildIndex); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_InvalidChildIndex, fMemoryManager); if (index == 0) return fYesToken; diff --git a/src/xercesc/util/regx/Match.hpp b/src/xercesc/util/regx/Match.hpp index 4d6c80d61ee92279ff41f33d55c7c8fe5387c051..36bf022aec4c46af9594cf75efa11bd5570aafd2 100644 --- a/src/xercesc/util/regx/Match.hpp +++ b/src/xercesc/util/regx/Match.hpp @@ -112,13 +112,13 @@ private: void cleanUp(); // ----------------------------------------------------------------------- - // Private data members - // - // fNoGroups - // Represents no of regular expression groups + // Private data members + // + // fNoGroups + // Represents no of regular expression groups // - // fStartPositions - // Array of start positions in the target text matched to specific + // fStartPositions + // Array of start positions in the target text matched to specific // regular expression group // // fEndPositions @@ -127,7 +127,7 @@ private: // // fPositionsSize // Actual size of Start/EndPositions array. - // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- int fNoGroups; int fPositionsSize; int* fStartPositions; @@ -145,7 +145,7 @@ private: inline int Match::getNoGroups() const { if (fNoGroups < 0) - ThrowXML(RuntimeException, XMLExcepts::Regex_Result_Not_Set); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager); return fNoGroups; } @@ -153,10 +153,10 @@ inline int Match::getNoGroups() const { inline int Match::getStartPos(int index) const { if (!fStartPositions) - ThrowXML(RuntimeException, XMLExcepts::Regex_Result_Not_Set); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager); if (index < 0 || fNoGroups <= index) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); return fStartPositions[index]; } @@ -164,10 +164,10 @@ inline int Match::getStartPos(int index) const { inline int Match::getEndPos(int index) const { if (!fEndPositions) - ThrowXML(RuntimeException, XMLExcepts::Regex_Result_Not_Set); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager); if (index < 0 || fNoGroups <= index) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); return fEndPositions[index]; } @@ -178,10 +178,10 @@ inline int Match::getEndPos(int index) const { inline void Match::setStartPos(const int index, const int value) { if (!fStartPositions) - ThrowXML(RuntimeException, XMLExcepts::Regex_Result_Not_Set); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager); if (index < 0 || fNoGroups <= index) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); fStartPositions[index] = value; } @@ -189,10 +189,10 @@ inline void Match::setStartPos(const int index, const int value) { inline void Match::setEndPos(const int index, const int value) { if (!fEndPositions) - ThrowXML(RuntimeException, XMLExcepts::Regex_Result_Not_Set); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager); if (index < 0 || fNoGroups <= index) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); fEndPositions[index] = value; } diff --git a/src/xercesc/util/regx/ModifierToken.cpp b/src/xercesc/util/regx/ModifierToken.cpp index e4bc22556897a5810e93b6e12659c05ef84f0a6c..ad0ade37026e023ee28a746d7fee452198d77241 100644 --- a/src/xercesc/util/regx/ModifierToken.cpp +++ b/src/xercesc/util/regx/ModifierToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2002/11/04 15:17:00 tng * C++ Namespace Support. * @@ -84,8 +87,8 @@ XERCES_CPP_NAMESPACE_BEGIN // ModifierToken: Constructors and Destructors // --------------------------------------------------------------------------- ModifierToken::ModifierToken(Token* const child, const int options, - const int mask) - : Token(Token::T_MODIFIERGROUP) + const int mask, MemoryManager* const manager) + : Token(Token::T_MODIFIERGROUP, manager) , fOptions(options) , fOptionsMask(mask) , fChild(child) diff --git a/src/xercesc/util/regx/ModifierToken.hpp b/src/xercesc/util/regx/ModifierToken.hpp index 617a4dea9fa1d587406eff592d77d79699d3481d..598ac41886834bd4087f71c1f71081c3863374ef 100644 --- a/src/xercesc/util/regx/ModifierToken.hpp +++ b/src/xercesc/util/regx/ModifierToken.hpp @@ -73,7 +73,8 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - ModifierToken(Token* const child, const int options, const int mask); + ModifierToken(Token* const child, const int options, const int mask + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ModifierToken(); // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/Op.cpp b/src/xercesc/util/regx/Op.cpp index f511d555ab2a9ef06a9337cf6f1d4a7254a40058..db6787f36402ff985de3246dc35f86c9a23c8f8f 100644 --- a/src/xercesc/util/regx/Op.cpp +++ b/src/xercesc/util/regx/Op.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.4 2003/05/18 14:02:06 knoaman * Memory manager implementation: pass per instance manager. * @@ -91,9 +94,11 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // Op: Constructors and Destructors // --------------------------------------------------------------------------- -Op::Op(const short type) : fOpType(type), - fNextOp(0) { - +Op::Op(const short type, MemoryManager* const manager) + : fOpType(type) + , fNextOp(0) + , fMemoryManager(manager) +{ } // --------------------------------------------------------------------------- @@ -101,67 +106,67 @@ Op::Op(const short type) : fOpType(type), // --------------------------------------------------------------------------- int Op::getSize() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } XMLInt32 Op::getData() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } XMLInt32 Op::getData2() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } int Op::getRefNo() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const Op* Op::elementAt(int index) const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const Op* Op::getChild() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const Op* Op::getConditionFlow() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const Op* Op::getYesFlow() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const Op* Op::getNoFlow() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const XMLCh* Op::getLiteral() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } const Token* Op::getToken() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // for compilers that complain about no return value } @@ -169,8 +174,9 @@ const Token* Op::getToken() const { // --------------------------------------------------------------------------- // CharOp: Constructors and Destuctors // --------------------------------------------------------------------------- -CharOp::CharOp(const short type, const XMLInt32 charData) - : Op(type) +CharOp::CharOp(const short type, const XMLInt32 charData + , MemoryManager* const manager) + : Op(type, manager) , fCharData(charData) { } @@ -186,7 +192,7 @@ XMLInt32 CharOp::getData() const { // UnionOp: Constructors and Destuctors // --------------------------------------------------------------------------- UnionOp::UnionOp(const short type, const int size, MemoryManager* const manager) - : Op(type) + : Op(type, manager) , fBranches(new (manager) RefVectorOf<Op> (size, false, manager)) { } @@ -212,8 +218,8 @@ void UnionOp::addElement(Op* const op) { // --------------------------------------------------------------------------- // ChildOp: Constructors and Destuctors // --------------------------------------------------------------------------- -ChildOp::ChildOp(const short type) - : Op(type) +ChildOp::ChildOp(const short type, MemoryManager* const manager) + : Op(type, manager) , fChild(0) { } @@ -234,8 +240,9 @@ void ChildOp::setChild(const Op* const child) { // --------------------------------------------------------------------------- // ModifierOp: Constructors and Destuctors // --------------------------------------------------------------------------- -ModifierOp::ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2) - : ChildOp(type) +ModifierOp::ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2 + , MemoryManager* const manager) + : ChildOp(type, manager) , fVal1(v1) , fVal2(v2) { @@ -257,8 +264,8 @@ XMLInt32 ModifierOp::getData2() const { // --------------------------------------------------------------------------- // RangeOp: Constructors and Destuctors // --------------------------------------------------------------------------- -RangeOp::RangeOp(const short type, const Token* const token) - : Op (type) +RangeOp::RangeOp(const short type, const Token* const token, MemoryManager* const manager) + : Op (type, manager) , fToken(token) { } @@ -275,9 +282,10 @@ const Token* RangeOp::getToken() const { // --------------------------------------------------------------------------- // StringOp: Constructors and Destuctors // --------------------------------------------------------------------------- -StringOp::StringOp(const short type, const XMLCh* const literal) - : Op (type) - , fLiteral(XMLString::replicate(literal)) { +StringOp::StringOp(const short type, const XMLCh* const literal + , MemoryManager* const manager) + : Op (type, manager) + , fLiteral(XMLString::replicate(literal, manager)) { } @@ -294,8 +302,8 @@ const XMLCh* StringOp::getLiteral() const { // --------------------------------------------------------------------------- ConditionOp::ConditionOp(const short type, const int refNo, const Op* const condFlow, const Op* const yesFlow, - const Op* const noFlow) - : Op (type) + const Op* const noFlow, MemoryManager* const manager) + : Op (type, manager) , fRefNo(refNo) , fConditionOp(condFlow) , fYesOp(yesFlow) diff --git a/src/xercesc/util/regx/Op.hpp b/src/xercesc/util/regx/Op.hpp index e29f1d773f3c7843421ffa5045b104dc5f3ba6e0..503211dd66a54de632584b535233ee154d033783 100644 --- a/src/xercesc/util/regx/Op.hpp +++ b/src/xercesc/util/regx/Op.hpp @@ -134,15 +134,17 @@ protected: // ----------------------------------------------------------------------- // Protected Constructors // ----------------------------------------------------------------------- - Op(const short type); + Op(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); friend class OpFactory; + MemoryManager* const fMemoryManager; + private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- - Op(const Op&) {ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported);}; - Op& operator=(const Op&) {ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported);}; + Op(const Op&); + Op& operator=(const Op&); // ----------------------------------------------------------------------- // Private data members @@ -163,7 +165,7 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - CharOp(const short type, const XMLInt32 charData); + CharOp(const short type, const XMLInt32 charData, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~CharOp() {} // ----------------------------------------------------------------------- @@ -208,7 +210,7 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - ChildOp(const short type); + ChildOp(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ChildOp() {} // ----------------------------------------------------------------------- @@ -231,7 +233,7 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2); + ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ModifierOp() {} // ----------------------------------------------------------------------- @@ -251,7 +253,7 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - RangeOp(const short type, const Token* const token); + RangeOp(const short type, const Token* const token, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~RangeOp() {} // ----------------------------------------------------------------------- @@ -269,7 +271,7 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - StringOp(const short type, const XMLCh* const literal); + StringOp(const short type, const XMLCh* const literal, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~StringOp() { delete[] fLiteral;} // ----------------------------------------------------------------------- @@ -289,7 +291,7 @@ public: // ----------------------------------------------------------------------- ConditionOp(const short type, const int refNo, const Op* const condFlow, const Op* const yesFlow, - const Op* const noFlow); + const Op* const noFlow, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ConditionOp() {} // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/OpFactory.cpp b/src/xercesc/util/regx/OpFactory.cpp index 33f0bd93b9d9174a4f3518c8148fcdf268fc4daa..fa1e6a123274527929ef8f8e1905c2b5021d4338 100644 --- a/src/xercesc/util/regx/OpFactory.cpp +++ b/src/xercesc/util/regx/OpFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/05/18 14:02:06 knoaman * Memory manager implementation: pass per instance manager. * @@ -115,14 +118,14 @@ OpFactory::~OpFactory() { // --------------------------------------------------------------------------- Op* OpFactory::createDotOp() { - Op* tmpOp = new (fMemoryManager) Op(Op::O_DOT); + Op* tmpOp = new (fMemoryManager) Op(Op::O_DOT, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; } CharOp* OpFactory::createCharOp(int data) { - CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CHAR, data); + CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CHAR, data, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -130,7 +133,7 @@ CharOp* OpFactory::createCharOp(int data) { CharOp* OpFactory::createAnchorOp(int data) { - CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_ANCHOR, data); + CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_ANCHOR, data, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -138,7 +141,7 @@ CharOp* OpFactory::createAnchorOp(int data) { CharOp* OpFactory::createCaptureOp(int number, const Op* const next) { - CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CAPTURE, number); + CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_CAPTURE, number, fMemoryManager); tmpOp->setNextOp(next); fOpVector->addElement(tmpOp); @@ -155,7 +158,7 @@ UnionOp* OpFactory::createUnionOp(int size) { ChildOp* OpFactory::createClosureOp(int id) { - ModifierOp* tmpOp = new (fMemoryManager) ModifierOp(Op::O_CLOSURE, id, -1); + ModifierOp* tmpOp = new (fMemoryManager) ModifierOp(Op::O_CLOSURE, id, -1, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -163,7 +166,7 @@ ChildOp* OpFactory::createClosureOp(int id) { ChildOp* OpFactory::createNonGreedyClosureOp() { - ChildOp* tmpOp = new (fMemoryManager) ChildOp(Op::O_NONGREEDYCLOSURE); + ChildOp* tmpOp = new (fMemoryManager) ChildOp(Op::O_NONGREEDYCLOSURE, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -172,7 +175,7 @@ ChildOp* OpFactory::createNonGreedyClosureOp() { ChildOp* OpFactory::createQuestionOp(bool nonGreedy) { ChildOp* tmpOp = new (fMemoryManager) ChildOp(nonGreedy ? Op::O_NONGREEDYQUESTION : - Op::O_QUESTION); + Op::O_QUESTION, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -180,7 +183,7 @@ ChildOp* OpFactory::createQuestionOp(bool nonGreedy) { RangeOp* OpFactory::createRangeOp(const Token* const token) { - RangeOp* tmpOp = new (fMemoryManager) RangeOp(Op::O_RANGE, token); + RangeOp* tmpOp = new (fMemoryManager) RangeOp(Op::O_RANGE, token, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -189,7 +192,7 @@ RangeOp* OpFactory::createRangeOp(const Token* const token) { ChildOp* OpFactory::createLookOp(const short type, const Op* const next, const Op* const branch) { - ChildOp* tmpOp = new (fMemoryManager) ChildOp(type); + ChildOp* tmpOp = new (fMemoryManager) ChildOp(type, fMemoryManager); tmpOp->setNextOp(next); tmpOp->setChild(branch); @@ -199,7 +202,7 @@ ChildOp* OpFactory::createLookOp(const short type, const Op* const next, CharOp* OpFactory::createBackReferenceOp(int refNo) { - CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_BACKREFERENCE, refNo); + CharOp* tmpOp = new (fMemoryManager) CharOp(Op::O_BACKREFERENCE, refNo, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -207,7 +210,7 @@ CharOp* OpFactory::createBackReferenceOp(int refNo) { StringOp* OpFactory::createStringOp(const XMLCh* const literal) { - StringOp* tmpOp = new (fMemoryManager) StringOp(Op::O_STRING, literal); + StringOp* tmpOp = new (fMemoryManager) StringOp(Op::O_STRING, literal, fMemoryManager); fOpVector->addElement(tmpOp); return tmpOp; @@ -216,7 +219,7 @@ StringOp* OpFactory::createStringOp(const XMLCh* const literal) { ChildOp* OpFactory::createIndependentOp(const Op* const next, const Op* const branch) { - ChildOp* tmpOp = new (fMemoryManager) ChildOp(Op::O_INDEPENDENT); + ChildOp* tmpOp = new (fMemoryManager) ChildOp(Op::O_INDEPENDENT, fMemoryManager); tmpOp->setNextOp(next); tmpOp->setChild(branch); @@ -228,7 +231,7 @@ ModifierOp* OpFactory::createModifierOp(const Op* const next, const Op* const branch, const int add, const int mask) { - ModifierOp* tmpOp = new (fMemoryManager) ModifierOp(Op::O_MODIFIER, add, mask); + ModifierOp* tmpOp = new (fMemoryManager) ModifierOp(Op::O_MODIFIER, add, mask, fMemoryManager); tmpOp->setNextOp(next); tmpOp->setChild(branch); @@ -241,7 +244,7 @@ ConditionOp* OpFactory::createConditionOp(const Op* const next, const int ref, const Op* const noFlow) { ConditionOp* tmpOp = new (fMemoryManager) ConditionOp(Op::O_CONDITION, ref, conditionFlow, - yesFlow, noFlow); + yesFlow, noFlow, fMemoryManager); tmpOp->setNextOp(next); return tmpOp; diff --git a/src/xercesc/util/regx/ParenToken.cpp b/src/xercesc/util/regx/ParenToken.cpp index 9531c7e0cf0f181544f921f36a9292545477de45..6167c297c04e7a32e4310baf0bcf3977a7457470 100644 --- a/src/xercesc/util/regx/ParenToken.cpp +++ b/src/xercesc/util/regx/ParenToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.2 2002/11/04 15:17:00 tng * C++ Namespace Support. * @@ -81,8 +84,8 @@ XERCES_CPP_NAMESPACE_BEGIN // ParenToken: Constructors and Destructors // --------------------------------------------------------------------------- ParenToken::ParenToken(const unsigned short tokType, - Token* const tok, const int noParen) - : Token(tokType) + Token* const tok, const int noParen, MemoryManager* const manager) + : Token(tokType, manager) , fNoParen(noParen) , fChild(tok) { diff --git a/src/xercesc/util/regx/ParenToken.hpp b/src/xercesc/util/regx/ParenToken.hpp index 04043dc4cb544d2abba629ddef360a6d2200bb1d..8135c6656f0af9f82e1bc1317b419c7935ae1502 100644 --- a/src/xercesc/util/regx/ParenToken.hpp +++ b/src/xercesc/util/regx/ParenToken.hpp @@ -74,7 +74,7 @@ public: // Public Constructors and Destructor // ----------------------------------------------------------------------- ParenToken(const unsigned short tokType, Token* const tok, - const int noParen); + const int noParen, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ParenToken(); // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/ParserForXMLSchema.cpp b/src/xercesc/util/regx/ParserForXMLSchema.cpp index 2dc212862a6ef5c206480c4cbaf049a46eee6c80..5d86bcc9fddc1054d5d6bf40cb1aa0d81125c439 100644 --- a/src/xercesc/util/regx/ParserForXMLSchema.cpp +++ b/src/xercesc/util/regx/ParserForXMLSchema.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/05/15 18:42:54 knoaman * Partial implementation of the configurable memory manager. * @@ -179,7 +182,7 @@ Token* ParserForXMLSchema::processParen() { Token* retTok = getTokenFactory()->createParenthesis(parseRegx(true), 0); if (getState() != REGX_T_RPAREN) { - ThrowXML(ParseException, XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException, XMLExcepts::Parser_Factor1, getMemoryManager()); } processNext(); @@ -258,7 +261,7 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { RangeToken* tok2 = processBacksolidus_pP(ch); if (tok2 == 0) { - ThrowXML(ParseException,XMLExcepts::Parser_Atom5); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom5, getMemoryManager()); } tok->mergeRanges(tok2); @@ -281,7 +284,7 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { tok->subtractRanges(rangeTok); if (getState() != REGX_T_CHAR || getCharData() != chCloseSquare) { - ThrowXML(ParseException,XMLExcepts::Parser_CC5); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC5, getMemoryManager()); } break; } // end if REGX_T_XMLSCHEMA... @@ -296,7 +299,7 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { || ch == chDash)) { // '[', ']', '-' not allowed and should be esacaped XMLCh chStr[] = { ch, chNull }; - ThrowXML2(ParseException,XMLExcepts::Parser_CC6, chStr, chStr); + ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, chStr, chStr, getMemoryManager()); } if (getState() != REGX_T_CHAR || getCharData() != chDash) { @@ -306,13 +309,13 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { processNext(); if ((type = getState()) == REGX_T_EOF) - ThrowXML(ParseException,XMLExcepts::Parser_CC2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC2, getMemoryManager()); if ((type == REGX_T_CHAR && getCharData() == chCloseSquare) || type == REGX_T_XMLSCHEMA_CC_SUBTRACTION) { static const XMLCh dashStr[] = { chDash, chNull}; - ThrowXML2(ParseException, XMLExcepts::Parser_CC6, dashStr, dashStr); + ThrowXMLwithMemMgr2(ParseException, XMLExcepts::Parser_CC6, dashStr, dashStr, getMemoryManager()); } else { @@ -325,7 +328,7 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { || rangeEnd == chCloseSquare || rangeEnd == chDash) // '[', ']', '-' not allowed and should be esacaped - ThrowXML2(ParseException, XMLExcepts::Parser_CC6, rangeEndStr, rangeEndStr); + ThrowXMLwithMemMgr2(ParseException, XMLExcepts::Parser_CC6, rangeEndStr, rangeEndStr, getMemoryManager()); } else if (type == REGX_T_BACKSOLIDUS) { rangeEnd = decodeEscaped(); @@ -335,7 +338,7 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { if (ch > rangeEnd) { XMLCh chStr[] = { ch, chNull }; - ThrowXML2(ParseException,XMLExcepts::Parser_Ope3, rangeEndStr, chStr); + ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_Ope3, rangeEndStr, chStr, getMemoryManager()); } tok->addRange(ch, rangeEnd); @@ -346,7 +349,7 @@ RangeToken* ParserForXMLSchema::parseCharacterClass(const bool useNRange) { } if (getState() == REGX_T_EOF) - ThrowXML(ParseException,XMLExcepts::Parser_CC2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC2, getMemoryManager()); tok->sortRanges(); tok->compactRanges(); @@ -365,25 +368,25 @@ XMLInt32 ParserForXMLSchema::processCInCharacterClass(RangeToken* const tok, Token* ParserForXMLSchema::processLook(const unsigned short tokType) { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_A() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_B() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_b() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } @@ -401,13 +404,13 @@ Token* ParserForXMLSchema::processBacksolidus_c() { Token* ParserForXMLSchema::processBacksolidus_g() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_gt() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } @@ -425,61 +428,61 @@ Token* ParserForXMLSchema::processBacksolidus_i() { Token* ParserForXMLSchema::processBacksolidus_lt() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_X() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_Z() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBacksolidus_z() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processBackReference() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processCondition() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processIndependent() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processModifiers() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } Token* ParserForXMLSchema::processParen2() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } RangeToken* ParserForXMLSchema::parseSetOperations() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager()); return 0; // for compilers that complain about no return value } @@ -526,7 +529,7 @@ bool ParserForXMLSchema::checkQuestion(const int off) { XMLInt32 ParserForXMLSchema::decodeEscaped() { if (getState() != REGX_T_BACKSOLIDUS) - ThrowXML(ParseException,XMLExcepts::Parser_Next1);; + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next1, getMemoryManager()); XMLInt32 ch = getCharData(); @@ -559,7 +562,7 @@ XMLInt32 ParserForXMLSchema::decodeEscaped() { { XMLCh chString[] = {chBackSlash, ch, chNull}; chString[1] = ch; - ThrowXML1(ParseException,XMLExcepts::Parser_Process2, chString); + ThrowXMLwithMemMgr1(ParseException,XMLExcepts::Parser_Process2, chString, getMemoryManager()); } } diff --git a/src/xercesc/util/regx/RangeToken.cpp b/src/xercesc/util/regx/RangeToken.cpp index 0446b5132abe2c118a6359177c050559077d392a..30f19389b40ea6bec5eb77475ddcb0c9f26db649 100644 --- a/src/xercesc/util/regx/RangeToken.cpp +++ b/src/xercesc/util/regx/RangeToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/05/16 21:37:00 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * @@ -126,7 +129,7 @@ const unsigned int RangeToken::INITIALSIZE = 16; // --------------------------------------------------------------------------- RangeToken::RangeToken(const unsigned short tokType, MemoryManager* const manager) - : Token(tokType) + : Token(tokType, manager) , fSorted(false) , fCompacted(false) , fNonMapIndex(0) @@ -307,7 +310,7 @@ void RangeToken::compactRanges() { target += 2; } else { - ThrowXML(RuntimeException, XMLExcepts::Regex_CompactRangesError); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_CompactRangesError, fMemoryManager); } } // inner while @@ -322,7 +325,7 @@ void RangeToken::mergeRanges(const Token *const tok) { if (tok->getTokenType() != this->getTokenType()) - ThrowXML(IllegalArgumentException, XMLExcepts::Regex_MergeRangesTypeMismatch); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Regex_MergeRangesTypeMismatch, fMemoryManager); RangeToken* rangeTok = (RangeToken *) tok; @@ -460,7 +463,7 @@ void RangeToken::subtractRanges(RangeToken* const tok) { } else { fMemoryManager->deallocate(result);//delete [] result; - ThrowXML(RuntimeException, XMLExcepts::Regex_SubtractRangesError); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_SubtractRangesError, fMemoryManager); } } //end while @@ -556,7 +559,7 @@ void RangeToken::intersectRanges(RangeToken* const tok) { else { fMemoryManager->deallocate(result);//delete [] result; - ThrowXML(RuntimeException, XMLExcepts::Regex_IntersectRangesError); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_IntersectRangesError, fMemoryManager); } } //end while @@ -571,10 +574,11 @@ void RangeToken::intersectRanges(RangeToken* const tok) { * for NRANGE: Creates the same meaning RANGE. */ Token* RangeToken::complementRanges(RangeToken* const tok, - TokenFactory* const tokFactory) { + TokenFactory* const tokFactory, + MemoryManager* const manager) { if (tok->getTokenType() != T_RANGE && tok->getTokenType() != T_NRANGE) - ThrowXML(IllegalArgumentException, XMLExcepts::Regex_ComplementRangesInvalidArg); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Regex_ComplementRangesInvalidArg, manager); tok->sortRanges(); tok->compactRanges(); diff --git a/src/xercesc/util/regx/RangeToken.hpp b/src/xercesc/util/regx/RangeToken.hpp index d32bf38ad2367f2b4c6b1a97f33747933a1d0e29..f116f960d9004d109d498511a32dd65c9b01065b 100644 --- a/src/xercesc/util/regx/RangeToken.hpp +++ b/src/xercesc/util/regx/RangeToken.hpp @@ -110,7 +110,8 @@ public: void subtractRanges(RangeToken* const tok); void intersectRanges(RangeToken* const tok); static Token* complementRanges(RangeToken* const tok, - TokenFactory* const tokFactory); + TokenFactory* const tokFactory, + MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); // ----------------------------------------------------------------------- // Match methods diff --git a/src/xercesc/util/regx/RangeTokenMap.cpp b/src/xercesc/util/regx/RangeTokenMap.cpp index 1cba3c0661090306ada60f80de9775ed65a1cde8..13d06e733e4af9bc016dffff7b59a6b990fd7509 100644 --- a/src/xercesc/util/regx/RangeTokenMap.cpp +++ b/src/xercesc/util/regx/RangeTokenMap.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/17 16:44:34 knoaman * Fix multithreading problem. * @@ -162,7 +165,6 @@ RangeTokenMap::~RangeTokenMap() { delete fCategories; fCategories = 0; - delete fTokenFactory; fTokenFactory = 0; } @@ -207,7 +209,7 @@ RangeToken* RangeTokenMap::getRange(const XMLCh* const keyword, if (complement) { - rangeTok = (RangeToken*) RangeToken::complementRanges(rangeTok, fTokenFactory); + rangeTok = (RangeToken*) RangeToken::complementRanges(rangeTok, fTokenFactory, fTokenRegistry->getMemoryManager()); elemMap->setRangeToken(rangeTok , complement); } } @@ -242,7 +244,7 @@ void RangeTokenMap::addKeywordMap(const XMLCh* const keyword, unsigned int categId = fCategories->getId(categoryName); if (categId == 0) { - ThrowXML1(RuntimeException, XMLExcepts::Regex_InvalidCategoryName, categoryName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_InvalidCategoryName, categoryName, fTokenRegistry->getMemoryManager()); } if (fTokenRegistry->containsKey(keyword)) { @@ -271,7 +273,7 @@ void RangeTokenMap::setRangeToken(const XMLCh* const keyword, fTokenRegistry->get(keyword)->setRangeToken(tok, complement); } else { - ThrowXML1(RuntimeException, XMLExcepts::Regex_KeywordNotFound, keyword); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_KeywordNotFound, keyword, fTokenRegistry->getMemoryManager()); } } diff --git a/src/xercesc/util/regx/RegularExpression.cpp b/src/xercesc/util/regx/RegularExpression.cpp index 12f528eb5d0857aa9d2e5a7fdb6c09f5652e6652..37ced88cb9d322830a96fd7a66cfb0b316675864 100644 --- a/src/xercesc/util/regx/RegularExpression.cpp +++ b/src/xercesc/util/regx/RegularExpression.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.16 2003/12/16 12:25:48 cargilld * Change a conditional expression to an if-else to avoid a compiler problem. * @@ -461,60 +464,67 @@ void RegularExpression::setPattern(const XMLCh* const pattern, // --------------------------------------------------------------------------- // RegularExpression: Matching methods // --------------------------------------------------------------------------- -bool RegularExpression::matches(const char* const expression) { +bool RegularExpression::matches(const char* const expression + , MemoryManager* const manager) { - XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager); - ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager); - return matches(tmpBuf, 0, XMLString::stringLen(tmpBuf), 0); + XMLCh* tmpBuf = XMLString::transcode(expression, manager); + ArrayJanitor<XMLCh> janBuf(tmpBuf, manager); + return matches(tmpBuf, 0, XMLString::stringLen(tmpBuf), 0, manager); } bool RegularExpression::matches(const char* const expression, - const int start, const int end) { + const int start, const int end + , MemoryManager* const manager) { - XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager); - ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager); - return matches(tmpBuf, start, end, 0); + XMLCh* tmpBuf = XMLString::transcode(expression, manager); + ArrayJanitor<XMLCh> janBuf(tmpBuf, manager); + return matches(tmpBuf, start, end, 0, manager); } bool RegularExpression::matches(const char* const expression, - Match* const match) { + Match* const match + , MemoryManager* const manager) { - XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager); - ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager); - return matches(tmpBuf, 0, XMLString::stringLen(tmpBuf), match); + XMLCh* tmpBuf = XMLString::transcode(expression, manager); + ArrayJanitor<XMLCh> janBuf(tmpBuf, manager); + return matches(tmpBuf, 0, XMLString::stringLen(tmpBuf), match, manager); } bool RegularExpression::matches(const char* const expression, const int start, - const int end, Match* const pMatch) { + const int end, Match* const pMatch + , MemoryManager* const manager) { - XMLCh* tmpBuf = XMLString::transcode(expression, fMemoryManager); - ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager); - return matches(tmpBuf, start, end, pMatch); + XMLCh* tmpBuf = XMLString::transcode(expression, manager); + ArrayJanitor<XMLCh> janBuf(tmpBuf, manager); + return matches(tmpBuf, start, end, pMatch, manager); } // --------------------------------------------------------------------------- // RegularExpression: Matching methods - Wide char version // --------------------------------------------------------------------------- -bool RegularExpression::matches(const XMLCh* const expression) { +bool RegularExpression::matches(const XMLCh* const expression, MemoryManager* const manager) { - return matches(expression, 0, XMLString::stringLen(expression), 0); + return matches(expression, 0, XMLString::stringLen(expression), 0, manager); } bool RegularExpression::matches(const XMLCh* const expression, - const int start, const int end) { + const int start, const int end + , MemoryManager* const manager) { - return matches(expression, start, end, 0); + return matches(expression, start, end, 0, manager); } bool RegularExpression::matches(const XMLCh* const expression, - Match* const match) { + Match* const match + , MemoryManager* const manager) { - return matches(expression, 0, XMLString::stringLen(expression), match); + return matches(expression, 0, XMLString::stringLen(expression), match, manager); } bool RegularExpression::matches(const XMLCh* const expression, const int start, - const int end, Match* const pMatch) { + const int end, Match* const pMatch + , MemoryManager* const manager) { if (fOperations == 0) prepare(); @@ -530,7 +540,7 @@ bool RegularExpression::matches(const XMLCh* const expression, const int start, fContext = new (fMemoryManager) Context(fMemoryManager); if (fContext->fInUse) { - context = new (fMemoryManager) Context(fMemoryManager); + context = new (manager) Context(manager); tmpContext = context; } else { @@ -845,7 +855,7 @@ RefArrayVectorOf<XMLCh>* RegularExpression::tokenize(const XMLCh* const expressi ( (matchStart + 1 - tokStart) * sizeof(XMLCh) );//new XMLCh[matchStart + 1 - tokStart]; - XMLString::subString(token, expression, tokStart, matchStart); + XMLString::subString(token, expression, tokStart, matchStart, fMemoryManager); tokenStack->addElement(token); } @@ -868,7 +878,7 @@ RefArrayVectorOf<XMLCh>* RegularExpression::tokenize(const XMLCh* const expressi ( (strLength + 1 - tokStart) * sizeof(XMLCh) );//new XMLCh[strLength + 1 - tokStart]; - XMLString::subString(token, expression, tokStart, strLength); + XMLString::subString(token, expression, tokStart, strLength, fMemoryManager); } if (!XMLString::equals(fPattern, &chNull)) @@ -922,9 +932,12 @@ XMLCh* RegularExpression::replace(const XMLCh* const matchString, const XMLCh* const replaceString, const int start, const int end) { + // REVISIT:: cargillmem - subEx is temporary... replicate was modified below + // but there is also a call to delete[]!!! + //check if matches zero length string - throw error if so - if (matches(XMLUni::fgZeroLenString)){ - ThrowXML(RuntimeException, XMLExcepts::Regex_RepPatMatchesZeroString); + if (matches(XMLUni::fgZeroLenString, fMemoryManager)){ + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_RepPatMatchesZeroString, fMemoryManager); } RefVectorOf<Match> *subEx = new (fMemoryManager) RefVectorOf<Match>(10, true, fMemoryManager); @@ -943,7 +956,7 @@ XMLCh* RegularExpression::replace(const XMLCh* const matchString, numSubEx = subEx->elementAt(0)->getNoGroups() - 1; int tokStackSize = tokenStack->size(); - const XMLCh* curRepString = XMLString::replicate(replaceString); + const XMLCh* curRepString = XMLString::replicate(replaceString, fMemoryManager); for (int i = 0; i < tokStackSize; i++){ @@ -962,7 +975,7 @@ XMLCh* RegularExpression::replace(const XMLCh* const matchString, } delete[] (XMLCh*)curRepString; - return XMLString::replicate(result.getRawBuffer()); + return XMLString::replicate(result.getRawBuffer(), fMemoryManager); } @@ -1356,7 +1369,7 @@ bool RegularExpression::matchBackReference(Context* const context, const bool ignoreCase) { if (refNo <=0 || refNo >= fNoGroups) - ThrowXML(IllegalArgumentException, XMLExcepts::Regex_BadRefNo); + ThrowXMLwithMemMgr(IllegalArgumentException, XMLExcepts::Regex_BadRefNo, fMemoryManager); if (context->fMatch->getStartPos(refNo) < 0 || context->fMatch->getEndPos(refNo) < 0) @@ -1457,7 +1470,7 @@ int RegularExpression::parseOptions(const XMLCh* const options) int v = getOptionValue(options[i]); if (v == 0) - ThrowXML1(ParseException, XMLExcepts::Regex_UnknownOption, options); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Regex_UnknownOption, options, fMemoryManager); opts |= v; } @@ -1521,7 +1534,7 @@ Op* RegularExpression::compile(const Token* const token, Op* const next, ret = compileCondition(token, next, reverse); break; default: - ThrowXML(RuntimeException, XMLExcepts::Regex_UnknownTokenType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_UnknownTokenType, fMemoryManager); break; // this line to be deleted } @@ -1544,7 +1557,7 @@ const XMLCh* RegularExpression::subInExp(const XMLCh* const repString, int numSubExp = subEx->getNoGroups() - 1; if (numSubExp == 0) - return XMLString::replicate(repString); + return XMLString::replicate(repString, fMemoryManager); bool notEscaped = true; @@ -1565,15 +1578,15 @@ const XMLCh* RegularExpression::subInExp(const XMLCh* const repString, if (!XMLString::isDigit(*ptr)){ //invalid replace string - $ must be followed by a digit - ThrowXML(RuntimeException, XMLExcepts::Regex_InvalidRepPattern); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_InvalidRepPattern, fMemoryManager); } indexStr[0] = *ptr; //get the digit - index = XMLString::parseInt(indexStr); //convert it to an int + index = XMLString::parseInt(indexStr, fMemoryManager); //convert it to an int //now check that the index is legal if (index > numSubExp){ - ThrowXML(RuntimeException, XMLExcepts::Regex_InvalidRepPattern); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_InvalidRepPattern, fMemoryManager); } int start = subEx->getStartPos(index); @@ -1589,7 +1602,7 @@ const XMLCh* RegularExpression::subInExp(const XMLCh* const repString, //if you have a slash and then a character that's not a $ or /, //then it's an invalid replace string if (!notEscaped && (*ptr != chDollarSign && *ptr != chBackSlash)){ - ThrowXML(RuntimeException, XMLExcepts::Regex_InvalidRepPattern); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_InvalidRepPattern, fMemoryManager); } if (*ptr == chBackSlash){ @@ -1603,7 +1616,7 @@ const XMLCh* RegularExpression::subInExp(const XMLCh* const repString, } } - return XMLString::replicate(newString.getRawBuffer()); + return XMLString::replicate(newString.getRawBuffer(), fMemoryManager); } @@ -1699,7 +1712,7 @@ unsigned short RegularExpression::getCharType(const XMLCh ch) { fWordRange = fTokenFactory->getRange(fgUniIsWord); if (fWordRange == 0) - ThrowXML1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord, fMemoryManager); } return fWordRange->match(ch) ? WT_LETTER : WT_OTHER; diff --git a/src/xercesc/util/regx/RegularExpression.hpp b/src/xercesc/util/regx/RegularExpression.hpp index 13c6c8ddc52273b8c8337f29e5c59a52ec07a32e..8446994432af60f088f6dd7ff938e4d07a868802 100644 --- a/src/xercesc/util/regx/RegularExpression.hpp +++ b/src/xercesc/util/regx/RegularExpression.hpp @@ -139,19 +139,19 @@ public: // ----------------------------------------------------------------------- // Matching methods // ----------------------------------------------------------------------- - bool matches(const char* const matchString); + bool matches(const char* const matchString, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager); bool matches(const char* const matchString, const int start, - const int end); - bool matches(const char* const matchString, Match* const pMatch); + const int end, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager); + bool matches(const char* const matchString, Match* const pMatch, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager); bool matches(const char* const matchString, const int start, - const int end, Match* const pMatch); + const int end, Match* const pMatch, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager); - bool matches(const XMLCh* const matchString); + bool matches(const XMLCh* const matchString, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager);; bool matches(const XMLCh* const matchString, const int start, - const int end); - bool matches(const XMLCh* const matchString, Match* const pMatch); + const int end, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager); + bool matches(const XMLCh* const matchString, Match* const pMatch, MemoryManager* const manager);// = XMLPlatformUtils::fgMemoryManager); bool matches(const XMLCh* const matchString, const int start, - const int end, Match* const pMatch); + const int end, Match* const pMatch, MemoryManager* const manage); // = XMLPlatformUtils::fgMemoryManager); // ----------------------------------------------------------------------- // Tokenize methods diff --git a/src/xercesc/util/regx/RegxParser.cpp b/src/xercesc/util/regx/RegxParser.cpp index 8bb955fc79989aa1177ae84f61aa7c29ed4ff08c..72b2d3c0ffb12a9de60f3e02cd4208514485db97 100644 --- a/src/xercesc/util/regx/RegxParser.cpp +++ b/src/xercesc/util/regx/RegxParser.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/05/18 14:02:06 knoaman * Memory manager implementation: pass per instance manager. * @@ -219,7 +222,7 @@ Token* RegxParser::parse(const XMLCh* const regxStr, const int options) { Token* retTok = parseRegx(); if (fOffset != fStringLen) { - ThrowXML(ParseException,XMLExcepts::Parser_Parse1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Parse1, fMemoryManager); } if (fReferences != 0) { @@ -228,7 +231,7 @@ Token* RegxParser::parse(const XMLCh* const regxStr, const int options) { for (unsigned int i = 0; i < refSize; i++) { if (fNoGroups <= fReferences->elementAt(i)->fReferenceNo) { - ThrowXML(ParseException,XMLExcepts::Parser_Parse2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Parse2, fMemoryManager); } } @@ -259,7 +262,7 @@ void RegxParser::processNext() { nextState = REGX_T_BACKSOLIDUS; if (fOffset >= fStringLen) { - ThrowXML(ParseException,XMLExcepts::Parser_Next1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next1, fMemoryManager); } fCharData = fString[fOffset++]; @@ -342,7 +345,7 @@ void RegxParser::processNext() { break; if (++fOffset >= fStringLen) - ThrowXML(ParseException,XMLExcepts::Parser_Next2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next2, fMemoryManager); ch = fString[fOffset++]; @@ -364,7 +367,7 @@ void RegxParser::processNext() { break; case chOpenAngle: if (fOffset >= fStringLen) - ThrowXML(ParseException,XMLExcepts::Parser_Next2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next2, fMemoryManager); ch = fString[fOffset++]; @@ -375,7 +378,7 @@ void RegxParser::processNext() { nextState = REGX_T_NEGATIVELOOKBEHIND; } else { - ThrowXML(ParseException,XMLExcepts::Parser_Next3); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next3, fMemoryManager); } break; case chPound: @@ -387,7 +390,7 @@ void RegxParser::processNext() { } if (ch != chCloseParen) - ThrowXML(ParseException,XMLExcepts::Parser_Next4); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next4, fMemoryManager); nextState = REGX_T_COMMENT; break; @@ -403,14 +406,14 @@ void RegxParser::processNext() { nextState = REGX_T_CONDITION; break; } - ThrowXML(ParseException,XMLExcepts::Parser_Next2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next2, fMemoryManager); } } break; case chBackSlash: nextState = REGX_T_BACKSOLIDUS; if (fOffset >= fStringLen) { - ThrowXML(ParseException,XMLExcepts::Parser_Next1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next1, fMemoryManager); } fCharData = fString[fOffset++]; @@ -507,7 +510,7 @@ Token* RegxParser::processLook(const unsigned short tokType) { Token* tok = fTokenFactory->createLook(tokType, parseRegx()); if (fState != REGX_T_RPAREN) { - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); } processNext(); @@ -624,7 +627,7 @@ Token* RegxParser::processParen() { Token* tok = fTokenFactory->createParenthesis(parseRegx(true),num); if (fState != REGX_T_RPAREN) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); processNext(); return tok; @@ -637,7 +640,7 @@ Token* RegxParser::processParen2() { Token* tok = fTokenFactory->createParenthesis(parseRegx(), 0); if (fState != REGX_T_RPAREN) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); processNext(); return tok; @@ -647,7 +650,7 @@ Token* RegxParser::processParen2() { Token* RegxParser::processCondition() { if (fOffset + 1 >= fStringLen) - ThrowXML(ParseException,XMLExcepts::Parser_Factor4); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor4, fMemoryManager); int refNo = -1; Token* conditionTok = 0; @@ -666,7 +669,7 @@ Token* RegxParser::processCondition() { fOffset++; if (fString[fOffset] != chCloseParen) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); fOffset++; } @@ -686,10 +689,10 @@ Token* RegxParser::processCondition() { break; case Token::T_ANCHOR: if (fState != REGX_T_RPAREN) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); break; default: - ThrowXML(ParseException,XMLExcepts::Parser_Factor5); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor5, fMemoryManager); } } @@ -700,14 +703,14 @@ Token* RegxParser::processCondition() { if (yesPattern->getTokenType() == Token::T_UNION) { if (yesPattern->size() != 2) - ThrowXML(ParseException,XMLExcepts::Parser_Factor6); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor6, fMemoryManager); noPattern = yesPattern->getChild(1); yesPattern = yesPattern->getChild(0); } if (fState != REGX_T_RPAREN) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); processNext(); return fTokenFactory->createCondition(refNo,conditionTok, @@ -736,7 +739,7 @@ Token* RegxParser::processModifiers() { } // end while if (fOffset >= fStringLen) - ThrowXML(ParseException,XMLExcepts::Parser_Factor2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor2, fMemoryManager); if (ch == chDash) { @@ -753,7 +756,7 @@ Token* RegxParser::processModifiers() { } if (fOffset >= fStringLen) - ThrowXML(ParseException,XMLExcepts::Parser_Factor2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor2, fMemoryManager); } Token* tok = 0; @@ -765,7 +768,7 @@ Token* RegxParser::processModifiers() { tok = fTokenFactory->createModifierGroup(parseRegx(),add,mask); if (fState != REGX_T_RPAREN) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); processNext(); } @@ -776,7 +779,7 @@ Token* RegxParser::processModifiers() { tok = fTokenFactory->createModifierGroup(parseRegx(),add,mask); } else { - ThrowXML(ParseException,XMLExcepts::Parser_Factor3); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor3, fMemoryManager); } return tok; @@ -790,7 +793,7 @@ Token* RegxParser::processIndependent() { Token* tok = fTokenFactory->createLook(Token::T_INDEPENDENT, parseRegx()); if (fState != REGX_T_RPAREN) - ThrowXML(ParseException,XMLExcepts::Parser_Factor1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager); processNext(); return tok; @@ -803,7 +806,7 @@ Token* RegxParser::processBacksolidus_c() { if (fOffset >= fStringLen || ((ch = fString[fOffset++]) & 0xFFE0) != 0x0040) - ThrowXML(ParseException,XMLExcepts::Parser_Atom1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom1, fMemoryManager); processNext(); return fTokenFactory->createChar(ch - 0x40); @@ -926,10 +929,10 @@ Token* RegxParser::parseFactor() { } if (min < 0) - ThrowXML1(ParseException, XMLExcepts::Parser_Quantifier5, fString); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Parser_Quantifier5, fString, fMemoryManager); } else { - ThrowXML1(ParseException, XMLExcepts::Parser_Quantifier1, fString); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Parser_Quantifier1, fString, fMemoryManager); } max = min; @@ -937,7 +940,7 @@ Token* RegxParser::parseFactor() { if (ch == chComma) { if (fOffset >= fStringLen) { - ThrowXML1(ParseException, XMLExcepts::Parser_Quantifier3, fString); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Parser_Quantifier3, fString, fMemoryManager); } else if ((ch = fString[fOffset++]) >= chDigit_0 && ch <= chDigit_9) { @@ -950,9 +953,9 @@ Token* RegxParser::parseFactor() { } if (max < 0) - ThrowXML1(ParseException, XMLExcepts::Parser_Quantifier5, fString); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Parser_Quantifier5, fString, fMemoryManager); else if (min > max) - ThrowXML1(ParseException, XMLExcepts::Parser_Quantifier4, fString); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Parser_Quantifier4, fString, fMemoryManager); } else { max = -1; @@ -960,7 +963,7 @@ Token* RegxParser::parseFactor() { } if (ch != chCloseCurly) { - ThrowXML1(ParseException, XMLExcepts::Parser_Quantifier2, fString); + ThrowXMLwithMemMgr1(ParseException, XMLExcepts::Parser_Quantifier2, fString, fMemoryManager); } if (checkQuestion(fOffset)) { @@ -1048,7 +1051,7 @@ Token* RegxParser::parseAtom() { int start = fOffset; tok = processBacksolidus_pP(fCharData); if (tok == 0) { - ThrowXML(ParseException,XMLExcepts::Parser_Atom5); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom5, fMemoryManager); } } break; @@ -1074,13 +1077,13 @@ Token* RegxParser::parseAtom() { if (fCharData == chOpenCurly || fCharData == chCloseCurly || fCharData == chCloseSquare) - ThrowXML(ParseException,XMLExcepts::Parser_Atom4); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom4, fMemoryManager); tok = fTokenFactory->createChar(fCharData); processNext(); break; default: - ThrowXML(ParseException,XMLExcepts::Parser_Atom4); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom4, fMemoryManager); } //end switch return tok; @@ -1092,13 +1095,13 @@ RangeToken* RegxParser::processBacksolidus_pP(const XMLInt32 ch) { processNext(); if (fState != REGX_T_CHAR || fCharData != chOpenCurly) - ThrowXML(ParseException,XMLExcepts::Parser_Atom2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom2, fMemoryManager); int nameStart = fOffset; - int nameEnd = XMLString::indexOf(fString,chCloseCurly,nameStart); + int nameEnd = XMLString::indexOf(fString,chCloseCurly,nameStart, fMemoryManager); if (nameEnd < 0) - ThrowXML(ParseException,XMLExcepts::Parser_Atom3); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom3, fMemoryManager); fOffset = nameEnd + 1; XMLCh* rangeName = (XMLCh*) fMemoryManager->allocate @@ -1106,7 +1109,7 @@ RangeToken* RegxParser::processBacksolidus_pP(const XMLInt32 ch) { (nameEnd - nameStart + 1) * sizeof(XMLCh) );//new XMLCh[(nameEnd - nameStart) + 1]; ArrayJanitor<XMLCh> janRangeName(rangeName, fMemoryManager); - XMLString::subString(rangeName, fString, nameStart, nameEnd); + XMLString::subString(rangeName, fString, nameStart, nameEnd, fMemoryManager); return fTokenFactory->getRange(rangeName, !(ch == chLatin_p)); } @@ -1186,7 +1189,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { RangeToken* tok2 = processBacksolidus_pP(ch); if (tok2 == 0) { - ThrowXML(ParseException,XMLExcepts::Parser_Atom5); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Atom5, fMemoryManager); } tok->mergeRanges(tok2); @@ -1199,10 +1202,10 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { } // end if REGX_T_BACKSOLIDUS else if (fState == REGX_T_POSIX_CHARCLASS_START) { - int nameEnd = XMLString::indexOf(fString, chColon, fOffset); + int nameEnd = XMLString::indexOf(fString, chColon, fOffset, fMemoryManager); if (nameEnd < 0) { - ThrowXML(ParseException,XMLExcepts::Parser_CC1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC1, fMemoryManager); } bool positive = true; @@ -1219,18 +1222,18 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { );//new XMLCh[(nameEnd - fOffset) + 1]; ArrayJanitor<XMLCh> janName(name, fMemoryManager); - XMLString::subString(name, fString, fOffset, nameEnd); + XMLString::subString(name, fString, fOffset, nameEnd, fMemoryManager); RangeToken* rangeTok = fTokenFactory->getRange(name, !positive); if (rangeTok == 0) { - ThrowXML(ParseException,XMLExcepts::Parser_CC3); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC3, fMemoryManager); } tok->mergeRanges(rangeTok); end = true; if (nameEnd+1 >= fStringLen || fString[nameEnd+1] != chCloseSquare) { - ThrowXML(ParseException,XMLExcepts::Parser_CC1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC1, fMemoryManager); } fOffset = nameEnd + 2; @@ -1247,7 +1250,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { processNext(); if (fState == REGX_T_EOF) - ThrowXML(ParseException,XMLExcepts::Parser_CC2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC2, fMemoryManager); if (fState == REGX_T_CHAR && fCharData == chCloseSquare) { @@ -1275,7 +1278,7 @@ RangeToken* RegxParser::parseCharacterClass(const bool useNRange) { } // end while fState if (fState == REGX_T_EOF) { - ThrowXML(ParseException,XMLExcepts::Parser_CC2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC2, fMemoryManager); } if (!useNRange && nRange) { @@ -1305,7 +1308,7 @@ RangeToken* RegxParser::parseSetOperations() { processNext(); if (fState != REGX_T_LBRACKET) - ThrowXML(ParseException,XMLExcepts::Parser_Ope1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Ope1, fMemoryManager); RangeToken* tok2 = parseCharacterClass(false); @@ -1319,11 +1322,11 @@ RangeToken* RegxParser::parseSetOperations() { tok->intersectRanges(tok2); } else { - throw 0; // ThrowXML(RuntimeException, "ASSERT") + throw 0; // ThrowXMLwithMemMgr(RuntimeException, "ASSERT") } } else { - ThrowXML(ParseException,XMLExcepts::Parser_Ope2); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Ope2, fMemoryManager); } } @@ -1361,7 +1364,7 @@ Token* RegxParser::getTokenForShorthand(const XMLInt32 ch) { tok = useUnicode ? fTokenFactory->getRange(fgUniIsSpace, true) : fTokenFactory->getRange(fgASCIISpace, true); // default: -// ThrowXML(RuntimeException, "Invalid shorthand {0}", chAsString) +// ThrowXMLwithMemMgr(RuntimeException, "Invalid shorthand {0}", chAsString) } return tok; @@ -1371,7 +1374,7 @@ Token* RegxParser::getTokenForShorthand(const XMLInt32 ch) { XMLInt32 RegxParser::decodeEscaped() { if (fState != REGX_T_BACKSOLIDUS) - ThrowXML(ParseException,XMLExcepts::Parser_Next1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Next1, fMemoryManager); XMLInt32 ch = fCharData; @@ -1395,7 +1398,7 @@ XMLInt32 RegxParser::decodeEscaped() { { processNext(); if (fState != REGX_T_CHAR) { - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); } if (fCharData == chOpenCurly) { @@ -1405,7 +1408,7 @@ XMLInt32 RegxParser::decodeEscaped() { do { processNext(); if (fState != REGX_T_CHAR) - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); if ((v1 = hexChar(fCharData)) < 0) break; @@ -1414,23 +1417,23 @@ XMLInt32 RegxParser::decodeEscaped() { } while (true); if (fCharData != chCloseCurly) - ThrowXML(ParseException,XMLExcepts::Parser_Descape3); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape3, fMemoryManager); if (uv > Token::UTF16_MAX) - ThrowXML(ParseException,XMLExcepts::Parser_Descape4); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape4, fMemoryManager); ch = uv; } else { int v1 = 0; if (fState != REGX_T_CHAR || (v1 = hexChar(fCharData)) < 0) - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); int uv = v1; processNext(); if (fState != REGX_T_CHAR || (v1 = hexChar(fCharData)) < 0) - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); ch = uv*16 + v1; } @@ -1445,7 +1448,7 @@ XMLInt32 RegxParser::decodeEscaped() { processNext(); if (fState != REGX_T_CHAR || (v1 = hexChar(fCharData)) < 0) - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); uv = (i == 0) ? v1 : uv*16 + v1; } @@ -1462,13 +1465,13 @@ XMLInt32 RegxParser::decodeEscaped() { processNext(); if (fState != REGX_T_CHAR || (v1 = hexChar(fCharData)) < 0) - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); uv = (i == 0) ? v1 : uv*16 + v1; } if (uv > Token::UTF16_MAX) - ThrowXML(ParseException,XMLExcepts::Parser_Descape1); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape1, fMemoryManager); ch = uv; } @@ -1476,7 +1479,7 @@ XMLInt32 RegxParser::decodeEscaped() { case chLatin_A: case chLatin_Z: case chLatin_z: - ThrowXML(ParseException,XMLExcepts::Parser_Descape5); + ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Descape5, fMemoryManager); } // end switch return ch; diff --git a/src/xercesc/util/regx/RegxParser.hpp b/src/xercesc/util/regx/RegxParser.hpp index 19acf58fabb2d53d4efc0e505d948d913abb88d8..188ba0d63b5cab3c1aa55f10dc12276027b5d569 100644 --- a/src/xercesc/util/regx/RegxParser.hpp +++ b/src/xercesc/util/regx/RegxParser.hpp @@ -154,7 +154,7 @@ protected: // ----------------------------------------------------------------------- virtual bool checkQuestion(const int off); virtual XMLInt32 decodeEscaped(); - + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- // Protected Parsing/Processing methods // ----------------------------------------------------------------------- @@ -279,6 +279,9 @@ inline TokenFactory* RegxParser::getTokenFactory() const { return fTokenFactory; } +inline MemoryManager* RegxParser::getMemoryManager() const { + return fMemoryManager; +} // --------------------------------------------------------------------------- // RegxParser: Setter Methods // --------------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/StringToken.cpp b/src/xercesc/util/regx/StringToken.cpp index 7f60df6cb05af7446ec7d643a107b64e8d4f9923..41fe4c306c025fd00bd139b7756541962d161891 100644 --- a/src/xercesc/util/regx/StringToken.cpp +++ b/src/xercesc/util/regx/StringToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/05/16 00:03:10 knoaman * Partial implementation of the configurable memory manager. * @@ -87,7 +90,7 @@ StringToken::StringToken(const unsigned short tokType, const XMLCh* const literal, const int refNo, MemoryManager* const manager) - : Token(tokType) + : Token(tokType, manager) , fString(XMLString::replicate(literal, manager)) , fRefNo(refNo) , fMemoryManager(manager) diff --git a/src/xercesc/util/regx/Token.cpp b/src/xercesc/util/regx/Token.cpp index 9c957ff68427858c5f87a8c8e25b52ea51e8cf8f..9d1643997d16004992dd005f6d313ea22e510224 100644 --- a/src/xercesc/util/regx/Token.cpp +++ b/src/xercesc/util/regx/Token.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2002/11/21 14:56:35 gareth * Fixed bug in Token::analyzeFirstCharacter so that . matches new line with head character optimisation enabled. As per discussion Jennifer Schachter had with Khaled. * @@ -115,7 +118,11 @@ const unsigned short Token::FC_ANY = 2; // --------------------------------------------------------------------------- // Token: Constructors and Destructors // --------------------------------------------------------------------------- -Token::Token(const unsigned short tokType) : fTokenType(tokType) { +Token::Token(const unsigned short tokType + , MemoryManager* const manager) + : fTokenType(tokType) + , fMemoryManager(manager) +{ } @@ -375,11 +382,11 @@ int Token::analyzeFirstCharacter(RangeToken* const rangeTok, RangeToken* caseITok = (((RangeToken*) this)->getCaseInsensitiveToken(tokFactory)); - rangeTok->mergeRanges(RangeToken::complementRanges(caseITok, tokFactory)); + rangeTok->mergeRanges(RangeToken::complementRanges(caseITok, tokFactory, fMemoryManager)); } else { rangeTok->mergeRanges( - RangeToken::complementRanges((RangeToken*) this, tokFactory)); + RangeToken::complementRanges((RangeToken*) this, tokFactory, fMemoryManager)); } } case T_INDEPENDENT: diff --git a/src/xercesc/util/regx/Token.hpp b/src/xercesc/util/regx/Token.hpp index 169b040bf320aeeae37ea12dcc880bc1e64ff4ac..c17e4adcd0473fc620a826ab7b1ed0e10cb7880c 100644 --- a/src/xercesc/util/regx/Token.hpp +++ b/src/xercesc/util/regx/Token.hpp @@ -65,6 +65,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/util/RuntimeException.hpp> +#include <xercesc/util/PlatformUtils.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -81,7 +82,9 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - Token(const unsigned short tokType); + Token(const unsigned short tokType + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); virtual ~Token(); // ----------------------------------------------------------------------- @@ -177,6 +180,8 @@ private: // Private data members // ----------------------------------------------------------------------- unsigned short fTokenType; +protected: + MemoryManager* const fMemoryManager; }; @@ -254,7 +259,7 @@ inline bool Token::isSet(const int options, const unsigned int flag) { // --------------------------------------------------------------------------- inline void Token::addChild(Token* const, TokenFactory* const) { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } // --------------------------------------------------------------------------- @@ -262,32 +267,32 @@ inline void Token::addChild(Token* const, TokenFactory* const) { // --------------------------------------------------------------------------- inline void Token::addRange(const XMLInt32, const XMLInt32) { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } inline void Token::mergeRanges(const Token *const) { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } inline void Token::sortRanges() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } inline void Token::compactRanges() { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } inline void Token::subtractRanges(RangeToken* const) { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } inline void Token::intersectRanges(RangeToken* const) { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/regx/TokenFactory.cpp b/src/xercesc/util/regx/TokenFactory.cpp index df0da4ccc7e61b488768514f35841816fffd3489..8bfa3b0316e72445c22ba03eb8e010d26501cec6 100644 --- a/src/xercesc/util/regx/TokenFactory.cpp +++ b/src/xercesc/util/regx/TokenFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/10/17 16:44:34 knoaman * Fix multithreading problem. * @@ -214,7 +217,7 @@ Token* TokenFactory::createToken(const unsigned short tokType) { if (tokType == Token::T_EMPTY && fEmpty != 0) return fEmpty; - Token* tmpTok = new (fMemoryManager) Token(tokType); + Token* tmpTok = new (fMemoryManager) Token(tokType, fMemoryManager); if (tokType == Token::T_EMPTY) { fEmpty = tmpTok; @@ -229,7 +232,7 @@ Token* TokenFactory::createToken(const unsigned short tokType) { ParenToken* TokenFactory::createLook(const unsigned short tokType, Token* const token) { - ParenToken* tmpTok = new (fMemoryManager) ParenToken(tokType, token, 0); + ParenToken* tmpTok = new (fMemoryManager) ParenToken(tokType, token, 0, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -238,7 +241,7 @@ ParenToken* TokenFactory::createLook(const unsigned short tokType, ParenToken* TokenFactory::createParenthesis(Token* const token, const int noGroups) { - ParenToken* tmpTok = new (fMemoryManager) ParenToken(Token::T_PAREN, token, noGroups); + ParenToken* tmpTok = new (fMemoryManager) ParenToken(Token::T_PAREN, token, noGroups, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -247,8 +250,8 @@ ParenToken* TokenFactory::createParenthesis(Token* const token, ClosureToken* TokenFactory::createClosure(Token* const token, bool isNonGreedy) { - ClosureToken* tmpTok = isNonGreedy ? new (fMemoryManager) ClosureToken(Token::T_NONGREEDYCLOSURE, token) - : new (fMemoryManager) ClosureToken(Token::T_CLOSURE, token); + ClosureToken* tmpTok = isNonGreedy ? new (fMemoryManager) ClosureToken(Token::T_NONGREEDYCLOSURE, token, fMemoryManager) + : new (fMemoryManager) ClosureToken(Token::T_CLOSURE, token, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -257,7 +260,7 @@ ClosureToken* TokenFactory::createClosure(Token* const token, ConcatToken* TokenFactory::createConcat(Token* const token1, Token* const token2) { - ConcatToken* tmpTok = new (fMemoryManager) ConcatToken(token1, token2); + ConcatToken* tmpTok = new (fMemoryManager) ConcatToken(token1, token2, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -265,8 +268,8 @@ ConcatToken* TokenFactory::createConcat(Token* const token1, UnionToken* TokenFactory::createUnion(const bool isConcat) { - UnionToken* tmpTok = isConcat ? new (fMemoryManager) UnionToken(Token::T_CONCAT) - : new (fMemoryManager) UnionToken(Token::T_UNION); + UnionToken* tmpTok = isConcat ? new (fMemoryManager) UnionToken(Token::T_CONCAT, fMemoryManager) + : new (fMemoryManager) UnionToken(Token::T_UNION, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -286,8 +289,8 @@ RangeToken* TokenFactory::createRange(const bool isNegRange){ CharToken* TokenFactory::createChar(const XMLUInt32 ch, const bool isAnchor) { - CharToken* tmpTok = isAnchor ? new (fMemoryManager) CharToken(Token::T_ANCHOR, ch) - : new (fMemoryManager) CharToken(Token::T_CHAR, ch); + CharToken* tmpTok = isAnchor ? new (fMemoryManager) CharToken(Token::T_ANCHOR, ch, fMemoryManager) + : new (fMemoryManager) CharToken(Token::T_CHAR, ch, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -313,7 +316,7 @@ ModifierToken* TokenFactory::createModifierGroup(Token* const child, const int add, const int mask) { - ModifierToken* tmpTok = new (fMemoryManager) ModifierToken(child, add, mask); + ModifierToken* tmpTok = new (fMemoryManager) ModifierToken(child, add, mask, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; @@ -325,7 +328,7 @@ ConditionToken* TokenFactory::createCondition(const int refNo, Token* const noFlow) { ConditionToken* tmpTok = new (fMemoryManager) ConditionToken(refNo, condition, yesFlow, - noFlow); + noFlow, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; } diff --git a/src/xercesc/util/regx/UnicodeRangeFactory.cpp b/src/xercesc/util/regx/UnicodeRangeFactory.cpp index bd80b08c5f550e582416af944a230c325dabba4a..9b2437c4d94060b6ab0f1f192e80ae1d00105733 100644 --- a/src/xercesc/util/regx/UnicodeRangeFactory.cpp +++ b/src/xercesc/util/regx/UnicodeRangeFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2002/11/04 15:17:01 tng * C++ Namespace Support. * @@ -231,7 +234,7 @@ void UnicodeRangeFactory::buildRanges() { // Create assigned range tok = ranges[XMLUniCharacter::UNASSIGNED]; rangeTokMap->setRangeToken(fgUniAssigned,(RangeToken*)RangeToken::complementRanges(tok, - tokFactory)); + tokFactory, tokFactory->getMemoryManager())); fRangesCreated = true; } diff --git a/src/xercesc/util/regx/UnionToken.cpp b/src/xercesc/util/regx/UnionToken.cpp index 858e088855793dfd6a43aa73a24b98608ea42428..a88ef0898fd5053719a2cdae8b54e3cff673dd9a 100644 --- a/src/xercesc/util/regx/UnionToken.cpp +++ b/src/xercesc/util/regx/UnionToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:37 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/05/18 14:02:06 knoaman * Memory manager implementation: pass per instance manager. * @@ -119,8 +122,8 @@ const unsigned short UnionToken::INITIALSIZE = 8; // --------------------------------------------------------------------------- // UnionToken: Constructors and Destructors // --------------------------------------------------------------------------- -UnionToken::UnionToken(const unsigned short tokType) - : Token(tokType) +UnionToken::UnionToken(const unsigned short tokType, MemoryManager* const manager) + : Token(tokType, manager) , fChildren(0) { diff --git a/src/xercesc/util/regx/UnionToken.hpp b/src/xercesc/util/regx/UnionToken.hpp index f55e0b49e462f28a1b7d3d26b16408e6fb075541..359a75e22ee70ad6d282a8d9d2ff2393b3fda5c3 100644 --- a/src/xercesc/util/regx/UnionToken.hpp +++ b/src/xercesc/util/regx/UnionToken.hpp @@ -74,7 +74,8 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - UnionToken(const unsigned short tokType); + UnionToken(const unsigned short tokType + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~UnionToken(); // ----------------------------------------------------------------------- diff --git a/src/xercesc/validators/DTD/DTDAttDef.hpp b/src/xercesc/validators/DTD/DTDAttDef.hpp index df6112f53a73a354fe557fe574c1dd1625dec93e..17c0538f8239e416f65b89dcdb12283a79d48c94 100644 --- a/src/xercesc/validators/DTD/DTDAttDef.hpp +++ b/src/xercesc/validators/DTD/DTDAttDef.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/10 16:24:51 peiyongz * Implementation of Serialization/Deserialization * @@ -197,7 +200,7 @@ inline unsigned int DTDAttDef::getElemId() const inline const XMLCh* DTDAttDef::getDOMTypeInfoName() const { - return getAttTypeString(getType()); + return getAttTypeString(getType(), getMemoryManager()); } inline const XMLCh* DTDAttDef::getDOMTypeInfoUri() const diff --git a/src/xercesc/validators/DTD/DTDAttDefList.cpp b/src/xercesc/validators/DTD/DTDAttDefList.cpp index 7ec2fcbd22a31fd39f89a4d70d654f1e144aaa9a..f000e1925207c1fbc36fb3d07bb3502703219f72 100644 --- a/src/xercesc/validators/DTD/DTDAttDefList.cpp +++ b/src/xercesc/validators/DTD/DTDAttDefList.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/13 23:19:49 peiyongz * initSize * @@ -114,8 +117,8 @@ DTDAttDefList::DTDAttDefList(RefHashTableOf<DTDAttDef>* const listToUse, MemoryM ,fSize(0) ,fCount(0) { - fEnum = new (getMemoryManager()) RefHashTableOfEnumerator<DTDAttDef>(listToUse); - fArray = (DTDAttDef **)((getMemoryManager())->allocate( sizeof(DTDAttDef*) << 1)); + fEnum = new (getMemoryManager()) RefHashTableOfEnumerator<DTDAttDef>(listToUse, false, manager); + fArray = (DTDAttDef **)(manager->allocate( sizeof(DTDAttDef*) << 1)); fSize = 2; } @@ -200,7 +203,7 @@ unsigned int DTDAttDefList::getAttDefCount() const XMLAttDef &DTDAttDefList::getAttDef(unsigned int index) { if(index >= fCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager()); return *(fArray[index]); } @@ -210,7 +213,7 @@ XMLAttDef &DTDAttDefList::getAttDef(unsigned int index) const XMLAttDef &DTDAttDefList::getAttDef(unsigned int index) const { if(index >= fCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager()); return *(fArray[index]); } @@ -249,7 +252,7 @@ void DTDAttDefList::serialize(XSerializeEngine& serEng) serEng >> fSize; if (!fEnum && fList) { - fEnum = new (getMemoryManager()) RefHashTableOfEnumerator<DTDAttDef>(fList); + fEnum = new (getMemoryManager()) RefHashTableOfEnumerator<DTDAttDef>(fList, false, getMemoryManager()); } if(fSize) { diff --git a/src/xercesc/validators/DTD/DTDElementDecl.cpp b/src/xercesc/validators/DTD/DTDElementDecl.cpp index d13e164e462fb7a501e1a07ed01c6b35f76badce..4b0488106ed9963dd411db1dcbb3f0297dafa355 100644 --- a/src/xercesc/validators/DTD/DTDElementDecl.cpp +++ b/src/xercesc/validators/DTD/DTDElementDecl.cpp @@ -239,7 +239,7 @@ bool DTDElementDecl::resetDefs() // This lets the scanner use them to track which has been provided and // which have not. // - RefHashTableOfEnumerator<DTDAttDef> enumDefs(fAttDefs); + RefHashTableOfEnumerator<DTDAttDef> enumDefs(fAttDefs, false, getMemoryManager()); while (enumDefs.hasMoreElements()) enumDefs.nextElement().setProvided(false); return true; @@ -369,7 +369,7 @@ XMLContentModel* DTDElementDecl::makeContentModel() } else { - ThrowXML(RuntimeException, XMLExcepts::CM_MustBeMixedOrChildren); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_MustBeMixedOrChildren, getMemoryManager()); } return cmRet; } @@ -381,7 +381,7 @@ XMLContentModel* DTDElementDecl::createChildModel() ContentSpecNode* specNode = getContentSpec(); if(!specNode) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, getMemoryManager()); // // Do a sanity check that the node does not have a PCDATA id. Since, @@ -389,7 +389,7 @@ XMLContentModel* DTDElementDecl::createChildModel() // if (specNode->getElement()) { if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_NoPCDATAHere, getMemoryManager()); } // @@ -451,7 +451,7 @@ XMLContentModel* DTDElementDecl::createChildModel() } else { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, getMemoryManager()); } // Its not any simple type of content, so create a DFA based content model diff --git a/src/xercesc/validators/DTD/DTDGrammar.hpp b/src/xercesc/validators/DTD/DTDGrammar.hpp index 93dc79a0dbc43b9358529ca352db8dc601daa315..e9723c645952474c6480db1e7ef5c8ea29f3852b 100644 --- a/src/xercesc/validators/DTD/DTDGrammar.hpp +++ b/src/xercesc/validators/DTD/DTDGrammar.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/10/14 15:20:42 peiyongz * Implementation of Serialization/Deserialization * @@ -338,19 +341,19 @@ inline unsigned int DTDGrammar::getRootElemId() inline NameIdPoolEnumerator<DTDElementDecl> DTDGrammar::getElemEnumerator() const { - return NameIdPoolEnumerator<DTDElementDecl>(fElemDeclPool); + return NameIdPoolEnumerator<DTDElementDecl>(fElemDeclPool, fMemoryManager); } inline NameIdPoolEnumerator<DTDEntityDecl> DTDGrammar::getEntityEnumerator() const { - return NameIdPoolEnumerator<DTDEntityDecl>(fEntityDeclPool); + return NameIdPoolEnumerator<DTDEntityDecl>(fEntityDeclPool, fMemoryManager); } inline NameIdPoolEnumerator<XMLNotationDecl> DTDGrammar::getNotationEnumerator() const { - return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool); + return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager); } inline const DTDEntityDecl* diff --git a/src/xercesc/validators/DTD/DTDScanner.cpp b/src/xercesc/validators/DTD/DTDScanner.cpp index 53a1c612e84b734ee4e7a9df540a58202815553e..08bff4044d365b65d72d1d8f179eff2dea643236 100644 --- a/src/xercesc/validators/DTD/DTDScanner.cpp +++ b/src/xercesc/validators/DTD/DTDScanner.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.30 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.29 2003/10/01 16:32:41 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * @@ -482,7 +485,7 @@ bool DTDScanner::expandPERef( const bool scanExternal // If the creation failed then throw an exception if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId(), fMemoryManager); // Set the 'throw at end' flag, to the one we were given reader->setThrowAtEnd(throwEndOfExt); @@ -774,7 +777,7 @@ DTDScanner::scanAttDef(DTDElementDecl& parentElem, XMLBuffer& bufToUse) const XMLCh fgDefault[] = { chLatin_d, chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull }; bool ok = false; if (decl->getType() == XMLAttDef::Enumeration) { - BaseRefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(decl->getEnumeration()); + BaseRefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(decl->getEnumeration(), fMemoryManager); int size = enumVector->size(); ok = (size == 1 && (XMLString::equals(enumVector->elementAt(0), fgDefault) || @@ -863,7 +866,7 @@ void DTDScanner::scanAttListDecl() // Watch for EOF if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chCloseAngle) { @@ -992,7 +995,7 @@ bool DTDScanner::scanAttValue(const XMLCh* const attrName nextCh = fReaderMgr->getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Check for our ending quote in the same entity if (nextCh == quoteCh) @@ -1047,6 +1050,7 @@ bool DTDScanner::scanAttValue(const XMLCh* const attrName , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError ( @@ -1157,7 +1161,7 @@ bool DTDScanner::scanCharRef(XMLCh& first, XMLCh& second) // Watch for EOF if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Break out on the terminating semicolon if (nextCh == chSemiColon) @@ -1605,7 +1609,7 @@ void DTDScanner::scanComment() if (!nextCh) { fScanner->emitError(XMLErrs::UnterminatedComment); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } // Check for correct surrogate pairs @@ -1633,6 +1637,7 @@ void DTDScanner::scanComment() , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -2197,7 +2202,7 @@ DTDScanner::scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped) // If the creation failed then throw an exception // if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId(), fMemoryManager); // // Push the reader. If its a recursive expansion, then emit an error @@ -2286,7 +2291,7 @@ bool DTDScanner::scanEntityLiteral(XMLBuffer& toFill, const bool isPE) if (!nextCh) { fScanner->emitError(XMLErrs::UnterminatedEntityLiteral); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } // @@ -2391,6 +2396,7 @@ bool DTDScanner::scanEntityLiteral(XMLBuffer& toFill, const bool isPE) , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); fReaderMgr->skipPastChar(quoteCh); @@ -2764,6 +2770,7 @@ void DTDScanner::scanExtSubsetDecl(const bool inIncludeSect, const bool isDTD) , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -2977,7 +2984,7 @@ void DTDScanner::scanIgnoredSection() const XMLCh nextCh = fReaderMgr->getNextChar(); if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == chOpenAngle) { @@ -3043,6 +3050,7 @@ void DTDScanner::scanIgnoredSection() , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -3153,6 +3161,7 @@ bool DTDScanner::scanInternalSubset() , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError ( @@ -3730,7 +3739,7 @@ void DTDScanner::scanPI() if (!nextCh) { fScanner->emitError(XMLErrs::UnterminatedPI); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); } // Watch for potential terminating character @@ -3766,6 +3775,7 @@ void DTDScanner::scanPI() , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); } @@ -3832,7 +3842,7 @@ bool DTDScanner::scanPublicLiteral(XMLBuffer& toFill) // Watch for EOF if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); if (nextCh == quoteCh) break; @@ -3850,6 +3860,7 @@ bool DTDScanner::scanPublicLiteral(XMLBuffer& toFill) , tmpBuf , 8 , 16 + , fMemoryManager ); fScanner->emitError(XMLErrs::InvalidPublicIdChar, tmpBuf); } @@ -3882,7 +3893,7 @@ bool DTDScanner::scanSystemLiteral(XMLBuffer& toFill) // Watch for EOF if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); + ThrowXMLwithMemMgr(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF, fMemoryManager); // Break out on terminating quote if (nextCh == quoteCh) diff --git a/src/xercesc/validators/DTD/DTDValidator.cpp b/src/xercesc/validators/DTD/DTDValidator.cpp index 6d9b4a4f57b47d9a1b22aca44b4e3f214923371f..e5e384953f4ba1740f2df2cb02b4ac630fa887be 100644 --- a/src/xercesc/validators/DTD/DTDValidator.cpp +++ b/src/xercesc/validators/DTD/DTDValidator.cpp @@ -99,7 +99,7 @@ int DTDValidator::checkContent(XMLElementDecl* const elemDecl // the element decl in our own way of looking at them. // if (!elemDecl) - ThrowXML(RuntimeException, XMLExcepts::Val_InvalidElemId); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_InvalidElemId, getScanner()->getMemoryManager()); // // Get the content spec type of this element. This will tell us what @@ -131,7 +131,7 @@ int DTDValidator::checkContent(XMLElementDecl* const elemDecl } else { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMType, getScanner()->getMemoryManager()); } // Went ok, so return success @@ -512,7 +512,7 @@ void DTDValidator::preContentValidation(bool reuseGrammar, if(reuseGrammar && reason == XMLElementDecl::JustFaultIn){ } else - ThrowXML(RuntimeException, XMLExcepts::DTD_UnknownCreateReason); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::DTD_UnknownCreateReason, getScanner()->getMemoryManager()); #endif } } diff --git a/src/xercesc/validators/common/AllContentModel.cpp b/src/xercesc/validators/common/AllContentModel.cpp index ed07b871c9aa7ab26d16348f8cb2874eb2371004..980e8a446b2df8becc038aeb2aef7ddc87a92205 100644 --- a/src/xercesc/validators/common/AllContentModel.cpp +++ b/src/xercesc/validators/common/AllContentModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/20 18:09:18 knoaman * Store a copy of each child, instead of a reference, as the content spec node * tree is not guaranteed to be persistent. @@ -130,7 +133,7 @@ AllContentModel::AllContentModel( ContentSpecNode* const parentContentSpec // ContentSpecNode* curNode = parentContentSpec; if (!curNode) - ThrowXML(RuntimeException, XMLExcepts::CM_NoParentCSN); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_NoParentCSN, fMemoryManager); // And now call the private recursive method that iterates the tree buildChildList(curNode, children, childOptional); @@ -390,13 +393,13 @@ AllContentModel::buildChildList(ContentSpecNode* const curNode // that was specified with minOccurs=0, maxOccurs=1 ContentSpecNode* leftNode = curNode->getFirst(); if (leftNode->getType() != ContentSpecNode::Leaf) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); toFill.addElement(leftNode->getElement()); toOptional.addElement(true); } else - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/common/CMAny.cpp b/src/xercesc/validators/common/CMAny.cpp index 4dcea5d99f75052bccb13b8b10e78b26b91d9058..83b116f98d3d5c142fc8d27a24cc32503845e8e4 100644 --- a/src/xercesc/validators/common/CMAny.cpp +++ b/src/xercesc/validators/common/CMAny.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/05/15 18:48:27 knoaman * Partial implementation of the configurable memory manager. * @@ -110,9 +113,9 @@ CMAny::CMAny( const ContentSpecNode::NodeTypes type && (type & 0x0f) != ContentSpecNode::Any_Other && (type & 0x0f) != ContentSpecNode::Any_NS) { - ThrowXML1(RuntimeException, + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::CM_NotValidSpecTypeForNode, - "CMAny"); + "CMAny", manager); } } diff --git a/src/xercesc/validators/common/CMBinaryOp.cpp b/src/xercesc/validators/common/CMBinaryOp.cpp index 6cbd8ba4d5722a36dfff6254085072201ffed416..d0c97115834d6af78721418fc620a48077e14329 100644 --- a/src/xercesc/validators/common/CMBinaryOp.cpp +++ b/src/xercesc/validators/common/CMBinaryOp.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/11/20 18:12:20 knoaman * Use a bitwise operation to check the node type. * @@ -125,7 +128,7 @@ CMBinaryOp::CMBinaryOp( const ContentSpecNode::NodeTypes type if (((type & 0x0f) != ContentSpecNode::Choice) && ((type & 0x0f) != ContentSpecNode::Sequence)) { - ThrowXML(RuntimeException, XMLExcepts::CM_BinOpHadUnaryType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_BinOpHadUnaryType, manager); } } diff --git a/src/xercesc/validators/common/CMStateSet.hpp b/src/xercesc/validators/common/CMStateSet.hpp index 14f1131e70186a95a6d7d78ef3b78ee0167e7ad8..f3f4dff73b86f3670bdac4204ad52466655a87cb 100644 --- a/src/xercesc/validators/common/CMStateSet.hpp +++ b/src/xercesc/validators/common/CMStateSet.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/05/16 21:43:20 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * @@ -257,7 +260,7 @@ public : // They have to be the same size if (fBitCount != srcSet.fBitCount) - ThrowXML(RuntimeException, XMLExcepts::Bitset_NotEqualSize); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Bitset_NotEqualSize, fMemoryManager); if (fBitCount < 65) { @@ -276,7 +279,7 @@ public : bool getBit(const unsigned int bitToGet) const { if (bitToGet >= fBitCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex, fMemoryManager); if (fBitCount < 65) { @@ -311,7 +314,7 @@ public : void setBit(const unsigned int bitToSet) { if (bitToSet >= fBitCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex, fMemoryManager); if (fBitCount < 65) { diff --git a/src/xercesc/validators/common/CMUnaryOp.cpp b/src/xercesc/validators/common/CMUnaryOp.cpp index 6e15649df40743f4c38eadef3fc5c0a65292821c..27b3f42e322a07eaae1cda87adb9be20d3609cb1 100644 --- a/src/xercesc/validators/common/CMUnaryOp.cpp +++ b/src/xercesc/validators/common/CMUnaryOp.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/05/15 18:48:27 knoaman * Partial implementation of the configurable memory manager. * @@ -119,7 +122,7 @@ CMUnaryOp::CMUnaryOp( const ContentSpecNode::NodeTypes type && (type != ContentSpecNode::ZeroOrMore) && (type != ContentSpecNode::OneOrMore)) { - ThrowXML(RuntimeException, XMLExcepts::CM_UnaryOpHadBinType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnaryOpHadBinType, manager); } } diff --git a/src/xercesc/validators/common/ContentLeafNameTypeVector.cpp b/src/xercesc/validators/common/ContentLeafNameTypeVector.cpp index ca46f5002708d4a14ad25501bf733cb4eccf7fbc..76fc2f3e1920a7e14d6e2f47bab620a899f6b360 100644 --- a/src/xercesc/validators/common/ContentLeafNameTypeVector.cpp +++ b/src/xercesc/validators/common/ContentLeafNameTypeVector.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.3 2003/05/15 18:48:27 knoaman * Partial implementation of the configurable memory manager. * @@ -166,7 +169,7 @@ void ContentLeafNameTypeVector::setValues QName* ContentLeafNameTypeVector::getLeafNameAt(const unsigned int pos) const { if (pos >= fLeafCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); return fLeafNames[pos]; } @@ -175,7 +178,7 @@ const ContentSpecNode::NodeTypes ContentLeafNameTypeVector::getLeafTypeAt (const unsigned int pos) const { if (pos >= fLeafCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex, fMemoryManager); return fLeafTypes[pos]; } diff --git a/src/xercesc/validators/common/DFAContentModel.cpp b/src/xercesc/validators/common/DFAContentModel.cpp index 8b8084d4c103a081bb62b2f4d86b2e44d2aa1856..a5a25a027fdcf0c720717bfffddde14b35fb15ef 100644 --- a/src/xercesc/validators/common/DFAContentModel.cpp +++ b/src/xercesc/validators/common/DFAContentModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/20 18:12:20 knoaman * Use a bitwise operation to check the node type. * @@ -1128,7 +1131,7 @@ CMNode* DFAContentModel::buildSyntaxTree(ContentSpecNode* const curNode) } else { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); } } return retNode; @@ -1290,7 +1293,7 @@ int DFAContentModel::postTreeBuildInit( CMNode* const nodeCur } else { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); } return newIndex; } diff --git a/src/xercesc/validators/common/DFAContentModel.hpp b/src/xercesc/validators/common/DFAContentModel.hpp index 9d60915a334cfddf45f101e1700b6321c2e10dbe..1bedb01451813e25d6d42456f1dfd749a86a861e 100644 --- a/src/xercesc/validators/common/DFAContentModel.hpp +++ b/src/xercesc/validators/common/DFAContentModel.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/05/16 21:43:20 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * @@ -342,7 +345,7 @@ DFAContentModel::getNextState(const unsigned int currentState, } if (currentState >= fTransTableSize || elementIndex >= fElemMapSize) { - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager); } return fTransTable[currentState][elementIndex]; diff --git a/src/xercesc/validators/common/GrammarResolver.cpp b/src/xercesc/validators/common/GrammarResolver.cpp index 23997bc1fdd7b558331c1b2679b7f7f2c1240864..d3ebd75339da69caed367d005b00097933ae8bff 100644 --- a/src/xercesc/validators/common/GrammarResolver.cpp +++ b/src/xercesc/validators/common/GrammarResolver.cpp @@ -57,6 +57,9 @@ /* * $Log$ + * Revision 1.22 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.21 2003/11/21 22:38:50 neilg * Enable grammar pools and grammar resolvers to manufacture * XSModels. This also cleans up handling in the @@ -316,13 +319,13 @@ Grammar* GrammarResolver::getGrammar( XMLGrammarDescription* const gramDesc) RefHashTableOfEnumerator<Grammar> GrammarResolver::getGrammarEnumerator() const { - return RefHashTableOfEnumerator<Grammar>(fGrammarBucket); + return RefHashTableOfEnumerator<Grammar>(fGrammarBucket, false, fMemoryManager); } RefHashTableOfEnumerator<Grammar> GrammarResolver::getReferencedGrammarEnumerator() const { - return RefHashTableOfEnumerator<Grammar>(fGrammarFromPool); + return RefHashTableOfEnumerator<Grammar>(fGrammarFromPool, false, fMemoryManager); } RefHashTableOfEnumerator<Grammar> @@ -393,7 +396,7 @@ void GrammarResolver::resetCachedGrammar() void GrammarResolver::cacheGrammars() { - RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarBucket); + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarBucket, false, fMemoryManager); ValueVectorOf<XMLCh*> keys(8, fMemoryManager); unsigned int keyCount = 0; @@ -489,7 +492,7 @@ XSModel *GrammarResolver::getXSModel() // with our our grammars or we would like to upate it now // so we have to regenerate the XSModel fGrammarsToAddToXSModel->removeAllElements(); - RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarBucket); + RefHashTableOfEnumerator<Grammar> grammarEnum(fGrammarBucket, false, fMemoryManager); while (grammarEnum.hasMoreElements()) { Grammar& grammar = (Grammar&) grammarEnum.nextElement(); diff --git a/src/xercesc/validators/common/MixedContentModel.cpp b/src/xercesc/validators/common/MixedContentModel.cpp index 701c1165f6e93569a9c05ece24133939248c2cb0..4d6ba75ad6fccaab035c5d141eb42947caede52b 100644 --- a/src/xercesc/validators/common/MixedContentModel.cpp +++ b/src/xercesc/validators/common/MixedContentModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/11/20 18:12:20 knoaman * Use a bitwise operation to check the node type. * @@ -188,7 +191,7 @@ MixedContentModel::MixedContentModel(const bool dtd // ContentSpecNode* curNode = parentContentSpec; if (!curNode) - ThrowXML(RuntimeException, XMLExcepts::CM_NoParentCSN); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_NoParentCSN, fMemoryManager); // And now call the private recursive method that iterates the tree buildChildList(curNode, children, childTypes); diff --git a/src/xercesc/validators/common/SimpleContentModel.cpp b/src/xercesc/validators/common/SimpleContentModel.cpp index 359c324dc0938730c610daf07ee1d276409cd67c..976d47e5d61a0d3fdd5f923ae73c3243bb4598d0 100644 --- a/src/xercesc/validators/common/SimpleContentModel.cpp +++ b/src/xercesc/validators/common/SimpleContentModel.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/20 18:12:20 knoaman * Use a bitwise operation to check the node type. * @@ -331,7 +334,7 @@ SimpleContentModel::validateContent(QName** const children break; default : - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); break; } return -1; @@ -491,7 +494,7 @@ int SimpleContentModel::validateContentSpecial(QName** const children break; default : - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); break; } return -1; diff --git a/src/xercesc/validators/common/SimpleContentModel.hpp b/src/xercesc/validators/common/SimpleContentModel.hpp index 9aa6ae6890f1ee7ad978f45fad903af563eb79bc..0811c5b839ad2bd1500fe2823e907ce4dbcb7be2 100644 --- a/src/xercesc/validators/common/SimpleContentModel.hpp +++ b/src/xercesc/validators/common/SimpleContentModel.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/06/03 18:12:29 knoaman * Add default value for memory manager argument. * @@ -244,6 +247,7 @@ public : QName* fSecondChild; ContentSpecNode::NodeTypes fOp; bool fDTD; + MemoryManager* const fMemoryManager; }; @@ -262,6 +266,7 @@ inline SimpleContentModel::SimpleContentModel , fSecondChild(0) , fOp(cmOp) , fDTD(dtd) + , fMemoryManager(manager) { if (firstChild) fFirstChild = new (manager) QName(*firstChild); diff --git a/src/xercesc/validators/datatype/AbstractNumericFacetValidator.cpp b/src/xercesc/validators/datatype/AbstractNumericFacetValidator.cpp index 62a09eeae53306d9ff73de82bfb31b935b9dd80d..d1653934aa32d6f7c2d316e02ec76bb242d91081 100644 --- a/src/xercesc/validators/datatype/AbstractNumericFacetValidator.cpp +++ b/src/xercesc/validators/datatype/AbstractNumericFacetValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.17 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.16 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -146,24 +149,26 @@ XERCES_CPP_NAMESPACE_BEGIN const int AbstractNumericFacetValidator::INDETERMINATE = 2; -#define REPORT_FACET_ERROR(val1, val2, except_code) \ - ThrowXML2(InvalidDatatypeFacetException \ +#define REPORT_FACET_ERROR(val1, val2, except_code, manager) \ + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException \ , except_code \ , val1->getFormattedString() \ - , val2->getFormattedString()); + , val2->getFormattedString() \ + , manager); -#define FROM_BASE_VALUE_SPACE(val, facetFlag, except_code) \ +#define FROM_BASE_VALUE_SPACE(val, facetFlag, except_code, manager) \ if ((thisFacetsDefined & facetFlag) != 0) \ { \ try \ { \ - numBase->checkContent(val->getRawData(), (ValidationContext*)0, false); \ + numBase->checkContent(val->getRawData(), (ValidationContext*)0, false, manager); \ } \ catch ( XMLException& ) \ { \ - ThrowXML1(InvalidDatatypeFacetException \ + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException \ , except_code \ - , val->getRawData()); \ + , val->getRawData() \ + , manager); \ } \ } @@ -218,7 +223,8 @@ AbstractNumericFacetValidator::AbstractNumericFacetValidator( // // P1. Enumeration // -void AbstractNumericFacetValidator::init(RefArrayVectorOf<XMLCh>* const enums) +void AbstractNumericFacetValidator::init(RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager) { fStrEnumeration = enums; // save the literal value @@ -229,9 +235,9 @@ void AbstractNumericFacetValidator::init(RefArrayVectorOf<XMLCh>* const enums) setFacetsDefined(DatatypeValidator::FACET_ENUMERATION); } - assignFacet(); - inspectFacet(); - inspectFacetBase(); + assignFacet(manager); + inspectFacet(manager); + inspectFacetBase(manager); inheritFacet(); } @@ -240,7 +246,7 @@ void AbstractNumericFacetValidator::init(RefArrayVectorOf<XMLCh>* const enums) // assign common facets // assign additional facet // -void AbstractNumericFacetValidator::assignFacet() +void AbstractNumericFacetValidator::assignFacet(MemoryManager* const manager) { RefHashTableOf<KVStringPair>* facets = getFacets(); @@ -251,7 +257,7 @@ void AbstractNumericFacetValidator::assignFacet() XMLCh* key; XMLCh* value; - RefHashTableOfEnumerator<KVStringPair> e(facets); + RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager); while (e.hasMoreElements()) { @@ -274,7 +280,7 @@ void AbstractNumericFacetValidator::assignFacet() } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value, manager); } setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE); } @@ -286,7 +292,7 @@ void AbstractNumericFacetValidator::assignFacet() } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value, manager); } setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE); } @@ -298,7 +304,7 @@ void AbstractNumericFacetValidator::assignFacet() } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value, manager); } setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE); } @@ -310,7 +316,7 @@ void AbstractNumericFacetValidator::assignFacet() } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value, manager); } setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE); } @@ -320,16 +326,16 @@ void AbstractNumericFacetValidator::assignFacet() bool retStatus; try { - retStatus = XMLString::textToBin(value, val); + retStatus = XMLString::textToBin(value, val, fMemoryManager); } catch (RuntimeException&) { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager); } if (!retStatus) { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager); } setFixed(val); @@ -338,7 +344,7 @@ void AbstractNumericFacetValidator::assignFacet() } else { - assignAdditionalFacet(key, value); + assignAdditionalFacet(key, value, manager); } }//while @@ -350,7 +356,7 @@ void AbstractNumericFacetValidator::assignFacet() // check common facets // check Additional Facet Constraint // -void AbstractNumericFacetValidator::inspectFacet() +void AbstractNumericFacetValidator::inspectFacet(MemoryManager* const manager) { int thisFacetsDefined = getFacetsDefined(); @@ -366,13 +372,13 @@ void AbstractNumericFacetValidator::inspectFacet() // check 4.3.8.c1 error: maxInclusive + maxExclusive if (((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) && ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) ) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_max_Incl_Excl); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_max_Incl_Excl, manager); // non co-existence checking // check 4.3.9.c1 error: minInclusive + minExclusive if (((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) && ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) ) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_min_Incl_Excl); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_min_Incl_Excl, manager); // // minExclusive < minInclusive <= maxInclusive < maxExclusive @@ -386,7 +392,8 @@ void AbstractNumericFacetValidator::inspectFacet() { REPORT_FACET_ERROR(thisMinInclusive , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_minIncl) + , XMLExcepts::FACET_maxIncl_minIncl + , manager) } } @@ -399,7 +406,8 @@ void AbstractNumericFacetValidator::inspectFacet() { REPORT_FACET_ERROR(thisMinExclusive , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_minExcl) + , XMLExcepts::FACET_maxExcl_minExcl + , manager) } } @@ -412,7 +420,8 @@ void AbstractNumericFacetValidator::inspectFacet() { REPORT_FACET_ERROR(thisMinExclusive , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_minExcl) + , XMLExcepts::FACET_maxIncl_minExcl + , manager) } } @@ -425,11 +434,12 @@ void AbstractNumericFacetValidator::inspectFacet() { REPORT_FACET_ERROR(thisMinInclusive , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_minIncl) + , XMLExcepts::FACET_maxExcl_minIncl + , manager) } } - checkAdditionalFacetConstraints(); + checkAdditionalFacetConstraints(manager); }// end of inspectFacet() @@ -439,7 +449,7 @@ void AbstractNumericFacetValidator::inspectFacet() // check enumeration // check Additional Facet Constraint // -void AbstractNumericFacetValidator::inspectFacetBase() +void AbstractNumericFacetValidator::inspectFacetBase(MemoryManager* const manager) { AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator(); @@ -488,14 +498,16 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxInclusive , baseMaxInclusive - , XMLExcepts::FACET_maxIncl_base_fixed) + , XMLExcepts::FACET_maxIncl_base_fixed + , manager) } if (result == 1 || result == INDETERMINATE) { REPORT_FACET_ERROR(thisMaxInclusive , baseMaxInclusive - , XMLExcepts::FACET_maxIncl_base_maxIncl) + , XMLExcepts::FACET_maxIncl_base_maxIncl + , manager) } } @@ -507,7 +519,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxInclusive , baseMaxExclusive - , XMLExcepts::FACET_maxIncl_base_maxExcl) + , XMLExcepts::FACET_maxIncl_base_maxExcl + , manager) } } @@ -519,7 +532,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxInclusive , baseMinInclusive - , XMLExcepts::FACET_maxIncl_base_minIncl) + , XMLExcepts::FACET_maxIncl_base_minIncl + , manager) } } @@ -530,7 +544,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxInclusive , baseMinExclusive - , XMLExcepts::FACET_maxIncl_base_minExcl) + , XMLExcepts::FACET_maxIncl_base_minExcl + , manager) } } @@ -553,14 +568,16 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxExclusive , baseMaxExclusive - , XMLExcepts::FACET_maxExcl_base_fixed) + , XMLExcepts::FACET_maxExcl_base_fixed + , manager) } if (result == 1 || result == INDETERMINATE) { REPORT_FACET_ERROR(thisMaxExclusive , baseMaxExclusive - , XMLExcepts::FACET_maxExcl_base_maxExcl) + , XMLExcepts::FACET_maxExcl_base_maxExcl + , manager) } /** @@ -576,14 +593,16 @@ void AbstractNumericFacetValidator::inspectFacetBase() { FROM_BASE_VALUE_SPACE(thisMaxExclusive , DatatypeValidator::FACET_MAXEXCLUSIVE - , XMLExcepts::FACET_maxExcl_notFromBase) + , XMLExcepts::FACET_maxExcl_notFromBase + , manager) } } else // base has no maxExclusive { FROM_BASE_VALUE_SPACE(thisMaxExclusive , DatatypeValidator::FACET_MAXEXCLUSIVE - , XMLExcepts::FACET_maxExcl_notFromBase) + , XMLExcepts::FACET_maxExcl_notFromBase + , manager) } if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) @@ -593,7 +612,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxExclusive , baseMaxInclusive - , XMLExcepts::FACET_maxExcl_base_maxIncl) + , XMLExcepts::FACET_maxExcl_base_maxIncl + , manager) } } @@ -604,7 +624,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxExclusive , baseMinExclusive - , XMLExcepts::FACET_maxExcl_base_minExcl) + , XMLExcepts::FACET_maxExcl_base_minExcl + , manager) } } @@ -615,7 +636,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxExclusive , baseMinInclusive - , XMLExcepts::FACET_maxExcl_base_minIncl) + , XMLExcepts::FACET_maxExcl_base_minIncl + , manager) } } } @@ -637,14 +659,16 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinExclusive , baseMinExclusive - , XMLExcepts::FACET_minExcl_base_fixed) + , XMLExcepts::FACET_minExcl_base_fixed + , manager) } if (result == -1 || result == INDETERMINATE) { REPORT_FACET_ERROR(thisMinExclusive , baseMinExclusive - , XMLExcepts::FACET_minExcl_base_minExcl) + , XMLExcepts::FACET_minExcl_base_minExcl + , manager) } /** @@ -661,7 +685,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { FROM_BASE_VALUE_SPACE(thisMinExclusive , DatatypeValidator::FACET_MINEXCLUSIVE - , XMLExcepts::FACET_minExcl_notFromBase) + , XMLExcepts::FACET_minExcl_notFromBase + , manager) } } else // base has no minExclusive @@ -669,7 +694,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() FROM_BASE_VALUE_SPACE(thisMinExclusive , DatatypeValidator::FACET_MINEXCLUSIVE - , XMLExcepts::FACET_minExcl_notFromBase) + , XMLExcepts::FACET_minExcl_notFromBase + , manager) } if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) @@ -679,8 +705,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinExclusive , baseMaxInclusive - - , XMLExcepts::FACET_minExcl_base_maxIncl) + , XMLExcepts::FACET_minExcl_base_maxIncl + , manager) } } @@ -691,7 +717,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinExclusive , baseMinInclusive - , XMLExcepts::FACET_minExcl_base_minIncl) + , XMLExcepts::FACET_minExcl_base_minIncl + , manager) } } @@ -702,7 +729,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinExclusive , baseMaxExclusive - , XMLExcepts::FACET_minExcl_base_maxExcl) + , XMLExcepts::FACET_minExcl_base_maxExcl + , manager) } } @@ -726,14 +754,16 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinInclusive , baseMinInclusive - , XMLExcepts::FACET_minIncl_base_fixed) + , XMLExcepts::FACET_minIncl_base_fixed + , manager) } if (result == -1 || result == INDETERMINATE) { REPORT_FACET_ERROR(thisMinInclusive , baseMinInclusive - , XMLExcepts::FACET_minIncl_base_minIncl) + , XMLExcepts::FACET_minIncl_base_minIncl + , manager) } } @@ -744,7 +774,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinInclusive , baseMaxInclusive - , XMLExcepts::FACET_minIncl_base_maxIncl) + , XMLExcepts::FACET_minIncl_base_maxIncl + , manager) } } @@ -755,7 +786,8 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinInclusive , baseMinExclusive - , XMLExcepts::FACET_minIncl_base_minExcl) + , XMLExcepts::FACET_minIncl_base_minExcl + , manager) } } @@ -766,13 +798,14 @@ void AbstractNumericFacetValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinInclusive , baseMaxExclusive - , XMLExcepts::FACET_minIncl_base_maxExcl) + , XMLExcepts::FACET_minIncl_base_maxExcl + , manager) } } } - checkAdditionalFacetConstraintsBase(); + checkAdditionalFacetConstraintsBase(manager); // check 4.3.5.c0 must: enumeration values from the value space of base // @@ -783,7 +816,7 @@ void AbstractNumericFacetValidator::inspectFacetBase() if ( ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) && ( fStrEnumeration )) { - setEnumeration(); + setEnumeration(manager); } // @@ -793,11 +826,13 @@ void AbstractNumericFacetValidator::inspectFacetBase() FROM_BASE_VALUE_SPACE(thisMaxInclusive , DatatypeValidator::FACET_MAXINCLUSIVE - , XMLExcepts::FACET_maxIncl_notFromBase) + , XMLExcepts::FACET_maxIncl_notFromBase + , manager) FROM_BASE_VALUE_SPACE(thisMinInclusive , DatatypeValidator::FACET_MININCLUSIVE - , XMLExcepts::FACET_minIncl_notFromBase) + , XMLExcepts::FACET_minIncl_notFromBase + , manager) } //end of inspectFacetBase @@ -877,6 +912,34 @@ const RefArrayVectorOf<XMLCh>* AbstractNumericFacetValidator::getEnumString() co return (fEnumerationInherited? getBaseValidator()->getEnumString() : fStrEnumeration ); } + +void AbstractNumericFacetValidator::checkAdditionalFacetConstraints(MemoryManager* const manager) const +{ + return; +} + +void AbstractNumericFacetValidator::checkAdditionalFacetConstraintsBase(MemoryManager* const manager) const +{ + return; +} + +void AbstractNumericFacetValidator::inheritAdditionalFacet() +{ + return; +} + +void AbstractNumericFacetValidator::assignAdditionalFacet( const XMLCh* const key + , const XMLCh* const + , MemoryManager* const manager) +{ + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException + , XMLExcepts::FACET_Invalid_Tag + , key + , manager); +} + + + /*** * Support for Serialization/De-serialization ***/ diff --git a/src/xercesc/validators/datatype/AbstractNumericFacetValidator.hpp b/src/xercesc/validators/datatype/AbstractNumericFacetValidator.hpp index 21f20f4cf94a9d71458316a00d780de8a6465a30..21d244f25a4abc6512f7e8b3c3cde0900d5ea315 100644 --- a/src/xercesc/validators/datatype/AbstractNumericFacetValidator.hpp +++ b/src/xercesc/validators/datatype/AbstractNumericFacetValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -137,26 +140,29 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - void init(RefArrayVectorOf<XMLCh>* const enums); + void init(RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager); // // Abstract interface // virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) = 0; + , const XMLCh* const value + , MemoryManager* const manager); - virtual void inheritAdditionalFacet() = 0; + virtual void inheritAdditionalFacet(); - virtual void checkAdditionalFacetConstraints() const = 0; + virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const; - virtual void checkAdditionalFacetConstraintsBase() const = 0; + virtual void checkAdditionalFacetConstraintsBase(MemoryManager* const manager) const; virtual int compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue) = 0; virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) = 0; + , bool asBase + , MemoryManager* const manager) = 0; // ----------------------------------------------------------------------- // Setter methods @@ -170,7 +176,7 @@ protected: virtual void setMinExclusive(const XMLCh* const) = 0; - virtual void setEnumeration() = 0; + virtual void setEnumeration(MemoryManager* const manager) = 0; static const int INDETERMINATE; @@ -212,11 +218,11 @@ protected: private: - void assignFacet(); + void assignFacet(MemoryManager* const manager); - void inspectFacet(); + void inspectFacet(MemoryManager* const manager); - void inspectFacetBase(); + void inspectFacetBase(MemoryManager* const manager); void inheritFacet(); diff --git a/src/xercesc/validators/datatype/AbstractNumericValidator.cpp b/src/xercesc/validators/datatype/AbstractNumericValidator.cpp index 756b1eaaa01ed08545415bb3739f27ddd8d14640..3352875afa4169d6a21212eacc21a42892aa84d1 100644 --- a/src/xercesc/validators/datatype/AbstractNumericValidator.cpp +++ b/src/xercesc/validators/datatype/AbstractNumericValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * @@ -101,11 +104,12 @@ XERCES_CPP_NAMESPACE_BEGIN -#define REPORT_VALUE_ERROR(val1, val2, except_code) \ - ThrowXML2(InvalidDatatypeValueException \ +#define REPORT_VALUE_ERROR(val1, val2, except_code, manager) \ + ThrowXMLwithMemMgr2(InvalidDatatypeValueException \ , except_code \ , val1->getFormattedString() \ - , val2->getFormattedString()); + , val2->getFormattedString() \ + , manager); // --------------------------------------------------------------------------- // Constructors and Destructor @@ -125,12 +129,14 @@ AbstractNumericValidator::AbstractNumericValidator( } void AbstractNumericValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { - checkContent(content, context, false); + checkContent(content, context, false, manager); } -void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData) +void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData + , MemoryManager* const manager) { int thisFacetsDefined = getFacetsDefined(); int result; @@ -146,7 +152,8 @@ void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData) { REPORT_VALUE_ERROR(theData , getMaxExclusive() - , XMLExcepts::VALUE_exceed_maxExcl) + , XMLExcepts::VALUE_exceed_maxExcl + , manager) } } @@ -158,7 +165,8 @@ void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData) { REPORT_VALUE_ERROR(theData , getMaxInclusive() - , XMLExcepts::VALUE_exceed_maxIncl) + , XMLExcepts::VALUE_exceed_maxIncl + , manager) } } @@ -170,7 +178,8 @@ void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData) { REPORT_VALUE_ERROR(theData , getMinInclusive() - , XMLExcepts::VALUE_exceed_minIncl) + , XMLExcepts::VALUE_exceed_minIncl + , manager) } } @@ -182,13 +191,14 @@ void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData) { REPORT_VALUE_ERROR(theData , getMinExclusive() - , XMLExcepts::VALUE_exceed_minExcl) + , XMLExcepts::VALUE_exceed_minExcl + , manager) } } } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager); } } @@ -198,12 +208,10 @@ const XMLCh* AbstractNumericValidator::getCanonicalRepresentation(const XMLCh* { //Validate the content AbstractNumericValidator* temp = (AbstractNumericValidator*) this; - temp->checkContent(rawData, 0, false); - MemoryManager* toUse = memMgr? memMgr : fMemoryManager; - + temp->checkContent(rawData, 0, false, toUse); + return XMLAbstractDoubleFloat::getCanonicalRepresentation(rawData, toUse); - } /*** diff --git a/src/xercesc/validators/datatype/AbstractNumericValidator.hpp b/src/xercesc/validators/datatype/AbstractNumericValidator.hpp index cf05c82393288acdf2cf162d22c52a0c88cb1929..1c96fe665a3bd045d7fc9231c6c18b8979331b1b 100644 --- a/src/xercesc/validators/datatype/AbstractNumericValidator.hpp +++ b/src/xercesc/validators/datatype/AbstractNumericValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -112,6 +115,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual const XMLCh* getCanonicalRepresentation @@ -136,16 +140,19 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - inline void init(RefArrayVectorOf<XMLCh>* const enums); + inline void init(RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager); // // Abstract interface // virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) = 0; + , bool asBase + , MemoryManager* const manager) = 0; - void boundsCheck(const XMLNumber* const); + void boundsCheck(const XMLNumber* const + , MemoryManager* const manager); private: @@ -156,9 +163,10 @@ private: }; -inline void AbstractNumericValidator::init(RefArrayVectorOf<XMLCh>* const enums) +inline void AbstractNumericValidator::init(RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager) { - AbstractNumericFacetValidator::init(enums); + AbstractNumericFacetValidator::init(enums, manager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/datatype/AbstractStringValidator.cpp b/src/xercesc/validators/datatype/AbstractStringValidator.cpp index f24c69d48142d3e9944f6164c55fc4ed425d2e90..22b3b5be2a3bc44661f510cd92c081450190d022 100644 --- a/src/xercesc/validators/datatype/AbstractStringValidator.cpp +++ b/src/xercesc/validators/datatype/AbstractStringValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.16 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -152,22 +155,24 @@ static const int BUF_LEN = 64; static XMLCh value1[BUF_LEN+1]; static XMLCh value2[BUF_LEN+1]; -#define REPORT_FACET_ERROR(val1, val2, except_code) \ - XMLString::binToText(val1, value1, BUF_LEN, 10); \ - XMLString::binToText(val2, value2, BUF_LEN, 10); \ - ThrowXML2(InvalidDatatypeFacetException \ +#define REPORT_FACET_ERROR(val1, val2, except_code, manager) \ + XMLString::binToText(val1, value1, BUF_LEN, 10, manager); \ + XMLString::binToText(val2, value2, BUF_LEN, 10, manager); \ + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException \ , except_code \ , value1 \ - , value2); + , value2 \ + , manager); -#define REPORT_VALUE_ERROR(data, val1, val2, except_code) \ - XMLString::binToText(val1, value1, BUF_LEN, 10); \ - XMLString::binToText(val2, value2, BUF_LEN, 10); \ - ThrowXML3(InvalidDatatypeValueException \ +#define REPORT_VALUE_ERROR(data, val1, val2, except_code, manager) \ + XMLString::binToText(val1, value1, BUF_LEN, 10, manager); \ + XMLString::binToText(val2, value2, BUF_LEN, 10, manager); \ + ThrowXMLwithMemMgr3(InvalidDatatypeValueException \ , except_code \ , data \ , value1 \ - , value2); + , value2 \ + , manager); // --------------------------------------------------------------------------- // Constructors and Destructor @@ -200,18 +205,19 @@ AbstractStringValidator::AbstractStringValidator( // assigneAdditionalFacet(), inheritAdditionalFacet(). } -void AbstractStringValidator::init(RefArrayVectorOf<XMLCh>* const enums) +void AbstractStringValidator::init(RefArrayVectorOf<XMLCh>* const enums + ,MemoryManager* const manager) { if (enums) { setEnumeration(enums, false); - normalizeEnumeration(); + normalizeEnumeration(manager); } - assignFacet(); - inspectFacet(); - inspectFacetBase(); + assignFacet(manager); + inspectFacet(manager); + inspectFacetBase(manager); inheritFacet(); } @@ -221,7 +227,7 @@ void AbstractStringValidator::init(RefArrayVectorOf<XMLCh>* const enum // assign common facets // assign additional facet // -void AbstractStringValidator::assignFacet() +void AbstractStringValidator::assignFacet(MemoryManager* const manager) { RefHashTableOf<KVStringPair>* facets = getFacets(); @@ -231,7 +237,7 @@ void AbstractStringValidator::assignFacet() XMLCh* key; XMLCh* value; - RefHashTableOfEnumerator<KVStringPair> e(facets); + RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager); while (e.hasMoreElements()) { @@ -244,33 +250,33 @@ void AbstractStringValidator::assignFacet() int val; try { - val = XMLString::parseInt(value); + val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value, manager); } if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_Len, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_Len, value, manager); - setLength(val); - setFacetsDefined(DatatypeValidator::FACET_LENGTH); + setLength(val); + setFacetsDefined(DatatypeValidator::FACET_LENGTH); } else if (XMLString::equals(key, SchemaSymbols::fgELT_MINLENGTH)) { int val; try { - val = XMLString::parseInt(value); + val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_minLen, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_minLen, value, manager); } if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_minLen, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_minLen, value, manager); setMinLength(val); setFacetsDefined(DatatypeValidator::FACET_MINLENGTH); @@ -280,15 +286,15 @@ void AbstractStringValidator::assignFacet() int val; try { - val = XMLString::parseInt(value); + val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_maxLen, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_maxLen, value, manager); } if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_maxLen, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_maxLen, value, manager); setMaxLength(val); setFacetsDefined(DatatypeValidator::FACET_MAXLENGTH); @@ -306,16 +312,16 @@ void AbstractStringValidator::assignFacet() bool retStatus; try { - retStatus = XMLString::textToBin(value, val); + retStatus = XMLString::textToBin(value, val, fMemoryManager); } catch (RuntimeException&) { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager); } if (!retStatus) { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager); } setFixed(val); @@ -329,7 +335,7 @@ void AbstractStringValidator::assignFacet() // else { - assignAdditionalFacet(key, value); + assignAdditionalFacet(key, value, manager); } }//while }//end of assigneFacet() @@ -339,7 +345,7 @@ void AbstractStringValidator::assignFacet() // check common facets // check Additional Facet Constraint // -void AbstractStringValidator::inspectFacet() +void AbstractStringValidator::inspectFacet(MemoryManager* const manager) { int thisFacetsDefined = getFacetsDefined(); @@ -351,9 +357,9 @@ void AbstractStringValidator::inspectFacet() if ((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) { if ((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_maxLen); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_maxLen, manager); else if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0)) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_minLen); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_minLen, manager); } // check 4.3.2.c1 must: minLength <= maxLength @@ -366,7 +372,8 @@ void AbstractStringValidator::inspectFacet() { REPORT_FACET_ERROR(thisMaxLength , thisMinLength - , XMLExcepts::FACET_maxLen_minLen) + , XMLExcepts::FACET_maxLen_minLen + , manager) } } @@ -378,7 +385,7 @@ void AbstractStringValidator::inspectFacet() // check enumeration // check Additional Facet Constraint // -void AbstractStringValidator::inspectFacetBase() +void AbstractStringValidator::inspectFacetBase(MemoryManager* const manager) { AbstractStringValidator *pBaseValidator = (AbstractStringValidator*) getBaseValidator(); @@ -424,7 +431,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisLength , baseMaxLength - , XMLExcepts::FACET_Len_baseMaxLen) + , XMLExcepts::FACET_Len_baseMaxLen + , manager) } if (((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) && @@ -432,7 +440,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisLength , baseMinLength - , XMLExcepts::FACET_Len_baseMinLen) + , XMLExcepts::FACET_Len_baseMinLen + , manager) } } @@ -445,7 +454,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxLength , baseLength - , XMLExcepts::FACET_maxLen_baseLen) + , XMLExcepts::FACET_maxLen_baseLen + , manager) } if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) && @@ -453,7 +463,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinLength , baseLength - , XMLExcepts::FACET_minLen_baseLen) + , XMLExcepts::FACET_minLen_baseLen + , manager) } } @@ -465,7 +476,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisLength , baseLength - , XMLExcepts::FACET_Len_baseLen) + , XMLExcepts::FACET_Len_baseLen + , manager) } } @@ -483,7 +495,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinLength , baseMaxLength - , XMLExcepts::FACET_minLen_basemaxLen) + , XMLExcepts::FACET_minLen_basemaxLen + , manager) } } @@ -497,7 +510,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinLength , baseMinLength - , XMLExcepts::FACET_minLen_base_fixed) + , XMLExcepts::FACET_minLen_base_fixed + , manager) } } @@ -507,7 +521,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMinLength , baseMinLength - , XMLExcepts::FACET_minLen_baseminLen) + , XMLExcepts::FACET_minLen_baseminLen + , manager) } } } @@ -520,7 +535,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxLength , baseMinLength - , XMLExcepts::FACET_maxLen_baseminLen) + , XMLExcepts::FACET_maxLen_baseminLen + , manager) } } @@ -534,7 +550,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxLength , baseMaxLength - , XMLExcepts::FACET_maxLen_base_fixed) + , XMLExcepts::FACET_maxLen_base_fixed + , manager) } } else @@ -543,7 +560,8 @@ void AbstractStringValidator::inspectFacetBase() { REPORT_FACET_ERROR(thisMaxLength , baseMaxLength - , XMLExcepts::FACET_maxLen_basemaxLen) + , XMLExcepts::FACET_maxLen_basemaxLen + , manager) } } } @@ -557,13 +575,13 @@ void AbstractStringValidator::inspectFacetBase() for ( ; i < enumLength; i++) { // ask parent do a complete check - pBaseValidator->checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false); + pBaseValidator->checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager); // enum shall pass this->checkContent() as well. - checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false); + checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager); } } - checkAdditionalFacetConstraints(); + checkAdditionalFacetConstraints(manager); } //end of inspectFacetBase @@ -637,26 +655,30 @@ void AbstractStringValidator::inheritFacet() // Compare methods // ----------------------------------------------------------------------- int AbstractStringValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { return XMLString::compareString(lValue, rValue); } void AbstractStringValidator::validate( const XMLCh* const content - , ValidationContext* const context ) + , ValidationContext* const context + , MemoryManager* const manager) { - checkContent(content, context, false); + checkContent(content, context, false, manager); } void AbstractStringValidator::checkContent( const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager + ) { //validate against base validator if any AbstractStringValidator *pBaseValidator = (AbstractStringValidator*) this->getBaseValidator(); if (pBaseValidator) - pBaseValidator->checkContent(content, context, true); + pBaseValidator->checkContent(content, context, true, manager); int thisFacetsDefined = getFacetsDefined(); @@ -666,20 +688,22 @@ void AbstractStringValidator::checkContent( const XMLCh* const conte // lazy construction if (getRegex() ==0) { try { + // REVISIT: cargillmem fMemoryManager or manager? setRegex(new (fMemoryManager) RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption, fMemoryManager)); } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), fMemoryManager); } } - if (getRegex()->matches(content) ==false) + if (getRegex()->matches(content, manager) ==false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -688,8 +712,8 @@ void AbstractStringValidator::checkContent( const XMLCh* const conte if (asBase) return; - checkValueSpace(content); - unsigned int length = getLength(content); + checkValueSpace(content, manager); + unsigned int length = getLength(content, manager); if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) && (length > getMaxLength())) @@ -697,7 +721,8 @@ void AbstractStringValidator::checkContent( const XMLCh* const conte REPORT_VALUE_ERROR(content , length , getMaxLength() - , XMLExcepts::VALUE_GT_maxLen) + , XMLExcepts::VALUE_GT_maxLen + , manager) } if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) && @@ -706,7 +731,8 @@ void AbstractStringValidator::checkContent( const XMLCh* const conte REPORT_VALUE_ERROR(content , length , getMinLength() - , XMLExcepts::VALUE_LT_minLen) + , XMLExcepts::VALUE_LT_minLen + , manager) } if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) && @@ -715,15 +741,16 @@ void AbstractStringValidator::checkContent( const XMLCh* const conte REPORT_VALUE_ERROR(content , length , getLength() - , XMLExcepts::VALUE_NE_Len) + , XMLExcepts::VALUE_NE_Len + , manager) } if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && (getEnumeration() != 0)) { - XMLCh* normContent = XMLString::replicate(content, fMemoryManager); - ArrayJanitor<XMLCh> jan(normContent, fMemoryManager); - normalizeContent(normContent); + XMLCh* normContent = XMLString::replicate(content, manager); + ArrayJanitor<XMLCh> jan(normContent, manager); + normalizeContent(normContent, manager); int i=0; int enumLength = getEnumeration()->size(); @@ -734,10 +761,10 @@ void AbstractStringValidator::checkContent( const XMLCh* const conte } if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } - checkAdditionalFacet(content); + checkAdditionalFacet(content, manager); } @@ -746,18 +773,51 @@ const RefArrayVectorOf<XMLCh>* AbstractStringValidator::getEnumString() const return getEnumeration(); } -void AbstractStringValidator::normalizeEnumeration() +void AbstractStringValidator::normalizeEnumeration(MemoryManager* const manager) { // default implementation: do nothing return; } -void AbstractStringValidator::normalizeContent(XMLCh* const) const +void AbstractStringValidator::normalizeContent(XMLCh* const, MemoryManager* const manager) const { // default implementation: do nothing return; } + +void AbstractStringValidator::checkAdditionalFacetConstraints(MemoryManager* const manager) const +{ + return; +} + +void AbstractStringValidator::checkAdditionalFacet(const XMLCh* const content + , MemoryManager* const manager) +{ + return; +} + +void AbstractStringValidator::inheritAdditionalFacet() +{ + return; +} + +void AbstractStringValidator::assignAdditionalFacet( const XMLCh* const key + , const XMLCh* const + , MemoryManager* const manager) +{ + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException + , XMLExcepts::FACET_Invalid_Tag + , key + , manager); +} + +int AbstractStringValidator::getLength(const XMLCh* const content + , MemoryManager* const manager) const +{ + return XMLString::stringLen(content); +} + /*** * Support for Serialization/De-serialization ***/ diff --git a/src/xercesc/validators/datatype/AbstractStringValidator.hpp b/src/xercesc/validators/datatype/AbstractStringValidator.hpp index efc32d2c761a945f166841644b7077c682076e4a..4dc4c7b6b7b484e5ea52740564d315b84c98d553 100644 --- a/src/xercesc/validators/datatype/AbstractStringValidator.hpp +++ b/src/xercesc/validators/datatype/AbstractStringValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.11 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.10 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -167,6 +170,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -177,7 +181,9 @@ public: /** @name Compare Function */ //@{ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -197,41 +203,47 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - void init(RefArrayVectorOf<XMLCh>* const enums); + void init(RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager); // // Abstract interface // virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) = 0; - - virtual void inheritAdditionalFacet() = 0; + , const XMLCh* const value + , MemoryManager* const manager); - virtual void checkAdditionalFacetConstraints() const = 0; + virtual void inheritAdditionalFacet(); - virtual void checkAdditionalFacet(const XMLCh* const content) const = 0; + virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const; - virtual void checkValueSpace(const XMLCh* const content) = 0; + virtual void checkAdditionalFacet(const XMLCh* const content + , MemoryManager* const manager); - virtual int getLength(const XMLCh* const content) const = 0; + virtual int getLength(const XMLCh* const content + , MemoryManager* const manager) const; + + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) = 0; // // to Allow ListDTV to overwrite // - virtual void inspectFacetBase(); + virtual void inspectFacetBase(MemoryManager* const manager); virtual void inheritFacet(); virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); /* ** Base64BinaryDatatypeValidator to overwrite */ - virtual void normalizeEnumeration(); + virtual void normalizeEnumeration(MemoryManager* const manager); - virtual void normalizeContent(XMLCh* const) const; + virtual void normalizeContent(XMLCh* const, MemoryManager* const manager) const; public: // ----------------------------------------------------------------------- @@ -261,9 +273,9 @@ protected: private: - void assignFacet(); + void assignFacet(MemoryManager* const manager); - void inspectFacet(); + void inspectFacet(MemoryManager* const manager); // ----------------------------------------------------------------------- // Private data members diff --git a/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp b/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp index b7d156e770d6f7b5c72d6bfd913751df57181a2d..d83764ad0211b9b13329a97b28c6e396305f2aef 100644 --- a/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -128,7 +131,7 @@ DatatypeValidator* AnySimpleTypeDatatypeValidator::newInstance delete facets; delete enums; - ThrowXML(RuntimeException, XMLExcepts::DV_InvalidOperation); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::DV_InvalidOperation, manager); // to satisfy some compilers return 0; diff --git a/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp b/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp index 3a06b8e8ab8e6e57cadbad4f6081339f4abad01d..3759c2a27c54fcc29e9d1a3f65fcda3e7c9bb089 100644 --- a/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp @@ -123,6 +123,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -151,7 +152,9 @@ public: * @param value2 string to compare * */ - int compare(const XMLCh* const value1, const XMLCh* const value2); + int compare(const XMLCh* const value1, const XMLCh* const value2 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -188,7 +191,8 @@ inline bool AnySimpleTypeDatatypeValidator::isAtomic() const { // DatatypeValidators: Compare methods // --------------------------------------------------------------------------- inline int AnySimpleTypeDatatypeValidator::compare(const XMLCh* const lValue, - const XMLCh* const rValue) + const XMLCh* const rValue + , MemoryManager* const manager) { return -1; } @@ -204,7 +208,8 @@ AnySimpleTypeDatatypeValidator::isSubstitutableBy(const DatatypeValidator* const inline void AnySimpleTypeDatatypeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { return; } diff --git a/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp b/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp index b7e57394b4a90a26d7392a224ff68a5fa744b495..7238f6ae05185fe7df3bbb70851137883181bcd5 100644 --- a/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/AnyURIDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/10/01 16:32:41 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * @@ -148,34 +151,30 @@ static const XMLCh BASE_URI[] = // --------------------------------------------------------------------------- AnyURIDatatypeValidator::AnyURIDatatypeValidator(MemoryManager* const manager) :AbstractStringValidator(0, 0, 0, DatatypeValidator::AnyURI, manager) -,fTempURI(0) {} AnyURIDatatypeValidator::~AnyURIDatatypeValidator() -{ - cleanUp(); +{ } AnyURIDatatypeValidator::AnyURIDatatypeValidator( DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets - , RefArrayVectorOf<XMLCh>* const enums + , RefArrayVectorOf<XMLCh>* const enums , const int finalSet , MemoryManager* const manager) :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::AnyURI, manager) -,fTempURI(0) { try { - init(enums); + init(enums, manager); } catch(const OutOfMemoryException&) { throw; } catch (...) - { - cleanUp(); + { throw; } } @@ -186,54 +185,31 @@ DatatypeValidator* AnyURIDatatypeValidator::newInstance( , const int finalSet , MemoryManager* const manager) { - return (DatatypeValidator*) new AnyURIDatatypeValidator(this, facets, enums, finalSet, manager); + return (DatatypeValidator*) new (manager) AnyURIDatatypeValidator(this, facets, enums, finalSet, manager); } // --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- -void AnyURIDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void AnyURIDatatypeValidator::inheritAdditionalFacet() -{} - -void AnyURIDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void AnyURIDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -int AnyURIDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - -void AnyURIDatatypeValidator::checkValueSpace(const XMLCh* const content) +void AnyURIDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // check 3.2.17.c0 must: URI (rfc 2396/2723) try { - if (!fTempURI) - fTempURI = new (fMemoryManager) XMLUri(BASE_URI, fMemoryManager); - // Support for relative URLs // According to Java 1.1: URLs may also be specified with a // String and the URL object that it is related to. // if (XMLString::stringLen(content)) - { - if (!XMLUri::isValidURI(fTempURI, content)) - ThrowXML1(InvalidDatatypeValueException + { + if (!XMLUri::isValidURI(true, content)) + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_URI_Malformed - , content); + , content + , manager); } } catch(const OutOfMemoryException&) @@ -242,9 +218,10 @@ void AnyURIDatatypeValidator::checkValueSpace(const XMLCh* const content) } catch (...) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_URI_Malformed - , content); + , content + , manager); } } @@ -258,8 +235,6 @@ IMPL_XSERIALIZABLE_TOCREATE(AnyURIDatatypeValidator) void AnyURIDatatypeValidator::serialize(XSerializeEngine& serEng) { AbstractStringValidator::serialize(serEng); - - //don't serialize fTempURI } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/datatype/AnyURIDatatypeValidator.hpp b/src/xercesc/validators/datatype/AnyURIDatatypeValidator.hpp index 55f798c5dac10354dc275e1dddf9684b0cef9530..c8993b1c954cae73f016c3d9e375b51be89bba8d 100644 --- a/src/xercesc/validators/datatype/AnyURIDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/AnyURIDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -155,44 +158,12 @@ public: protected: - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - inline void cleanUp(); - - // ----------------------------------------------------------------------- - // Private data members - // - // fTempURI - // to support relative URI, such as the urispec= "\sample" - // - // ----------------------------------------------------------------------- - - XMLUri *fTempURI; + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); +private: }; -inline void AnyURIDatatypeValidator::cleanUp() -{ - if (fTempURI) - { - delete fTempURI; - fTempURI = 0; - } -} - XERCES_CPP_NAMESPACE_END #endif diff --git a/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.cpp b/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.cpp index 4a2041561571d2ac74085f22a7d79ef5816dda1c..e3b9b078603540390f7a57182c779adb70a2b8cc 100644 --- a/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -144,7 +147,7 @@ Base64BinaryDatatypeValidator::Base64BinaryDatatypeValidator( , MemoryManager* const manager) :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::Base64Binary, manager) { - init(enums); + init(enums, manager); } DatatypeValidator* Base64BinaryDatatypeValidator::newInstance @@ -161,52 +164,40 @@ DatatypeValidator* Base64BinaryDatatypeValidator::newInstance // --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- -void Base64BinaryDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void Base64BinaryDatatypeValidator::inheritAdditionalFacet() -{} - -void Base64BinaryDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void Base64BinaryDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} -void Base64BinaryDatatypeValidator::checkValueSpace(const XMLCh* const content) +void Base64BinaryDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { - if (getLength(content) <= 0) + if (getLength(content, manager) <= 0) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Not_Base64 - , content); + , content + , manager); } } -int Base64BinaryDatatypeValidator::getLength(const XMLCh* const content) const +int Base64BinaryDatatypeValidator::getLength(const XMLCh* const content + , MemoryManager* const manager) const { - return Base64::getDataLength(content); + return Base64::getDataLength(content, manager); } -void Base64BinaryDatatypeValidator::normalizeEnumeration() +void Base64BinaryDatatypeValidator::normalizeEnumeration(MemoryManager* const manager) { int enumLength = getEnumeration()->size(); for ( int i=0; i < enumLength; i++) { - XMLString::removeWS(getEnumeration()->elementAt(i)); + XMLString::removeWS(getEnumeration()->elementAt(i), manager); } } -void Base64BinaryDatatypeValidator::normalizeContent(XMLCh* const content) const +void Base64BinaryDatatypeValidator::normalizeContent(XMLCh* const content + , MemoryManager* const manager) const { - XMLString::removeWS(content); + XMLString::removeWS(content, manager); } /*** diff --git a/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.hpp b/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.hpp index fac2110f9b74e160791049417372795dc384937c..bb35cfeaafd1f37514b1784ae40bfd18da3e92fe 100644 --- a/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/Base64BinaryDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -138,22 +141,15 @@ public: protected: - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); - virtual int getLength(const XMLCh* const content) const; + virtual int getLength(const XMLCh* const content + , MemoryManager* const manager) const; - virtual void normalizeEnumeration(); + virtual void normalizeEnumeration(MemoryManager* const manager); - virtual void normalizeContent(XMLCh* const) const; + virtual void normalizeContent(XMLCh* const, MemoryManager* const manager) const; private: diff --git a/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp b/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp index 25db59db726e08813b3f58edba446948d3c77552..e66a693ee160164ce5d41256f55b013020d0b81f 100644 --- a/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/BooleanDatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -150,14 +153,15 @@ BooleanDatatypeValidator::BooleanDatatypeValidator( // Boolean shall NOT have enumeration if (enums) { delete enums; - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag - , "enumeration"); + , "enumeration" + , manager); } XMLCh* key; XMLCh* value; - RefHashTableOfEnumerator<KVStringPair> e(facets); + RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager); while (e.hasMoreElements()) { @@ -172,9 +176,10 @@ BooleanDatatypeValidator::BooleanDatatypeValidator( } else { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag - , key); + , key + , manager); } } @@ -184,13 +189,14 @@ BooleanDatatypeValidator::BooleanDatatypeValidator( void BooleanDatatypeValidator::checkContent( const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { //validate against base validator if any BooleanDatatypeValidator *pBaseValidator = (BooleanDatatypeValidator*) this->getBaseValidator(); if (pBaseValidator !=0) - pBaseValidator->checkContent(content, context, true); + pBaseValidator->checkContent(content, context, true, manager); // we check pattern first if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 ) @@ -202,16 +208,17 @@ void BooleanDatatypeValidator::checkContent( const XMLCh* const cont } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), fMemoryManager); } } - if (getRegex()->matches(content) ==false) + if (getRegex()->matches(content, manager) ==false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -228,13 +235,14 @@ void BooleanDatatypeValidator::checkContent( const XMLCh* const cont } if (i == ARRAYSIZE) - ThrowXML(InvalidDatatypeValueException, XMLExcepts::CM_UnaryOpHadBinType); + ThrowXMLwithMemMgr(InvalidDatatypeValueException, XMLExcepts::CM_UnaryOpHadBinType, manager); //Not valid boolean type } int BooleanDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { // need to check by bool semantics // 1 == true @@ -273,9 +281,8 @@ const XMLCh* BooleanDatatypeValidator::getCanonicalRepresentation(const XMLCh* , MemoryManager* const memMgr) const { BooleanDatatypeValidator *temp = (BooleanDatatypeValidator*) this; - temp->checkContent(rawData, 0, false); - MemoryManager* toUse = memMgr? memMgr : getMemoryManager(); + temp->checkContent(rawData, 0, false, toUse); return ( XMLString::equals(rawData, fgValueSpace[0]) || XMLString::equals(rawData, fgValueSpace[2]) ) ? diff --git a/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp b/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp index db392cd94d5b156ca2372d4c17723d1b971d6efd..8736374dcfb389015c8efcc8b9267bc20bc9aa35 100644 --- a/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/BooleanDatatypeValidator.hpp @@ -125,6 +125,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -142,7 +143,9 @@ public: * @param content2 * @return */ - int compare(const XMLCh* const, const XMLCh* const); + int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -167,7 +170,8 @@ private: virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); // ----------------------------------------------------------------------- // Private data members @@ -210,9 +214,10 @@ inline DatatypeValidator* BooleanDatatypeValidator::newInstance } inline void BooleanDatatypeValidator::validate( const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { - checkContent(content, context, false); + checkContent(content, context, false, manager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/datatype/DatatypeValidator.cpp b/src/xercesc/validators/datatype/DatatypeValidator.cpp index 85a01bfa1e6a04e2d5b588a5a42cf7ce475e92b9..6e99fef0231f8bae1f003b32efe23e47cd9a7262 100644 --- a/src/xercesc/validators/datatype/DatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.19 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.18 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -639,9 +642,8 @@ const XMLCh* DatatypeValidator::getCanonicalRepresentation(const XMLCh* , MemoryManager* const memMgr) const { DatatypeValidator *temp = (DatatypeValidator*) this; - temp->validate(rawData, 0); - MemoryManager* toUse = memMgr? memMgr : fMemoryManager; + temp->validate(rawData, 0, toUse); return XMLString::replicate(rawData, toUse); } diff --git a/src/xercesc/validators/datatype/DatatypeValidator.hpp b/src/xercesc/validators/datatype/DatatypeValidator.hpp index 84a0a212d9cede355ba08267d607d172a8aeabd9..3f184c7022791b224ba77a57214e87fa4a70293d 100644 --- a/src/xercesc/validators/datatype/DatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DatatypeValidator.hpp @@ -280,6 +280,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ) = 0; /** @@ -314,7 +315,9 @@ public: * We will provide a default behavior that should be redefined at the * children level, if necessary (i.e. boolean case). */ - virtual int compare(const XMLCh* const value1, const XMLCh* const value2); + virtual int compare(const XMLCh* const value1, const XMLCh* const value2 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -725,7 +728,8 @@ inline void DatatypeValidator::setNumeric(bool numeric) // DatatypeValidators: Compare methods // --------------------------------------------------------------------------- inline int DatatypeValidator::compare(const XMLCh* const lValue, - const XMLCh* const rValue) + const XMLCh* const rValue + , MemoryManager* const manager) { return XMLString::compareString(lValue, rValue); } diff --git a/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp b/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp index b01bb57945620ecf9881afb3ac86e124e39ee995..81f43c28427dbc7d5bd4a52e5ce0c51ca10d41cc 100644 --- a/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp +++ b/src/xercesc/validators/datatype/DatatypeValidatorFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.24 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.23 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * @@ -910,6 +913,7 @@ DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator , const bool isDerivedByList , const int finalSet , const bool isUserDefined + , MemoryManager* const userManager ) { if (baseValidator == 0) { @@ -927,7 +931,7 @@ DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator DatatypeValidator* datatypeValidator = 0; MemoryManager* const manager = (isUserDefined) - ? fMemoryManager : XMLPlatformUtils::fgMemoryManager; + ? userManager : XMLPlatformUtils::fgMemoryManager; if (isDerivedByList) { datatypeValidator = new (manager) ListDatatypeValidator(baseValidator, facets, enums, finalSet, manager); @@ -1024,7 +1028,7 @@ DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator if (isUserDefined) { if (!fUserDefinedRegistry) { - fUserDefinedRegistry = new (fMemoryManager) RefHashTableOf<DatatypeValidator>(29, fMemoryManager); + fUserDefinedRegistry = new (userManager) RefHashTableOf<DatatypeValidator>(29, userManager); } fUserDefinedRegistry->put((void *)typeName, datatypeValidator); @@ -1056,6 +1060,7 @@ DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator , RefVectorOf<DatatypeValidator>* const validators , const int finalSet , const bool userDefined + , MemoryManager* const userManager ) { if (validators == 0) @@ -1063,7 +1068,7 @@ DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator DatatypeValidator* datatypeValidator = 0; MemoryManager* const manager = (userDefined) - ? fMemoryManager : XMLPlatformUtils::fgMemoryManager; + ? userManager : XMLPlatformUtils::fgMemoryManager; datatypeValidator = new (manager) UnionDatatypeValidator(validators, finalSet, manager); @@ -1072,7 +1077,7 @@ DatatypeValidator* DatatypeValidatorFactory::createDatatypeValidator if (userDefined) { if (!fUserDefinedRegistry) { - fUserDefinedRegistry = new (fMemoryManager) RefHashTableOf<DatatypeValidator>(29, fMemoryManager); + fUserDefinedRegistry = new (userManager) RefHashTableOf<DatatypeValidator>(29, userManager); } fUserDefinedRegistry->put((void *)typeName, datatypeValidator); diff --git a/src/xercesc/validators/datatype/DatatypeValidatorFactory.hpp b/src/xercesc/validators/datatype/DatatypeValidatorFactory.hpp index c0d21c38b17e46f8f1d9c491ffb1ecfa48777edb..8d50bbad57edad70e56e93fa52dbc8204ebe44af 100644 --- a/src/xercesc/validators/datatype/DatatypeValidatorFactory.hpp +++ b/src/xercesc/validators/datatype/DatatypeValidatorFactory.hpp @@ -214,6 +214,7 @@ public: , const bool isDerivedByList , const int finalSet = 0 , const bool isUserDefined = true + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -235,6 +236,7 @@ public: , RefVectorOf<DatatypeValidator>* const validators , const int finalSet , const bool isUserDefined = true + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/validators/datatype/DateDatatypeValidator.cpp b/src/xercesc/validators/datatype/DateDatatypeValidator.cpp index 49c949085b0d979d0307e5df4d926fcc98992d50..004cb15646b635183f4c6b5400e2eb08f14387c8 100644 --- a/src/xercesc/validators/datatype/DateDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DateDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -117,10 +120,10 @@ DateDatatypeValidator::DateDatatypeValidator( , RefHashTableOf<KVStringPair>* const facets , RefArrayVectorOf<XMLCh>* const enums , const int finalSet - , MemoryManager* const manager) + , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Date, manager) { - init(enums); + init(enums, manager); } DateDatatypeValidator::~DateDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* DateDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* DateDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* DateDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/DateDatatypeValidator.hpp b/src/xercesc/validators/datatype/DateDatatypeValidator.hpp index 0e09b9cb13ec8903ae20da4a25f4af47ab219285..74467306d5e9b39eb7355856596a84bab4810a3d 100644 --- a/src/xercesc/validators/datatype/DateDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DateDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,7 +138,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp index b01d0a1490ec5d604a0db55b188eb03d493e0b89..12d92b0e172188bac334fd34122dd85d050ee5f4 100644 --- a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.12 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * @@ -126,7 +129,7 @@ DateTimeDatatypeValidator::DateTimeDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::DateTime, manager) { - init(enums); + init(enums, manager); } DateTimeDatatypeValidator::~DateTimeDatatypeValidator() @@ -146,9 +149,9 @@ DatatypeValidator* DateTimeDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* DateTimeDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* DateTimeDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { @@ -178,9 +181,9 @@ const XMLCh* DateTimeDatatypeValidator::getCanonicalRepresentation(const XMLCh* // we need the checkContent to build the fDateTime // to get the canonical representation DateTimeDatatypeValidator* temp = (DateTimeDatatypeValidator*) this; - temp->checkContent(rawData, 0, false); - MemoryManager* toUse = memMgr? memMgr : fMemoryManager; + temp->checkContent(rawData, 0, false, toUse); + //Have the fDateTime to do the job return fDateTime->getDateTimeCanonicalRepresentation(toUse); } diff --git a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp index 2665ed65621fd96c7c93e903bca5731b77cd990e..23be0da3cac1111219119cd093d70664e3759a8a 100644 --- a/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DateTimeDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -144,7 +147,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/datatype/DateTimeValidator.cpp b/src/xercesc/validators/datatype/DateTimeValidator.cpp index 2fedb7c6c4598d5ec0861ac1ae44c973d389acc8..18f8877b3c7eb53b90ed1c766cb9e33c012da904 100644 --- a/src/xercesc/validators/datatype/DateTimeValidator.cpp +++ b/src/xercesc/validators/datatype/DateTimeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.12 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -117,11 +120,12 @@ static XMLCh value2[BUF_LEN+1]; // --------------------------------------------------------------------------- // Macro // --------------------------------------------------------------------------- -#define REPORT_VALUE_ERROR(val1, val2, except_code) \ - ThrowXML2(InvalidDatatypeValueException \ +#define REPORT_VALUE_ERROR(val1, val2, except_code, manager) \ + ThrowXMLwithMemMgr2(InvalidDatatypeValueException \ , except_code \ , val1->getRawData() \ - , val2->getRawData()); + , val2->getRawData() \ + , manager); // --------------------------------------------------------------------------- // Constructors and Destructor @@ -145,19 +149,21 @@ DateTimeValidator::DateTimeValidator( } void DateTimeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { - checkContent(content, context, false); + checkContent(content, context, false, manager); } int DateTimeValidator::compare(const XMLCh* const value1 - , const XMLCh* const value2) + , const XMLCh* const value2 + , MemoryManager* const manager) { try { - XMLDateTime *pDate1 = parse(value1); + XMLDateTime *pDate1 = parse(value1, manager); Janitor<XMLDateTime> jName1(pDate1); - XMLDateTime *pDate2 = parse(value2); + XMLDateTime *pDate2 = parse(value2, manager); Janitor<XMLDateTime> jName2(pDate2); int result = compareDates(pDate1, pDate2, true); return (result==INDETERMINATE)? -1 : result; @@ -173,32 +179,18 @@ int DateTimeValidator::compare(const XMLCh* const value1 } -void DateTimeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void DateTimeValidator::inheritAdditionalFacet() -{} - -void DateTimeValidator::checkAdditionalFacetConstraints() const -{} - -void DateTimeValidator::checkAdditionalFacetConstraintsBase() const -{} void DateTimeValidator::checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { + bool deleteLazy = false; //validate against base validator if any DateTimeValidator *pBaseValidator = (DateTimeValidator*) this->getBaseValidator(); if (pBaseValidator) - pBaseValidator->checkContent(content, context, true); + pBaseValidator->checkContent(content, context, true, manager); int thisFacetsDefined = getFacetsDefined(); @@ -212,16 +204,17 @@ void DateTimeValidator::checkContent(const XMLCh* const content } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), fMemoryManager); } } - if (getRegex()->matches(content) ==false) + if (getRegex()->matches(content, manager) ==false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -236,7 +229,12 @@ void DateTimeValidator::checkContent(const XMLCh* const content if (fDateTime) fDateTime->setBuffer(content); else - fDateTime = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + { + fDateTime = new (manager) XMLDateTime(content, manager); + // REVISIT: cargillmem + if (manager != fMemoryManager) + deleteLazy = true; + } parse(fDateTime); @@ -247,7 +245,8 @@ void DateTimeValidator::checkContent(const XMLCh* const content { REPORT_VALUE_ERROR( fDateTime , getMaxExclusive() - , XMLExcepts::VALUE_exceed_maxExcl) + , XMLExcepts::VALUE_exceed_maxExcl + , manager) } } @@ -259,7 +258,8 @@ void DateTimeValidator::checkContent(const XMLCh* const content { REPORT_VALUE_ERROR( fDateTime , getMaxInclusive() - , XMLExcepts::VALUE_exceed_maxIncl) + , XMLExcepts::VALUE_exceed_maxIncl + , manager) } } @@ -271,7 +271,8 @@ void DateTimeValidator::checkContent(const XMLCh* const content { REPORT_VALUE_ERROR( fDateTime , getMinInclusive() - , XMLExcepts::VALUE_exceed_minIncl) + , XMLExcepts::VALUE_exceed_minIncl + , manager) } } @@ -282,7 +283,8 @@ void DateTimeValidator::checkContent(const XMLCh* const content { REPORT_VALUE_ERROR( fDateTime , getMinExclusive() - , XMLExcepts::VALUE_exceed_minExcl) + , XMLExcepts::VALUE_exceed_minExcl + , manager) } } @@ -298,7 +300,16 @@ void DateTimeValidator::checkContent(const XMLCh* const content } if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); + } + + if (deleteLazy) + { + // REVISIT: cargillmem + // hmm.. if an exception is thrown do we cleanup... + // no but this avoids a number of exceptions for now... + delete fDateTime; + fDateTime = 0; } } @@ -345,25 +356,25 @@ int DateTimeValidator::compareDates(const XMLDateTime* const date1 void DateTimeValidator::setMaxInclusive(const XMLCh* const value) { - fMaxInclusive = parse(value); + fMaxInclusive = parse(value, fMemoryManager); } void DateTimeValidator::setMaxExclusive(const XMLCh* const value) { - fMaxExclusive = parse(value); + fMaxExclusive = parse(value, fMemoryManager); } void DateTimeValidator::setMinInclusive(const XMLCh* const value) { - fMinInclusive = parse(value); + fMinInclusive = parse(value, fMemoryManager); } void DateTimeValidator::setMinExclusive(const XMLCh* const value) { - fMinExclusive = parse(value); + fMinExclusive = parse(value, fMemoryManager); } -void DateTimeValidator::setEnumeration() +void DateTimeValidator::setEnumeration(MemoryManager* const manager) { // to do: do we need to check against base value space??? @@ -375,7 +386,7 @@ void DateTimeValidator::setEnumeration() fEnumerationInherited = false; for ( int i = 0; i < enumLength; i++) - fEnumeration->insertElementAt(parse(fStrEnumeration->elementAt(i)), i); + fEnumeration->insertElementAt(parse(fStrEnumeration->elementAt(i), fMemoryManager), i); } diff --git a/src/xercesc/validators/datatype/DateTimeValidator.hpp b/src/xercesc/validators/datatype/DateTimeValidator.hpp index c6e01f3b68b85127017bfd8512e7f5cf1e43fb77..ac53152a825f52e3bb501b780bf51189ab30104c 100644 --- a/src/xercesc/validators/datatype/DateTimeValidator.hpp +++ b/src/xercesc/validators/datatype/DateTimeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * @@ -112,10 +115,13 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual int compare(const XMLCh* const value1 - , const XMLCh* const value2); + , const XMLCh* const value2 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); /*** * Support for Serialization/De-serialization @@ -140,21 +146,13 @@ protected: // Abstract interface // - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - virtual int compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue); virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); virtual void setMaxInclusive(const XMLCh* const); @@ -164,14 +162,14 @@ protected: virtual void setMinExclusive(const XMLCh* const); - virtual void setEnumeration(); + virtual void setEnumeration(MemoryManager* const manager); protected: // ----------------------------------------------------------------------- // helper interface: to be implemented/overwritten by derived class // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const) = 0; + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager) = 0; virtual void parse(XMLDateTime* const) = 0; // to be overwritten by duration diff --git a/src/xercesc/validators/datatype/DayDatatypeValidator.cpp b/src/xercesc/validators/datatype/DayDatatypeValidator.cpp index 3253929fbbae5a351a98c95c6a339b61d9500fce..ad3da0c41d7e7260976ddd008041854fdbc800fe 100644 --- a/src/xercesc/validators/datatype/DayDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DayDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -120,7 +123,7 @@ DayDatatypeValidator::DayDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Day, manager) { - init(enums); + init(enums, manager); } DayDatatypeValidator::~DayDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* DayDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* DayDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* DayDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/DayDatatypeValidator.hpp b/src/xercesc/validators/datatype/DayDatatypeValidator.hpp index 82149e0f05c2c26ca8afa7ec8d50af399ae48723..a7cea84a92121598b1042229fe99fa4654a1a943 100644 --- a/src/xercesc/validators/datatype/DayDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DayDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,7 +138,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp b/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp index 94520527388a2301cc1548fab57e5790622894c1..88a279a71a883eb0a7cab03cf6da7eb85a77f907 100644 --- a/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DecimalDatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.19 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.18 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * @@ -203,15 +206,15 @@ DecimalDatatypeValidator::DecimalDatatypeValidator(MemoryManager* const manager) DecimalDatatypeValidator::DecimalDatatypeValidator( DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets - , RefArrayVectorOf<XMLCh>* const enums + , RefArrayVectorOf<XMLCh>* const enums , const int finalSet - , MemoryManager* const manager) + , MemoryManager* const manager) :AbstractNumericValidator(baseValidator, facets, finalSet, DatatypeValidator::Decimal, manager) , fTotalDigits(0) , fFractionDigits(0) , fCompareData(0) { - init(enums); + init(enums, manager); } DecimalDatatypeValidator::~DecimalDatatypeValidator() @@ -224,10 +227,11 @@ DecimalDatatypeValidator::~DecimalDatatypeValidator() // Compare methods // ----------------------------------------------------------------------- int DecimalDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { - XMLBigDecimal lObj(lValue, fMemoryManager); - XMLBigDecimal rObj(rValue, fMemoryManager); + XMLBigDecimal lObj(lValue, manager); + XMLBigDecimal rObj(rValue, manager); return compareValues(&lObj, &rObj); } @@ -259,23 +263,24 @@ DecimalDatatypeValidator::DecimalDatatypeValidator(DatatypeValidator* } void DecimalDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) + , const XMLCh* const value + , MemoryManager* const manager) { if (XMLString::equals(key, SchemaSymbols::fgELT_TOTALDIGITS)) { int val; try { - val = XMLString::parseInt(value); + val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_TotalDigit, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_TotalDigit, value, manager); } // check 4.3.11.c0 must: totalDigits > 0 if ( val <= 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_PosInt_TotalDigit, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_PosInt_TotalDigit, value, manager); setTotalDigits(val); setFacetsDefined(DatatypeValidator::FACET_TOTALDIGITS); @@ -285,25 +290,26 @@ void DecimalDatatypeValidator::assignAdditionalFacet(const XMLCh* const key int val; try { - val = XMLString::parseInt(value); + val = XMLString::parseInt(value, manager); } catch (NumberFormatException&) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_FractDigit, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_FractDigit, value, manager); } // check 4.3.12.c0 must: fractionDigits > 0 if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_FractDigit, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_FractDigit, value, manager); setFractionDigits(val); setFacetsDefined(DatatypeValidator::FACET_FRACTIONDIGITS); } else { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag - , key); + , key + , manager); } } @@ -335,7 +341,7 @@ void DecimalDatatypeValidator::inheritAdditionalFacet() } } -void DecimalDatatypeValidator::checkAdditionalFacetConstraints() const +void DecimalDatatypeValidator::checkAdditionalFacetConstraints(MemoryManager* const manager) const { int thisFacetsDefined = getFacetsDefined(); @@ -345,18 +351,19 @@ void DecimalDatatypeValidator::checkAdditionalFacetConstraints() const { if ( fFractionDigits > fTotalDigits ) { - XMLString::binToText(getFractionDigits(), value1, BUF_LEN, 10); - XMLString::binToText(getTotalDigits(), value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException + XMLString::binToText(getFractionDigits(), value1, BUF_LEN, 10, manager); + XMLString::binToText(getTotalDigits(), value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_TotDigit_FractDigit , value2 - , value1); + , value1 + , manager); } } } -void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase() const +void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase(MemoryManager* const manager) const { DecimalDatatypeValidator *numBase = (DecimalDatatypeValidator*) getBaseValidator(); @@ -374,24 +381,26 @@ void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase() const if ( (( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && ( fTotalDigits > numBase->fTotalDigits )) { - XMLString::binToText(fTotalDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException + XMLString::binToText(fTotalDigits, value1, BUF_LEN, 10, manager); + XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_totalDigit_base_totalDigit , value1 - , value2); + , value2 + , manager); } if ( (( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && (( numBase->getFixed() & DatatypeValidator::FACET_TOTALDIGITS) != 0) && ( fTotalDigits != numBase->fTotalDigits )) { - XMLString::binToText(fTotalDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException + XMLString::binToText(fTotalDigits, value1, BUF_LEN, 10, manager); + XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_totalDigit_base_fixed , value1 - , value2); + , value2 + , manager); } } @@ -401,24 +410,26 @@ void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase() const if ( (( baseFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && ( fFractionDigits > numBase->fFractionDigits )) { - XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fFractionDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException + XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10, manager); + XMLString::binToText(numBase->fFractionDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_fractDigit_base_fractDigit , value1 - , value2); + , value2 + , manager); } // check question error: fractionDigits > base.totalDigits ??? if ( (( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && ( fFractionDigits > numBase->fTotalDigits )) { - XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException + XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10, manager); + XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_fractDigit_base_totalDigit , value1 - , value2); + , value2 + , manager); } // fractionDigits != base.fractionDigits if (base.fixed) @@ -426,12 +437,13 @@ void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase() const (( numBase->getFixed() & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && ( fFractionDigits != numBase->fFractionDigits )) { - XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fFractionDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException + XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10, manager); + XMLString::binToText(numBase->fFractionDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_fractDigit_base_fixed , value1 - , value2); + , value2 + , manager); } } @@ -440,7 +452,8 @@ void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase() const int DecimalDatatypeValidator::compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue) { - return XMLBigDecimal::compareValues((XMLBigDecimal*) lValue, (XMLBigDecimal*) rValue); + return XMLBigDecimal::compareValues((XMLBigDecimal*) lValue, (XMLBigDecimal*) rValue, + ((XMLBigDecimal*)lValue)->getMemoryManager()); } void DecimalDatatypeValidator::setMaxInclusive(const XMLCh* const value) @@ -463,7 +476,7 @@ void DecimalDatatypeValidator::setMinExclusive(const XMLCh* const value) fMinExclusive = new (fMemoryManager) XMLBigDecimal(value, fMemoryManager); } -void DecimalDatatypeValidator::setEnumeration() +void DecimalDatatypeValidator::setEnumeration(MemoryManager* const manager) { // check 4.3.5.c0 must: enumeration values from the value space of base // @@ -483,14 +496,15 @@ void DecimalDatatypeValidator::setEnumeration() { for ( i = 0; i < enumLength; i++) { - numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false); + numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } } catch (XMLException&) { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base - , fStrEnumeration->elementAt(i)); + , fStrEnumeration->elementAt(i) + , manager); } } @@ -499,15 +513,15 @@ void DecimalDatatypeValidator::setEnumeration() // for ( i = 0; i < enumLength; i++) { - checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false); + checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } - fEnumeration = new (fMemoryManager) RefVectorOf<XMLNumber>(enumLength, true, fMemoryManager); + fEnumeration = new (manager) RefVectorOf<XMLNumber>(enumLength, true, manager); fEnumerationInherited = false; for ( i = 0; i < enumLength; i++) { - fEnumeration->insertElementAt(new (fMemoryManager) XMLBigDecimal(fStrEnumeration->elementAt(i), fMemoryManager), i); + fEnumeration->insertElementAt(new (manager) XMLBigDecimal(fStrEnumeration->elementAt(i), manager), i); } } @@ -517,13 +531,15 @@ void DecimalDatatypeValidator::setEnumeration() // ----------------------------------------------------------------------- void DecimalDatatypeValidator::checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { + bool deleteLazy = false; //validate against base validator if any DecimalDatatypeValidator *pBase = (DecimalDatatypeValidator*) this->getBaseValidator(); if (pBase) - pBase->checkContent(content, context, true); + pBase->checkContent(content, context, true, manager); int thisFacetsDefined = getFacetsDefined(); @@ -533,20 +549,22 @@ void DecimalDatatypeValidator::checkContent(const XMLCh* const conte // lazy construction if (getRegex() ==0) { try { + // REVISIT: cargillmem fMemoryManager vs manager setRegex(new (fMemoryManager) RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption, fMemoryManager)); } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager); } } - if (getRegex()->matches(content) ==false) + if (getRegex()->matches(content, manager) ==false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -558,8 +576,12 @@ void DecimalDatatypeValidator::checkContent(const XMLCh* const conte try { if (fCompareData) fCompareData->setDecimalValue(content); - else - fCompareData = new (fMemoryManager) XMLBigDecimal(content, fMemoryManager); + else { + // REVISIT: cargillmem + fCompareData = new (manager) XMLBigDecimal(content, manager); + if (manager != fMemoryManager) + deleteLazy = true; + } if (getEnumeration()) { @@ -572,22 +594,23 @@ void DecimalDatatypeValidator::checkContent(const XMLCh* const conte } if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } - boundsCheck(fCompareData); + boundsCheck(fCompareData, manager); if ( (thisFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0 ) { if ( fCompareData->getScale() > fFractionDigits ) { - XMLString::binToText(fCompareData->getScale(), value1, BUF_LEN, 10); - XMLString::binToText(fFractionDigits, value2, BUF_LEN, 10); - ThrowXML3(InvalidDatatypeFacetException + XMLString::binToText(fCompareData->getScale(), value1, BUF_LEN, 10, manager); + XMLString::binToText(fFractionDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr3(InvalidDatatypeFacetException , XMLExcepts::VALUE_exceed_fractDigit , fCompareData->getRawData() , value1 - , value2); + , value2 + , manager); } } @@ -595,13 +618,14 @@ void DecimalDatatypeValidator::checkContent(const XMLCh* const conte { if ( fCompareData->getTotalDigit() > fTotalDigits ) { - XMLString::binToText(fCompareData->getTotalDigit(), value1, BUF_LEN, 10); - XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10); - ThrowXML3(InvalidDatatypeFacetException + XMLString::binToText(fCompareData->getTotalDigit(), value1, BUF_LEN, 10, manager); + XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr3(InvalidDatatypeFacetException , XMLExcepts::VALUE_exceed_totalDigit , fCompareData->getRawData() , value1 - , value2); + , value2 + , manager); } /*** @@ -613,23 +637,29 @@ void DecimalDatatypeValidator::checkContent(const XMLCh* const conte if ( fCompareData->getScale() > fTotalDigits ) { - XMLString::binToText(fCompareData->getScale(), value1, BUF_LEN, 10); - XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10); - ThrowXML3(InvalidDatatypeFacetException + XMLString::binToText(fCompareData->getScale(), value1, BUF_LEN, 10, manager); + XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr3(InvalidDatatypeFacetException , XMLExcepts::VALUE_exceed_totalDigit , fCompareData->getRawData() , value1 - , value2); - } - + , value2 + , manager); + } } - } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage()); + if (deleteLazy) { + delete fCompareData; + fCompareData = 0; + } + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage(), manager); + } + if (deleteLazy) { + delete fCompareData; + fCompareData = 0; } - } /*** @@ -678,10 +708,9 @@ const XMLCh* DecimalDatatypeValidator::getCanonicalRepresentation(const XMLCh* { //Validate it first DecimalDatatypeValidator* temp = (DecimalDatatypeValidator*) this; - temp->checkContent(rawData, 0, false); - MemoryManager* toUse = memMgr? memMgr : fMemoryManager; - + temp->checkContent(rawData, 0, false, toUse); + XMLCanRepGroup::CanRepGroup dvType = DatatypeValidatorFactory::getCanRepGroup(temp); if ((dvType == XMLCanRepGroup::Decimal_Derivated_signed) || @@ -702,7 +731,6 @@ const XMLCh* DecimalDatatypeValidator::getCanonicalRepresentation(const XMLCh* { return XMLString::replicate(rawData, toUse); } - } /*** diff --git a/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp b/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp index c2dcff7fbb40ec87f19e16f9c02ee2fbdb78a5d4..873ac923d27f3e0ecab9a8654e5426534dc4abfc 100644 --- a/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DecimalDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.11 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.10 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -150,7 +153,9 @@ public: * @param content2 * @return */ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -196,13 +201,14 @@ protected: // ----------------------------------------------------------------------- virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); + , const XMLCh* const value + , MemoryManager* const manager); virtual void inheritAdditionalFacet(); - virtual void checkAdditionalFacetConstraints() const; + virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const; - virtual void checkAdditionalFacetConstraintsBase() const; + virtual void checkAdditionalFacetConstraintsBase(MemoryManager* const manager) const; virtual int compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue); @@ -215,7 +221,7 @@ protected: virtual void setMinExclusive(const XMLCh* const); - virtual void setEnumeration(); + virtual void setEnumeration(MemoryManager* const manager); // ----------------------------------------------------------------------- // Abstract interface from AbstractNumericValidator @@ -223,7 +229,8 @@ protected: virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); public: // ----------------------------------------------------------------------- diff --git a/src/xercesc/validators/datatype/DoubleDatatypeValidator.cpp b/src/xercesc/validators/datatype/DoubleDatatypeValidator.cpp index 965e73f8f0ba76a58e133608e13e86c7db225355..3c5f36be2526eca0921a16bea853b9f16fe7f1ae 100644 --- a/src/xercesc/validators/datatype/DoubleDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DoubleDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -134,7 +137,7 @@ DoubleDatatypeValidator::DoubleDatatypeValidator( , MemoryManager* const manager) :AbstractNumericValidator(baseValidator, facets, finalSet, DatatypeValidator::Double, manager) { - init(enums); + init(enums, manager); } DoubleDatatypeValidator::~DoubleDatatypeValidator() @@ -144,10 +147,11 @@ DoubleDatatypeValidator::~DoubleDatatypeValidator() // Compare methods // ----------------------------------------------------------------------- int DoubleDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { - XMLDouble lObj(lValue, fMemoryManager); - XMLDouble rObj(rValue, fMemoryManager); + XMLDouble lObj(lValue, manager); + XMLDouble rObj(rValue, manager); return compareValues(&lObj, &rObj); } @@ -176,23 +180,6 @@ DoubleDatatypeValidator::DoubleDatatypeValidator(DatatypeValidator* c //do not invoke init here !!! } -void DoubleDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void DoubleDatatypeValidator::inheritAdditionalFacet() -{} - -void DoubleDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void DoubleDatatypeValidator::checkAdditionalFacetConstraintsBase() const -{} - int DoubleDatatypeValidator::compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue) { @@ -219,7 +206,7 @@ void DoubleDatatypeValidator::setMinExclusive(const XMLCh* const value) fMinExclusive = new (fMemoryManager) XMLDouble(value, fMemoryManager); } -void DoubleDatatypeValidator::setEnumeration() +void DoubleDatatypeValidator::setEnumeration(MemoryManager* const manager) { // check 4.3.5.c0 must: enumeration values from the value space of base // @@ -239,14 +226,15 @@ void DoubleDatatypeValidator::setEnumeration() { for ( i = 0; i < enumLength; i++) { - numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false); + numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } } catch (XMLException&) { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base - , fStrEnumeration->elementAt(i)); + , fStrEnumeration->elementAt(i) + , manager); } } @@ -256,15 +244,15 @@ void DoubleDatatypeValidator::setEnumeration() // for ( i = 0; i < enumLength; i++) { - checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false); + checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } - fEnumeration = new (fMemoryManager) RefVectorOf<XMLNumber>(enumLength, true, fMemoryManager); + fEnumeration = new (manager) RefVectorOf<XMLNumber>(enumLength, true, manager); fEnumerationInherited = false; for ( i = 0; i < enumLength; i++) { - fEnumeration->insertElementAt(new (fMemoryManager) XMLDouble(fStrEnumeration->elementAt(i), fMemoryManager), i); + fEnumeration->insertElementAt(new (manager) XMLDouble(fStrEnumeration->elementAt(i), manager), i); } } @@ -274,13 +262,14 @@ void DoubleDatatypeValidator::setEnumeration() void DoubleDatatypeValidator::checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { //validate against base validator if any DoubleDatatypeValidator *pBase = (DoubleDatatypeValidator*) this->getBaseValidator(); if (pBase) - pBase->checkContent(content, context, true); + pBase->checkContent(content, context, true, manager); // we check pattern first if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 ) @@ -292,16 +281,17 @@ void DoubleDatatypeValidator::checkContent(const XMLCh* const conten } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), fMemoryManager); } } - if (getRegex()->matches(content) ==false) + if (getRegex()->matches(content, manager) ==false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -311,7 +301,7 @@ void DoubleDatatypeValidator::checkContent(const XMLCh* const conten return; try { - XMLDouble theValue(content, fMemoryManager); + XMLDouble theValue(content, manager); XMLDouble *theData = &theValue; if (getEnumeration()) @@ -325,15 +315,15 @@ void DoubleDatatypeValidator::checkContent(const XMLCh* const conten } if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } - boundsCheck(theData); + boundsCheck(theData, manager); } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage(), manager); } } diff --git a/src/xercesc/validators/datatype/DoubleDatatypeValidator.hpp b/src/xercesc/validators/datatype/DoubleDatatypeValidator.hpp index 49a320deef57a74517e0df9fb62514cda8db1910..4a62a200db010c9b901d247ff1359b3b983aaddc 100644 --- a/src/xercesc/validators/datatype/DoubleDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DoubleDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -142,7 +145,9 @@ public: * @param content2 * @return */ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -181,15 +186,6 @@ protected: // Abstract interface from AbstractNumericFacetValidator // ----------------------------------------------------------------------- - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - virtual int compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue); @@ -201,7 +197,7 @@ protected: virtual void setMinExclusive(const XMLCh* const); - virtual void setEnumeration(); + virtual void setEnumeration(MemoryManager* const manager); // ----------------------------------------------------------------------- // Abstract interface from AbstractNumericValidator @@ -209,7 +205,8 @@ protected: virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); }; diff --git a/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp b/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp index 69d42968389dbe5dd4007e3b2360815d1092cba7..ba7890c005b24adf87c34d41cf927298f53e62f5 100644 --- a/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/DurationDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -120,7 +123,7 @@ DurationDatatypeValidator::DurationDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Duration, manager) { - init(enums); + init(enums, manager); } DurationDatatypeValidator::~DurationDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* DurationDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* DurationDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* DurationDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/DurationDatatypeValidator.hpp b/src/xercesc/validators/datatype/DurationDatatypeValidator.hpp index 9c0240733d19d6ea1d63e9ef40454d84bc40735f..0f84d36f54a39de3a31aefc1d016f8aa9ce4ed5d 100644 --- a/src/xercesc/validators/datatype/DurationDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/DurationDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,7 +138,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); virtual int compareDates(const XMLDateTime* const , const XMLDateTime* const diff --git a/src/xercesc/validators/datatype/ENTITYDatatypeValidator.cpp b/src/xercesc/validators/datatype/ENTITYDatatypeValidator.cpp index cf15f560eb291c050e3f8b76f34dcd5450f7e06a..8c349d66de7c67166e5512b71335c95b7a324345 100644 --- a/src/xercesc/validators/datatype/ENTITYDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/ENTITYDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.9 2003/12/17 00:18:38 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/11/12 20:31:33 peiyongz * Using ValidationContext to validate() * @@ -128,7 +131,7 @@ ENTITYDatatypeValidator::ENTITYDatatypeValidator( , MemoryManager* const manager) :StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::ENTITY, manager) { - init(enums); + init(enums, manager); } ENTITYDatatypeValidator::~ENTITYDatatypeValidator() @@ -149,19 +152,21 @@ DatatypeValidator* ENTITYDatatypeValidator::newInstance // Compare methods // ----------------------------------------------------------------------- int ENTITYDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { return ( XMLString::equals(lValue, rValue)? 0 : -1); } void ENTITYDatatypeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { // use StringDatatypeValidator (which in turn, invoke // the baseValidator) to validate content against // facets if any. // - StringDatatypeValidator::validate(content, context); + StringDatatypeValidator::validate(content, context, manager); // // parse the entity iff an EntityDeclPool is provided @@ -173,16 +178,18 @@ void ENTITYDatatypeValidator::validate(const XMLCh* const content } -void ENTITYDatatypeValidator::checkValueSpace(const XMLCh* const content) +void ENTITYDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // 3.3.11 check must: "NCName" // if ( !XMLString::isValidNCName(content)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Invalid_NCName - , content); + , content + , manager); } } diff --git a/src/xercesc/validators/datatype/ENTITYDatatypeValidator.hpp b/src/xercesc/validators/datatype/ENTITYDatatypeValidator.hpp index ec5b7b404a211736b2587b5f9986fecbafb3db92..b962af32416f88dd9f13fbb763e27a1d4ac916c9 100644 --- a/src/xercesc/validators/datatype/ENTITYDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/ENTITYDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -153,6 +156,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -170,7 +174,8 @@ public: * @param content2 * @return */ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} @@ -212,7 +217,8 @@ protected: , const int finalSet , const ValidatorType type); - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/FloatDatatypeValidator.cpp b/src/xercesc/validators/datatype/FloatDatatypeValidator.cpp index 5ad1842da49330bcc588567693f51c68e85a3c63..9370d65b5a048df895b9fd1d391441e4e0b099a1 100644 --- a/src/xercesc/validators/datatype/FloatDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/FloatDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -136,7 +139,7 @@ FloatDatatypeValidator::FloatDatatypeValidator( , MemoryManager* const manager) :AbstractNumericValidator(baseValidator, facets, finalSet, DatatypeValidator::Float, manager) { - init(enums); + init(enums, manager); } FloatDatatypeValidator::~FloatDatatypeValidator() @@ -146,10 +149,11 @@ FloatDatatypeValidator::~FloatDatatypeValidator() // Compare methods // ----------------------------------------------------------------------- int FloatDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { - XMLFloat lObj(lValue, fMemoryManager); - XMLFloat rObj(rValue, fMemoryManager); + XMLFloat lObj(lValue, manager); + XMLFloat rObj(rValue, manager); return compareValues(&lObj, &rObj); } @@ -178,23 +182,6 @@ FloatDatatypeValidator::FloatDatatypeValidator(DatatypeValidator* con //do not invoke init here !!! } -void FloatDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void FloatDatatypeValidator::inheritAdditionalFacet() -{} - -void FloatDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void FloatDatatypeValidator::checkAdditionalFacetConstraintsBase() const -{} - int FloatDatatypeValidator::compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue) { @@ -221,7 +208,7 @@ void FloatDatatypeValidator::setMinExclusive(const XMLCh* const value) fMinExclusive = new (fMemoryManager) XMLFloat(value, fMemoryManager); } -void FloatDatatypeValidator::setEnumeration() +void FloatDatatypeValidator::setEnumeration(MemoryManager* const manager) { // check 4.3.5.c0 must: enumeration values from the value space of base // @@ -241,14 +228,15 @@ void FloatDatatypeValidator::setEnumeration() { for ( i = 0; i < enumLength; i++) { - numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false); + numBase->checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } } catch (XMLException&) { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base - , fStrEnumeration->elementAt(i)); + , fStrEnumeration->elementAt(i) + , manager); } } @@ -258,7 +246,7 @@ void FloatDatatypeValidator::setEnumeration() // for ( i = 0; i < enumLength; i++) { - checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false); + checkContent(fStrEnumeration->elementAt(i), (ValidationContext*)0, false, manager); } fEnumeration = new (fMemoryManager) RefVectorOf<XMLNumber>(enumLength, true, fMemoryManager); @@ -275,7 +263,8 @@ void FloatDatatypeValidator::setEnumeration() // ----------------------------------------------------------------------- void FloatDatatypeValidator::checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { //validate against base validator if any @@ -293,16 +282,17 @@ void FloatDatatypeValidator::checkContent(const XMLCh* const content } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), fMemoryManager); } } - if (getRegex()->matches(content) ==false) + if (getRegex()->matches(content, manager) ==false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -312,7 +302,7 @@ void FloatDatatypeValidator::checkContent(const XMLCh* const content return; try { - XMLFloat theValue(content, fMemoryManager); + XMLFloat theValue(content, manager); XMLFloat *theData = &theValue; if (getEnumeration() != 0) @@ -326,14 +316,14 @@ void FloatDatatypeValidator::checkContent(const XMLCh* const content } if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } - boundsCheck(theData); + boundsCheck(theData, manager); } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage(), manager); } } diff --git a/src/xercesc/validators/datatype/FloatDatatypeValidator.hpp b/src/xercesc/validators/datatype/FloatDatatypeValidator.hpp index 5f4a4c4a529c7f48d3f90a54b4c439f5cb7e1f50..a4f4124143e80f16c6fb8aa5027067a5ba957b7d 100644 --- a/src/xercesc/validators/datatype/FloatDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/FloatDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -142,7 +145,9 @@ public: * @param content2 * @return */ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -181,15 +186,6 @@ protected: // Abstract interface from AbstractNumericFacetValidator // ----------------------------------------------------------------------- - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - virtual int compareValues(const XMLNumber* const lValue , const XMLNumber* const rValue); @@ -201,7 +197,7 @@ protected: virtual void setMinExclusive(const XMLCh* const); - virtual void setEnumeration(); + virtual void setEnumeration(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); // ----------------------------------------------------------------------- // Abstract interface from AbstractNumericValidator @@ -209,7 +205,8 @@ protected: virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.cpp b/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.cpp index f9e47ab80caab4a56349ed64d87e0678e85dc945..850ab2a95696e3651465e53c9d3f99d43aad6005 100644 --- a/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -138,7 +141,7 @@ HexBinaryDatatypeValidator::HexBinaryDatatypeValidator( , MemoryManager* const manager) :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::HexBinary, manager) { - init(enums); + init(enums, manager); } DatatypeValidator* HexBinaryDatatypeValidator::newInstance @@ -155,34 +158,21 @@ DatatypeValidator* HexBinaryDatatypeValidator::newInstance // --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- -void HexBinaryDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void HexBinaryDatatypeValidator::inheritAdditionalFacet() -{} - -void HexBinaryDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void HexBinaryDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} -void HexBinaryDatatypeValidator::checkValueSpace(const XMLCh* const content) +void HexBinaryDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { - if (getLength(content) <= 0) + if (getLength(content, manager) <= 0) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Not_HexBin - , content); + , content + , manager); } } -int HexBinaryDatatypeValidator::getLength(const XMLCh* const content) const +int HexBinaryDatatypeValidator::getLength(const XMLCh* const content + , MemoryManager* const manager) const { return HexBin::getDataLength(content); } diff --git a/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.hpp b/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.hpp index 53c85d9c33b9c5e95193aa951a4ce63104ec9f1d..84eebdb46059f33ea9160e15888d831bc79f5383 100644 --- a/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/HexBinaryDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -133,18 +136,11 @@ public: protected: - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); - virtual int getLength(const XMLCh* const content) const; + virtual int getLength(const XMLCh* const content + , MemoryManager* const manager) const; private: diff --git a/src/xercesc/validators/datatype/IDDatatypeValidator.cpp b/src/xercesc/validators/datatype/IDDatatypeValidator.cpp index 904edb912b575c32030adae34ffe41bec4d08793..e00aed971b6edaa45e5adec8f7d412cc2add27e9 100644 --- a/src/xercesc/validators/datatype/IDDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/IDDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/12 20:31:33 peiyongz * Using ValidationContext to validate() * @@ -123,7 +126,7 @@ IDDatatypeValidator::IDDatatypeValidator( , MemoryManager* const manager) :StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::ID, manager) { - init(enums); + init(enums, manager); } IDDatatypeValidator::~IDDatatypeValidator() @@ -152,13 +155,14 @@ IDDatatypeValidator::IDDatatypeValidator( } void IDDatatypeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { // use StringDatatypeValidator (which in turn, invoke // the baseValidator) to validate content against // facets if any. // - StringDatatypeValidator::validate(content, context); + StringDatatypeValidator::validate(content, context, manager); // storing IDs to the global ID table if (context) @@ -168,16 +172,18 @@ void IDDatatypeValidator::validate(const XMLCh* const content } -void IDDatatypeValidator::checkValueSpace(const XMLCh* const content) +void IDDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // 3.3.8 check must: "NCName" // if ( !XMLString::isValidNCName(content)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Invalid_NCName - , content); + , content + , manager); } } diff --git a/src/xercesc/validators/datatype/IDDatatypeValidator.hpp b/src/xercesc/validators/datatype/IDDatatypeValidator.hpp index 1be6d76f6bafe7700dca9b4e6037d6629546e383..19d1350d53787c2e403c700f6e65b6c9c527ed2b 100644 --- a/src/xercesc/validators/datatype/IDDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/IDDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -156,6 +159,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -194,7 +198,8 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/IDREFDatatypeValidator.cpp b/src/xercesc/validators/datatype/IDREFDatatypeValidator.cpp index 16e035130c7e36b768d7a2d37b5c859e976b5133..d6aeeb34d055d98ccf7c6130d97745c49ee00897 100644 --- a/src/xercesc/validators/datatype/IDREFDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/IDREFDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/12 20:31:33 peiyongz * Using ValidationContext to validate() * @@ -121,7 +124,7 @@ IDREFDatatypeValidator::IDREFDatatypeValidator( , MemoryManager* const manager) :StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::IDREF, manager) { - init(enums); + init(enums, manager); } IDREFDatatypeValidator::~IDREFDatatypeValidator() @@ -150,13 +153,14 @@ IDREFDatatypeValidator::IDREFDatatypeValidator( } void IDREFDatatypeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { // use StringDatatypeValidator (which in turn, invoke // the baseValidator) to validate content against // facets if any. // - StringDatatypeValidator::validate(content, context); + StringDatatypeValidator::validate(content, context, manager); // this is different from java, since we always add, while // in java, it is done as told. REVISIT. @@ -168,16 +172,18 @@ void IDREFDatatypeValidator::validate(const XMLCh* const content } -void IDREFDatatypeValidator::checkValueSpace(const XMLCh* const content) +void IDREFDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // 3.3.9 check must: "NCName" // if ( !XMLString::isValidNCName(content)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Invalid_NCName - , content); + , content + , manager); } } diff --git a/src/xercesc/validators/datatype/IDREFDatatypeValidator.hpp b/src/xercesc/validators/datatype/IDREFDatatypeValidator.hpp index b2c0bf7e8dd8d4f19d2319679dfe64818ccaf6c7..80d6ff039ae5a07a17f024509101ab90b81e9944 100644 --- a/src/xercesc/validators/datatype/IDREFDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/IDREFDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -155,6 +158,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -193,7 +197,8 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/ListDatatypeValidator.cpp b/src/xercesc/validators/datatype/ListDatatypeValidator.cpp index 578dd4ab458524aa90dafc98c45840e80d2ff7a0..8d7629b323292538fb612a57ec340c664ea7b534 100644 --- a/src/xercesc/validators/datatype/ListDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/ListDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.15 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.14 2003/12/10 20:52:27 neilg * fixes for canonical value production; memory management was not implemented correctly * @@ -167,9 +170,9 @@ ListDatatypeValidator::ListDatatypeValidator( // In either case, it shall be not null // if (!baseValidator) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_List_Null_baseValidator); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_List_Null_baseValidator, manager); - init(enums); + init(enums, manager); } ListDatatypeValidator::~ListDatatypeValidator() @@ -187,13 +190,14 @@ DatatypeValidator* ListDatatypeValidator::newInstance } -int ListDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) +int ListDatatypeValidator::compare(const XMLCh* const lValue + , const XMLCh* const rValue + , MemoryManager* const manager) { DatatypeValidator* theItemTypeDTV = getItemTypeDTV(); - BaseRefVectorOf<XMLCh>* lVector = XMLString::tokenizeString(lValue); + BaseRefVectorOf<XMLCh>* lVector = XMLString::tokenizeString(lValue, manager); Janitor<BaseRefVectorOf<XMLCh> > janl(lVector); - BaseRefVectorOf<XMLCh>* rVector = XMLString::tokenizeString(rValue); + BaseRefVectorOf<XMLCh>* rVector = XMLString::tokenizeString(rValue, manager); Janitor<BaseRefVectorOf<XMLCh> > janr(rVector); int lNumberOfTokens = lVector->size(); @@ -207,7 +211,7 @@ int ListDatatypeValidator::compare(const XMLCh* const lValue { //compare each token for ( int i = 0; i < lNumberOfTokens; i++) { - int returnValue = theItemTypeDTV->compare(lVector->elementAt(i), rVector->elementAt(i)); + int returnValue = theItemTypeDTV->compare(lVector->elementAt(i), rVector->elementAt(i), manager); if (returnValue != 0) return returnValue; //REVISIT: does it make sense to return -1 or +1..? } @@ -217,22 +221,24 @@ int ListDatatypeValidator::compare(const XMLCh* const lValue } void ListDatatypeValidator::validate( const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { setContent(content); - BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content); + BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content, manager); Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector); - checkContent(tokenVector, content, context, false); + checkContent(tokenVector, content, context, false, manager); } void ListDatatypeValidator::checkContent( const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { setContent(content); - BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content); + BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content, manager); Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector); - checkContent(tokenVector, content, context, asBase); + checkContent(tokenVector, content, context, asBase, manager); } // @@ -241,16 +247,17 @@ void ListDatatypeValidator::checkContent( const XMLCh* const content void ListDatatypeValidator::checkContent( BaseRefVectorOf<XMLCh>* tokenVector , const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { DatatypeValidator* bv = getBaseValidator(); if (bv->getType() == DatatypeValidator::List) - ((ListDatatypeValidator*)bv)->checkContent(tokenVector, content, context, true); + ((ListDatatypeValidator*)bv)->checkContent(tokenVector, content, context, true, manager); else { // the ultimate itemType DTV for (unsigned int i = 0; i < tokenVector->size(); i++) - bv->validate(tokenVector->elementAt(i), context); + bv->validate(tokenVector->elementAt(i), context, manager); } int thisFacetsDefined = getFacetsDefined(); @@ -266,17 +273,18 @@ void ListDatatypeValidator::checkContent( BaseRefVectorOf<XMLCh>* to } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager); } } //check every item in the list as a whole - if (getRegex()->matches(content) == false) + if (getRegex()->matches(content, manager) == false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -291,40 +299,43 @@ void ListDatatypeValidator::checkContent( BaseRefVectorOf<XMLCh>* to if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) && (tokenNumber > getMaxLength())) { - XMLString::binToText(tokenNumber, value1, BUF_LEN, 10); - XMLString::binToText(getMaxLength(), value2, BUF_LEN, 10); + XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager); + XMLString::binToText(getMaxLength(), value2, BUF_LEN, 10, manager); - ThrowXML3(InvalidDatatypeValueException + ThrowXMLwithMemMgr3(InvalidDatatypeValueException , XMLExcepts::VALUE_GT_maxLen , getContent() , value1 - , value2); + , value2 + , manager); } if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) && (tokenNumber < getMinLength())) { - XMLString::binToText(tokenNumber, value1, BUF_LEN, 10); - XMLString::binToText(getMinLength(), value2, BUF_LEN, 10); + XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager); + XMLString::binToText(getMinLength(), value2, BUF_LEN, 10, manager); - ThrowXML3(InvalidDatatypeValueException + ThrowXMLwithMemMgr3(InvalidDatatypeValueException , XMLExcepts::VALUE_LT_minLen , getContent() , value1 - , value2); + , value2 + , manager); } if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) && (tokenNumber != AbstractStringValidator::getLength())) { - XMLString::binToText(tokenNumber, value1, BUF_LEN, 10); - XMLString::binToText(AbstractStringValidator::getLength(), value2, BUF_LEN, 10); + XMLString::binToText(tokenNumber, value1, BUF_LEN, 10, manager); + XMLString::binToText(AbstractStringValidator::getLength(), value2, BUF_LEN, 10, manager); - ThrowXML3(InvalidDatatypeValueException + ThrowXMLwithMemMgr3(InvalidDatatypeValueException , XMLExcepts::VALUE_NE_Len , getContent() , value1 - , value2); + , value2 + , manager); } if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && @@ -346,22 +357,23 @@ void ListDatatypeValidator::checkContent( BaseRefVectorOf<XMLCh>* to // eg. // tokenVector = "1 2 3.0 4" vs enumeration = "1 2 3 4.0" // - if (valueSpaceCheck(tokenVector, getEnumeration()->elementAt(i))) + if (valueSpaceCheck(tokenVector, getEnumeration()->elementAt(i), manager)) break; } if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, getContent()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, getContent(), manager); } // enumeration } bool ListDatatypeValidator::valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector - , const XMLCh* const enumStr) const + , const XMLCh* const enumStr + , MemoryManager* const manager) const { DatatypeValidator* theItemTypeDTV = getItemTypeDTV(); - BaseRefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(enumStr); + BaseRefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(enumStr, manager); Janitor<BaseRefVectorOf<XMLCh> > janName(enumVector); if (tokenVector->size() != enumVector->size()) @@ -369,7 +381,7 @@ bool ListDatatypeValidator::valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector for ( unsigned int j = 0; j < tokenVector->size(); j++ ) { - if (theItemTypeDTV->compare(tokenVector->elementAt(j), enumVector->elementAt(j)) != 0) + if (theItemTypeDTV->compare(tokenVector->elementAt(j), enumVector->elementAt(j), manager) != 0) return false; } @@ -389,35 +401,21 @@ DatatypeValidator* ListDatatypeValidator::getItemTypeDTV() const // --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- -void ListDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void ListDatatypeValidator::inheritAdditionalFacet() -{} - -void ListDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void ListDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} -void ListDatatypeValidator::checkValueSpace(const XMLCh* const content) +void ListDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) {} -int ListDatatypeValidator::getLength(const XMLCh* const content) const +int ListDatatypeValidator::getLength(const XMLCh* const content + , MemoryManager* const manager) const { - BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content); + BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content, manager); Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector); return tokenVector->size(); } -void ListDatatypeValidator::inspectFacetBase() +void ListDatatypeValidator::inspectFacetBase(MemoryManager* const manager) { // @@ -426,7 +424,7 @@ void ListDatatypeValidator::inspectFacetBase() if (getBaseValidator()->getType() == DatatypeValidator::List) { - AbstractStringValidator::inspectFacetBase(); + AbstractStringValidator::inspectFacetBase(manager); } else { @@ -442,13 +440,13 @@ void ListDatatypeValidator::inspectFacetBase() for ( i = 0; i < enumLength; i++) { // ask the itemType for a complete check - BaseRefVectorOf<XMLCh>* tempList = XMLString::tokenizeString(getEnumeration()->elementAt(i)); + BaseRefVectorOf<XMLCh>* tempList = XMLString::tokenizeString(getEnumeration()->elementAt(i), manager); int tokenNumber = tempList->size(); try { for ( int j = 0; j < tokenNumber; j++) - getBaseValidator()->validate(tempList->elementAt(j), (ValidationContext*)0); + getBaseValidator()->validate(tempList->elementAt(j), (ValidationContext*)0, manager); } catch(const OutOfMemoryException&) { @@ -463,15 +461,16 @@ void ListDatatypeValidator::inspectFacetBase() delete tempList; // enum shall pass this->checkContent() as well. - checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false); + checkContent(getEnumeration()->elementAt(i), (ValidationContext*)0, false, manager); } } catch ( XMLException& ) { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base - , getEnumeration()->elementAt(i)); + , getEnumeration()->elementAt(i) + , manager); } } @@ -505,12 +504,13 @@ const XMLCh* ListDatatypeValidator::getCanonicalRepresentation(const XMLCh* ListDatatypeValidator* temp = (ListDatatypeValidator*) this; temp->setContent(rawData); - BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(rawData); - Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector); - temp->checkContent(tokenVector, rawData, 0, false); - MemoryManager* toUse = memMgr? memMgr : getMemoryManager(); + BaseRefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(rawData, toUse); + Janitor<BaseRefVectorOf<XMLCh> > janName(tokenVector); + temp->checkContent(tokenVector, rawData, 0, false, toUse); + unsigned int retBufSize = 2 * XMLString::stringLen(rawData); + XMLCh* retBuf = (XMLCh*) toUse->allocate(retBufSize * sizeof(XMLCh)); XMLCh* retBufPtr = retBuf; diff --git a/src/xercesc/validators/datatype/ListDatatypeValidator.hpp b/src/xercesc/validators/datatype/ListDatatypeValidator.hpp index e2e6a799fc7fb81ed563c12c71970a878e2c8a28..48c4716b49a0d98c48411c9a34ae6192dc95d654 100644 --- a/src/xercesc/validators/datatype/ListDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/ListDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -186,6 +189,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -203,7 +207,9 @@ public: * @param content2 * @return */ - int compare(const XMLCh* const, const XMLCh* const); + int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -232,29 +238,23 @@ protected: // ctor provided to be used by derived classes: No // - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); - virtual int getLength(const XMLCh* const content) const; + virtual int getLength(const XMLCh* const content + , MemoryManager* const manager) const; // // Overwrite AbstractStringValidator's // - virtual void inspectFacetBase(); + virtual void inspectFacetBase(MemoryManager* const manager); virtual void inheritFacet(); virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); private: @@ -262,10 +262,12 @@ private: , const XMLCh* const content , ValidationContext* const context , bool asBase + , MemoryManager* const manager ); bool valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector - , const XMLCh* const enumStr) const; + , const XMLCh* const enumStr + , MemoryManager* const manager) const; // ----------------------------------------------------------------------- // Getter methods diff --git a/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp b/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp index edd7eb3af3b52bd114636101cdd2a39b21eb8aaf..cfcdd9e3e546c9cae5ca61eee5a53119a5e1593c 100644 --- a/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/MonthDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -120,7 +123,7 @@ MonthDatatypeValidator::MonthDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Month, manager) { - init(enums); + init(enums, manager); } MonthDatatypeValidator::~MonthDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* MonthDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* MonthDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* MonthDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/MonthDatatypeValidator.hpp b/src/xercesc/validators/datatype/MonthDatatypeValidator.hpp index 7549147d15d2ee71eedaf2e1ed47e590110d25bc..941a250b4f5d2fe36306ba708310ed8197bb04e5 100644 --- a/src/xercesc/validators/datatype/MonthDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/MonthDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,7 +138,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp b/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp index 6a46c9a453da6f1bd357846eb07c69581b83ed8d..4bae838fdd3f23aeca9fdb8ccb532f481acac60c 100644 --- a/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/MonthDayDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -120,7 +123,7 @@ MonthDayDatatypeValidator::MonthDayDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::MonthDay, manager) { - init(enums); + init(enums, manager); } MonthDayDatatypeValidator::~MonthDayDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* MonthDayDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* MonthDayDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* MonthDayDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/MonthDayDatatypeValidator.hpp b/src/xercesc/validators/datatype/MonthDayDatatypeValidator.hpp index 324a20a3982b4b39c3ea439a691b6e768b51485b..1852bc13fe38d2409e1ca1ad25a88604e7ddb839 100644 --- a/src/xercesc/validators/datatype/MonthDayDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/MonthDayDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,7 +138,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/datatype/NCNameDatatypeValidator.cpp b/src/xercesc/validators/datatype/NCNameDatatypeValidator.cpp index 75019d7787e8fcc6667406bd91dea683b324952b..03f2336a7b874698e2c8b11e2b25bd65832d1337 100644 --- a/src/xercesc/validators/datatype/NCNameDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/NCNameDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -115,7 +118,7 @@ NCNameDatatypeValidator::NCNameDatatypeValidator( , MemoryManager* const manager) :StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::NCName, manager) { - init(enums); + init(enums, manager); } DatatypeValidator* NCNameDatatypeValidator::newInstance @@ -144,33 +147,37 @@ NCNameDatatypeValidator::NCNameDatatypeValidator( // Compare methods // ----------------------------------------------------------------------- int NCNameDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { return ( XMLString::equals(lValue, rValue)? 0 : -1); } void NCNameDatatypeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { // use StringDatatypeValidator (which in turn, invoke // the baseValidator) to validate content against // facets if any. // - StringDatatypeValidator::validate(content, context); + StringDatatypeValidator::validate(content, context, manager); return; } -void NCNameDatatypeValidator::checkValueSpace(const XMLCh* const content) +void NCNameDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // 3.3.7 check must: "NCName" // if ( !XMLString::isValidNCName(content)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Invalid_NCName - , content); + , content + , manager); } } diff --git a/src/xercesc/validators/datatype/NCNameDatatypeValidator.hpp b/src/xercesc/validators/datatype/NCNameDatatypeValidator.hpp index a01270068a92af06ecaf8cab1ad860cd48fb9e2e..c24660ad997af089352d60b979a6eefa2bbdc68b 100644 --- a/src/xercesc/validators/datatype/NCNameDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/NCNameDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -138,6 +141,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -155,7 +159,8 @@ public: * @param content2 * @return */ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} @@ -190,7 +195,8 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp b/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp index 9bc9d8617c5a8095896ab8685125bb62e269dff6..3548fba87ac266e859f23af2572c53b7980aacf7 100644 --- a/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/10/01 16:32:41 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * @@ -137,7 +140,7 @@ NOTATIONDatatypeValidator::NOTATIONDatatypeValidator( , MemoryManager* const manager) :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::NOTATION, manager) { - init(enums); + init(enums, manager); } DatatypeValidator* NOTATIONDatatypeValidator::newInstance @@ -154,24 +157,9 @@ DatatypeValidator* NOTATIONDatatypeValidator::newInstance // --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- -void NOTATIONDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void NOTATIONDatatypeValidator::inheritAdditionalFacet() -{} - -void NOTATIONDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void NOTATIONDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} -void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content) +void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // NOTATATION: <URI>:<localPart> @@ -183,24 +171,25 @@ void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content) if ((colonPosition == -1) || // no ':' (colonPosition == contentLength - 1) ) // <URI>':' - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_NOTATION_Invalid - , content); + , content + , manager); if (colonPosition > 0) { // Extract URI - XMLCh* uriPart = (XMLCh*) fMemoryManager->allocate + XMLCh* uriPart = (XMLCh*) manager->allocate ( (colonPosition + 1) * sizeof(XMLCh) );//new XMLCh[colonPosition + 1]; - ArrayJanitor<XMLCh> jan1(uriPart, fMemoryManager); - XMLString::subString(uriPart, content, 0, colonPosition); + ArrayJanitor<XMLCh> jan1(uriPart, manager); + XMLString::subString(uriPart, content, 0, colonPosition, manager); try { // no relative uri support here - XMLUri newURI(uriPart, fMemoryManager); + XMLUri newURI(uriPart, manager); } catch(const OutOfMemoryException&) { @@ -208,34 +197,31 @@ void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content) } catch (...) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_NOTATION_Invalid - , content); + , content + , manager); } } // Extract localpart - XMLCh* localPart = (XMLCh*) fMemoryManager->allocate + XMLCh* localPart = (XMLCh*) manager->allocate ( (contentLength - colonPosition) * sizeof(XMLCh) );//new XMLCh[contentLength - colonPosition]; - ArrayJanitor<XMLCh> jan2(localPart, fMemoryManager); - XMLString::subString(localPart, content, colonPosition + 1, contentLength); + ArrayJanitor<XMLCh> jan2(localPart, manager); + XMLString::subString(localPart, content, colonPosition + 1, contentLength, manager); if ( !XMLString::isValidNCName(localPart)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_NOTATION_Invalid - , content); + , content + , manager); } } -int NOTATIONDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - /*** * Support for Serialization/De-serialization ***/ diff --git a/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.hpp b/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.hpp index a846682040bf1bdf2066f1e37af3a8cb2b05e9fb..33ead1c1bf1cd8a44344b636a5aef64d5624ad67 100644 --- a/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/NOTATIONDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -144,18 +147,8 @@ public: protected: - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/NameDatatypeValidator.cpp b/src/xercesc/validators/datatype/NameDatatypeValidator.cpp index 090dfa6023724b47a4ef3207073e765468727f7d..5e432fda92596b3fd04f762441e8384b1e95eb3d 100644 --- a/src/xercesc/validators/datatype/NameDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/NameDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -118,7 +121,7 @@ NameDatatypeValidator::NameDatatypeValidator( , MemoryManager* const manager) :StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Name, manager) { - init(enums); + init(enums, manager); } DatatypeValidator* NameDatatypeValidator::newInstance @@ -146,33 +149,37 @@ NameDatatypeValidator::NameDatatypeValidator( // Compare methods // ----------------------------------------------------------------------- int NameDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { return ( XMLString::equals(lValue, rValue)? 0 : -1); } void NameDatatypeValidator::validate(const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { // use StringDatatypeValidator (which in turn, invoke // the baseValidator) to validate content against // facets if any. // - StringDatatypeValidator::validate(content, context); + StringDatatypeValidator::validate(content, context, manager); return; } -void NameDatatypeValidator::checkValueSpace(const XMLCh* const content) +void NameDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // 3.3.6 check must: "Name" // if ( !XMLString::isValidName(content)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_Invalid_Name - , content); + , content + , manager); } } diff --git a/src/xercesc/validators/datatype/NameDatatypeValidator.hpp b/src/xercesc/validators/datatype/NameDatatypeValidator.hpp index 27b8dee1f7e3c1c1de5da93b67a849aab4ad7214..c54c6c2264d5f0ac53b7cfef7a47db921333662f 100644 --- a/src/xercesc/validators/datatype/NameDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/NameDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/11/12 20:32:03 peiyongz * Statless Grammar: ValidationContext * @@ -137,6 +140,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -154,7 +158,8 @@ public: * @param content2 * @return */ - virtual int compare(const XMLCh* const, const XMLCh* const); + virtual int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} @@ -189,7 +194,8 @@ protected: , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/QNameDatatypeValidator.cpp b/src/xercesc/validators/datatype/QNameDatatypeValidator.cpp index ad552c660e7658290b57feba5d3fd0285596f056..ceefe8932d60618e54a06e67c9d7855ed5381695 100644 --- a/src/xercesc/validators/datatype/QNameDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/QNameDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -126,7 +129,7 @@ QNameDatatypeValidator::QNameDatatypeValidator( , MemoryManager* const manager) :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::QName, manager) { - init(enums); + init(enums, manager); } DatatypeValidator* QNameDatatypeValidator::newInstance @@ -143,41 +146,22 @@ DatatypeValidator* QNameDatatypeValidator::newInstance // --------------------------------------------------------------------------- // Utilities // --------------------------------------------------------------------------- -void QNameDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void QNameDatatypeValidator::inheritAdditionalFacet() -{} - -void QNameDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void QNameDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} -void QNameDatatypeValidator::checkValueSpace(const XMLCh* const content) +void QNameDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) { // // check 3.2.18.c0 must: QName // if ( !XMLString::isValidQName(content)) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_QName_Invalid - , content); + , content + , manager); } } -int QNameDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - /*** * Support for Serialization/De-serialization ***/ diff --git a/src/xercesc/validators/datatype/QNameDatatypeValidator.hpp b/src/xercesc/validators/datatype/QNameDatatypeValidator.hpp index de32c377aa1129a53363bfc539088ec273e74b93..dcf677b17b1fe9469c602afcb22a653fe0dd857e 100644 --- a/src/xercesc/validators/datatype/QNameDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/QNameDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/09/30 21:31:30 peiyongz * Implementation of Serialization/Deserialization * @@ -143,18 +146,8 @@ public: protected: - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); private: diff --git a/src/xercesc/validators/datatype/StringDatatypeValidator.cpp b/src/xercesc/validators/datatype/StringDatatypeValidator.cpp index 5d47b91737dfe719b26d524a93e626f9444d8f09..6f12a33504028cf9e88b007894a312c98256af67 100644 --- a/src/xercesc/validators/datatype/StringDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/StringDatatypeValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.10 2003/11/24 05:11:06 neilg * remove unused statics * @@ -165,7 +168,7 @@ StringDatatypeValidator::StringDatatypeValidator( :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::String, manager) { setWhiteSpace(DatatypeValidator::PRESERVE); - init(enums); + init(enums, manager); } StringDatatypeValidator::~StringDatatypeValidator() @@ -198,7 +201,8 @@ StringDatatypeValidator::StringDatatypeValidator( // Utilities // --------------------------------------------------------------------------- void StringDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) + , const XMLCh* const value + , MemoryManager* const manager) { if (XMLString::equals(key, SchemaSymbols::fgELT_WHITESPACE)) { @@ -210,16 +214,17 @@ void StringDatatypeValidator::assignAdditionalFacet(const XMLCh* const key else if (XMLString::equals(value, SchemaSymbols::fgWS_COLLAPSE)) setWhiteSpace(DatatypeValidator::COLLAPSE); else - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_WS, value); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_WS, value, manager); //("whiteSpace value '" + ws + "' must be one of 'preserve', 'replace', 'collapse'."); setFacetsDefined(DatatypeValidator::FACET_WHITESPACE); } else { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag - , key); + , key + , manager); } } @@ -239,7 +244,7 @@ void StringDatatypeValidator::inheritAdditionalFacet() } } -void StringDatatypeValidator::checkAdditionalFacetConstraints() const +void StringDatatypeValidator::checkAdditionalFacetConstraints(MemoryManager* const manager) const { StringDatatypeValidator *pBaseValidator = (StringDatatypeValidator*) getBaseValidator(); @@ -257,25 +262,27 @@ void StringDatatypeValidator::checkAdditionalFacetConstraints() const if ((baseWSFacet == DatatypeValidator::COLLAPSE) && ((thisWSFacet == DatatypeValidator::PRESERVE) || (thisWSFacet == DatatypeValidator::REPLACE))) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_collapse); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_collapse, manager); if ((baseWSFacet == DatatypeValidator::REPLACE) && (thisWSFacet == DatatypeValidator::PRESERVE)) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_replace); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_replace, manager); if (((pBaseValidator->getFixed() & DatatypeValidator::FACET_WHITESPACE) !=0) && ( thisWSFacet != baseWSFacet)) { - ThrowXML2(InvalidDatatypeFacetException + ThrowXMLwithMemMgr2(InvalidDatatypeFacetException , XMLExcepts::FACET_whitespace_base_fixed , getWSstring(thisWSFacet) - , getWSstring(baseWSFacet)); + , getWSstring(baseWSFacet) + , manager); } } } -void StringDatatypeValidator::checkAdditionalFacet(const XMLCh* const content) const +void StringDatatypeValidator::checkAdditionalFacet(const XMLCh* const content + , MemoryManager* const manager) const { // // check WhiteSpace @@ -285,25 +292,21 @@ void StringDatatypeValidator::checkAdditionalFacet(const XMLCh* const content) c if ( getWSFacet() == DatatypeValidator::REPLACE ) { if (!XMLString::isWSReplaced(content)) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_replaced, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_replaced, content, manager); } else if ( getWSFacet() == DatatypeValidator::COLLAPSE ) { if (!XMLString::isWSCollapsed(content)) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_collapsed, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_collapsed, content, manager); } } } -void StringDatatypeValidator::checkValueSpace(const XMLCh* const content) +void StringDatatypeValidator::checkValueSpace(const XMLCh* const content + , MemoryManager* const manager) {} -int StringDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - /*** * Support for Serialization/De-serialization ***/ diff --git a/src/xercesc/validators/datatype/StringDatatypeValidator.hpp b/src/xercesc/validators/datatype/StringDatatypeValidator.hpp index 975391b76b7187e4c4f90bba189e9ddf43bb67ea..972588600b25bc8263a4204ed5c2959086160518 100644 --- a/src/xercesc/validators/datatype/StringDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/StringDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/01 01:09:35 knoaman * Refactoring of some code to improve performance. * @@ -157,17 +160,19 @@ protected: ); virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); + , const XMLCh* const value + , MemoryManager* const manager); virtual void inheritAdditionalFacet(); - virtual void checkAdditionalFacetConstraints() const; + virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const; - virtual void checkAdditionalFacet(const XMLCh* const content) const; + virtual void checkAdditionalFacet(const XMLCh* const content + , MemoryManager* const manager) const; - virtual void checkValueSpace(const XMLCh* const content); + virtual void checkValueSpace(const XMLCh* const content + , MemoryManager* const manager); - virtual int getLength(const XMLCh* const content) const; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp b/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp index a837e65bdcb29a531227f2632a4b1098728cdada..3e50c46a0adfcc1aebf87bb3900e20395e2db3bb 100644 --- a/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/TimeDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.12 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/12/11 21:40:24 peiyongz * support for Canonical Representation for Datatype * @@ -126,7 +129,7 @@ TimeDatatypeValidator::TimeDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Time, manager) { - init(enums); + init(enums, manager); } TimeDatatypeValidator::~TimeDatatypeValidator() @@ -146,9 +149,9 @@ DatatypeValidator* TimeDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* TimeDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* TimeDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { @@ -178,9 +181,9 @@ const XMLCh* TimeDatatypeValidator::getCanonicalRepresentation(const XMLCh* // we need the checkContent to build the fDateTime // to get the canonical representation TimeDatatypeValidator* temp = (TimeDatatypeValidator*) this; - temp->checkContent(rawData, 0, false); - MemoryManager* toUse = memMgr? memMgr : fMemoryManager; + temp->checkContent(rawData, 0, false, toUse); + //Have the fDateTime to do the job return fDateTime->getTimeCanonicalRepresentation(toUse); } diff --git a/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp b/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp index 3c79d89733f7facb04fb8855a52e5a91f6e95f9d..855b40a354c5719f3199000136d8fed6058fdda7 100644 --- a/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/TimeDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.7 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -146,7 +149,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp index e1cc8424ad8230b32b94137a92e8e71d0ccc928b..644b6a330a48b60fa02518449e41810376e96901 100644 --- a/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.21 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.20 2003/12/10 20:55:18 neilg * fixes for canonical value production; memory management was not implemented correctly * @@ -180,8 +183,8 @@ UnionDatatypeValidator::UnionDatatypeValidator( { if ( !memberTypeValidators ) { - ThrowXML(InvalidDatatypeFacetException - , XMLExcepts::FACET_Union_Null_memberTypeValidators); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException + , XMLExcepts::FACET_Union_Null_memberTypeValidators, manager); } // no pattern, no enumeration @@ -211,21 +214,22 @@ UnionDatatypeValidator::UnionDatatypeValidator( // if (!baseValidator) { - ThrowXML(InvalidDatatypeFacetException - , XMLExcepts::FACET_Union_Null_baseValidator); + ThrowXMLwithMemMgr(InvalidDatatypeFacetException + , XMLExcepts::FACET_Union_Null_baseValidator, manager); } if (baseValidator->getType() != DatatypeValidator::Union) { - XMLString::binToText(baseValidator->getType(), value1, BUF_LEN, 10); - ThrowXML1(InvalidDatatypeFacetException + XMLString::binToText(baseValidator->getType(), value1, BUF_LEN, 10, manager); + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Union_invalid_baseValidatorType - , value1); + , value1 + , manager); } try { - init(baseValidator, facets, enums); + init(baseValidator, facets, enums, manager); } catch(const OutOfMemoryException&) { @@ -240,7 +244,8 @@ UnionDatatypeValidator::UnionDatatypeValidator( void UnionDatatypeValidator::init(DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets - , RefArrayVectorOf<XMLCh>* const enums) + , RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager) { if (enums) setEnumeration(enums, false); @@ -250,7 +255,7 @@ void UnionDatatypeValidator::init(DatatypeValidator* const baseValida { XMLCh* key; XMLCh* value; - RefHashTableOfEnumerator<KVStringPair> e(facets); + RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager); while (e.hasMoreElements()) { @@ -267,9 +272,10 @@ void UnionDatatypeValidator::init(DatatypeValidator* const baseValida } else { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_Invalid_Tag - , key); + , key + , manager); } }//while @@ -297,16 +303,17 @@ void UnionDatatypeValidator::init(DatatypeValidator* const baseValida // since there are no other facets for Union, parent // checking is good enough. // - baseValidator->validate(getEnumeration()->elementAt(i), (ValidationContext*)0); + baseValidator->validate(getEnumeration()->elementAt(i), (ValidationContext*)0, manager); } } catch ( XMLException& ) { - ThrowXML1(InvalidDatatypeFacetException + ThrowXMLwithMemMgr1(InvalidDatatypeFacetException , XMLExcepts::FACET_enum_base - , getEnumeration()->elementAt(i)); + , getEnumeration()->elementAt(i) + , manager); } } @@ -343,12 +350,13 @@ void UnionDatatypeValidator::init(DatatypeValidator* const baseValida // void UnionDatatypeValidator::checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase) + , bool asBase + , MemoryManager* const manager) { DatatypeValidator* bv = getBaseValidator(); if (bv) - ((UnionDatatypeValidator*)bv)->checkContent(content, context, true); + ((UnionDatatypeValidator*)bv)->checkContent(content, context, true, manager); else { // 3) native union type // check content against each member type validator in Union @@ -362,7 +370,7 @@ void UnionDatatypeValidator::checkContent(const XMLCh* const content try { - fMemberTypeValidators->elementAt(i)->validate(content, context); + fMemberTypeValidators->elementAt(i)->validate(content, context, manager); memTypeValid = true; //set the validator of the type actually used to validate the content @@ -380,9 +388,10 @@ void UnionDatatypeValidator::checkContent(const XMLCh* const content if ( !memTypeValid ) { - ThrowXML1(InvalidDatatypeValueException + ThrowXMLwithMemMgr1(InvalidDatatypeValueException , XMLExcepts::VALUE_no_match_memberType - , content); + , content + , manager); //( "Content '"+content+"' does not match any union types" ); } } @@ -398,16 +407,17 @@ void UnionDatatypeValidator::checkContent(const XMLCh* const content } catch (XMLException &e) { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage(), manager); } } - if (getRegex()->matches(content) == false) + if (getRegex()->matches(content, manager) == false) { - ThrowXML2(InvalidDatatypeValueException + ThrowXMLwithMemMgr2(InvalidDatatypeValueException , XMLExcepts::VALUE_NotMatch_Pattern , content - , getPattern()); + , getPattern() + , manager); } } @@ -434,7 +444,7 @@ void UnionDatatypeValidator::checkContent(const XMLCh* const content { try { - if (memberDTV->elementAt(memberIndex)->compare(content, tmpEnum->elementAt(enumIndex)) == 0) + if (memberDTV->elementAt(memberIndex)->compare(content, tmpEnum->elementAt(enumIndex), manager) == 0) return; } catch (XMLException&) @@ -444,7 +454,7 @@ void UnionDatatypeValidator::checkContent(const XMLCh* const content } // for enumIndex } // for memberIndex - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); + ThrowXMLwithMemMgr1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content, manager); } // enumeration @@ -454,14 +464,15 @@ void UnionDatatypeValidator::checkContent(const XMLCh* const content // // int UnionDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) + , const XMLCh* const rValue + , MemoryManager* const manager) { RefVectorOf<DatatypeValidator>* memberDTV = getMemberTypeValidators(); unsigned int memberTypeNumber = memberDTV->size(); for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex) { - if (memberDTV->elementAt(memberIndex)->compare(lValue, rValue) ==0) + if (memberDTV->elementAt(memberIndex)->compare(lValue, rValue, manager) ==0) return 0; } @@ -486,7 +497,7 @@ const XMLCh* UnionDatatypeValidator::getCanonicalRepresentation(const XMLCh* { UnionDatatypeValidator* temp = (UnionDatatypeValidator*) this; - temp->checkContent(rawData, 0, false); + temp->checkContent(rawData, 0, false, memMgr); //get the native unionDv UnionDatatypeValidator* bdv = (UnionDatatypeValidator*) temp->getBaseValidator(); @@ -503,7 +514,7 @@ const XMLCh* UnionDatatypeValidator::getCanonicalRepresentation(const XMLCh* { try { - fMemberTypeValidators->elementAt(i)->validate(rawData, 0); + fMemberTypeValidators->elementAt(i)->validate(rawData, 0, toUse); return fMemberTypeValidators->elementAt(i)->getCanonicalRepresentation(rawData, toUse); } catch (XMLException&) diff --git a/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp b/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp index a9aa264f62f4924ba5d3d836ca3c945502e05df9..8afe91f37f391d660009a7ca470c0aa8530b7ca1 100644 --- a/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.15 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.14 2003/11/28 18:53:07 peiyongz * Support for getCanonicalRepresentation * @@ -223,6 +226,7 @@ public: ( const XMLCh* const content , ValidationContext* const context = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -251,7 +255,9 @@ public: * @param content2 * @return */ - int compare(const XMLCh* const, const XMLCh* const); + int compare(const XMLCh* const, const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); //@} @@ -310,11 +316,13 @@ private: virtual void checkContent(const XMLCh* const content , ValidationContext* const context - , bool asBase); + , bool asBase + , MemoryManager* const manager); void init(DatatypeValidator* const baseValidator , RefHashTableOf<KVStringPair>* const facets - , RefArrayVectorOf<XMLCh>* const enums); + , RefArrayVectorOf<XMLCh>* const enums + , MemoryManager* const manager); void cleanUp(); @@ -356,9 +364,10 @@ inline DatatypeValidator* UnionDatatypeValidator::newInstance } inline void UnionDatatypeValidator::validate( const XMLCh* const content - , ValidationContext* const context) + , ValidationContext* const context + , MemoryManager* const manager) { - checkContent(content, context, false); + checkContent(content, context, false, manager); } inline void UnionDatatypeValidator::cleanUp() diff --git a/src/xercesc/validators/datatype/YearDatatypeValidator.cpp b/src/xercesc/validators/datatype/YearDatatypeValidator.cpp index 6cdf9e22d4dcbe1a2d441db3f96a6b977c8bc819..eb45bd420db9ca7681b1edbdca8f4a14f131c73f 100644 --- a/src/xercesc/validators/datatype/YearDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/YearDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -120,7 +123,7 @@ YearDatatypeValidator::YearDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Year, manager) { - init(enums); + init(enums, manager); } YearDatatypeValidator::~YearDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* YearDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* YearDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* YearDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/YearDatatypeValidator.hpp b/src/xercesc/validators/datatype/YearDatatypeValidator.hpp index 4e11d9566ca9cbc6d9d8460bbfe7a722054e5400..e3862085357d3d498ce35c635faf56fe4da70490 100644 --- a/src/xercesc/validators/datatype/YearDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/YearDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,8 +138,9 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); - virtual void parse(XMLDateTime* const);}; + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); + virtual void parse(XMLDateTime* const); +}; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp b/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp index 6cb419f813a9e852faa192b7fe371f5272cccac2..9e1ade8495e7f89805c0b109ede636508404caae 100644 --- a/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp +++ b/src/xercesc/validators/datatype/YearMonthDatatypeValidator.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/11/06 15:30:07 neilg * first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse. * @@ -120,7 +123,7 @@ YearMonthDatatypeValidator::YearMonthDatatypeValidator( , MemoryManager* const manager) :DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::YearMonth, manager) { - init(enums); + init(enums, manager); } YearMonthDatatypeValidator::~YearMonthDatatypeValidator() @@ -140,9 +143,9 @@ DatatypeValidator* YearMonthDatatypeValidator::newInstance // // caller need to release the date created here // -XMLDateTime* YearMonthDatatypeValidator::parse(const XMLCh* const content) +XMLDateTime* YearMonthDatatypeValidator::parse(const XMLCh* const content, MemoryManager* const manager) { - XMLDateTime *pRetDate = new (fMemoryManager) XMLDateTime(content, fMemoryManager); + XMLDateTime *pRetDate = new (manager) XMLDateTime(content, manager); try { diff --git a/src/xercesc/validators/datatype/YearMonthDatatypeValidator.hpp b/src/xercesc/validators/datatype/YearMonthDatatypeValidator.hpp index 8e7fb60d7f0515f6a7c32c7f1483c22a4c5ce653..9de083231b2d6dfed02581b81efb086ae469c7cc 100644 --- a/src/xercesc/validators/datatype/YearMonthDatatypeValidator.hpp +++ b/src/xercesc/validators/datatype/YearMonthDatatypeValidator.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/12/17 00:18:39 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/10/02 19:21:06 peiyongz * Implementation of Serialization/Deserialization * @@ -135,7 +138,7 @@ protected: // ----------------------------------------------------------------------- // implementation of (DateTimeValidator's) virtual interface // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); + virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager); virtual void parse(XMLDateTime* const); }; diff --git a/src/xercesc/validators/schema/ComplexTypeInfo.cpp b/src/xercesc/validators/schema/ComplexTypeInfo.cpp index 355ff9db48dcc9cee04d7ad68e328d1dc7102605..c96cb94af8e75755c68f067a3dd3bc692a9de2b8 100644 --- a/src/xercesc/validators/schema/ComplexTypeInfo.cpp +++ b/src/xercesc/validators/schema/ComplexTypeInfo.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.22 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.21 2003/12/16 17:18:50 peiyongz * don't expand ContextSpecNode when deserilized * @@ -418,7 +421,7 @@ bool ComplexTypeInfo::resetDefs() { // This lets the scanner use them to track which has been provided and // which have not. // - RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs); + RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs, false, fMemoryManager); while (enumDefs.hasMoreElements()) enumDefs.nextElement().setProvided(false); @@ -549,7 +552,7 @@ XMLContentModel* ComplexTypeInfo::buildContentModel(ContentSpecNode* const aSpec } else { - ThrowXML(RuntimeException, XMLExcepts::CM_MustBeMixedOrChildren); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_MustBeMixedOrChildren, fMemoryManager); } return cmRet; @@ -561,7 +564,7 @@ XMLContentModel* ComplexTypeInfo::buildContentModel(ContentSpecNode* const aSpec XMLContentModel* ComplexTypeInfo::createChildModel(ContentSpecNode* specNode, const bool isMixed) { if(!specNode) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); ContentSpecNode::NodeTypes specType = specNode->getType(); // @@ -570,7 +573,7 @@ XMLContentModel* ComplexTypeInfo::createChildModel(ContentSpecNode* specNode, co // if (specNode->getElement()) { if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_NoPCDATAHere, fMemoryManager); } // @@ -661,7 +664,7 @@ XMLContentModel* ComplexTypeInfo::createChildModel(ContentSpecNode* specNode, co else { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager); } // Its not any simple type of content, so create a DFA based content model diff --git a/src/xercesc/validators/schema/ComplexTypeInfo.hpp b/src/xercesc/validators/schema/ComplexTypeInfo.hpp index 57db987a4f5e36744a43500d8a43cc00a2996b57..3132f70ea8ed3419ff0172ff95d8422405844e14 100644 --- a/src/xercesc/validators/schema/ComplexTypeInfo.hpp +++ b/src/xercesc/validators/schema/ComplexTypeInfo.hpp @@ -413,7 +413,7 @@ inline const XMLCh* ComplexTypeInfo::getTypeLocalName() const ( (length - index + 1) * sizeof(XMLCh) ); //new XMLCh[length - index + 1]; - XMLString::subString(tName, fTypeName, index + 1, length); + XMLString::subString(tName, fTypeName, index + 1, length, fMemoryManager); ((ComplexTypeInfo *)this)->fTypeLocalName = tName; } @@ -428,7 +428,7 @@ inline const XMLCh* ComplexTypeInfo::getTypeUri() const ( (index + 1) * sizeof(XMLCh) ); //new XMLCh[index + 1]; - XMLString::subString(uri, fTypeName, 0, index); + XMLString::subString(uri, fTypeName, 0, index, fMemoryManager); ((ComplexTypeInfo *)this)->fTypeUri = uri; } @@ -576,7 +576,7 @@ inline bool ComplexTypeInfo::contains(const XMLCh* const attName) { return false; } - RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs); + RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs, false, fMemoryManager); while (enumDefs.hasMoreElements()) { diff --git a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp index bfc27d19bf2e028e28a7eae66a4b7ed3c0380f50..8fd7eafe5cd8d01462a2e11e08ecfd93e6ac55ef 100644 --- a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp +++ b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.17 2003/12/11 19:26:27 knoaman * Store non schema attributes from parent in XSAnnotation * @@ -439,7 +442,7 @@ GeneralAttributeCheck::checkAttributes(const DOMElement* const elem, attName = attribute->getLocalName(); try { - attNameId= fAttMap->get(attName); + attNameId= fAttMap->get(attName, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -556,7 +559,7 @@ void GeneralAttributeCheck::validate(const DOMElement* const elem, if (dv) { try { - dv->validate(attValue, fValidationContext); + dv->validate(attValue, fValidationContext, fMemoryManager); } catch(const XMLException& excep) { schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); diff --git a/src/xercesc/validators/schema/GeneralAttributeCheck.hpp b/src/xercesc/validators/schema/GeneralAttributeCheck.hpp index 41f8a25982038eb29a9123756b3ae3bd83d94b29..71f9a8b8f8027ce11b7bcee4eb1afe2f16f589fb 100644 --- a/src/xercesc/validators/schema/GeneralAttributeCheck.hpp +++ b/src/xercesc/validators/schema/GeneralAttributeCheck.hpp @@ -224,7 +224,7 @@ public: // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- - unsigned short getFacetId(const XMLCh* const facetName); + unsigned short getFacetId(const XMLCh* const facetName, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); // ----------------------------------------------------------------------- // Setter methods @@ -299,9 +299,9 @@ private: // GeneralAttributeCheck: Getter methods // --------------------------------------------------------------------------- inline unsigned short -GeneralAttributeCheck::getFacetId(const XMLCh* const facetName) { +GeneralAttributeCheck::getFacetId(const XMLCh* const facetName, MemoryManager* const manager) { - return fFacetsMap->get(facetName); + return fFacetsMap->get(facetName, manager); } // --------------------------------------------------------------------------- diff --git a/src/xercesc/validators/schema/NamespaceScope.cpp b/src/xercesc/validators/schema/NamespaceScope.cpp index b2c30bf790d700cfbb81d9e8ee97d09d4b36e49d..235e754509f491cc81c6654f0245dccb990b3012 100644 --- a/src/xercesc/validators/schema/NamespaceScope.cpp +++ b/src/xercesc/validators/schema/NamespaceScope.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.5 2003/05/18 14:02:07 knoaman * Memory manager implementation: pass per instance manager. * @@ -162,7 +165,7 @@ unsigned int NamespaceScope::increaseDepth() unsigned int NamespaceScope::decreaseDepth() { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow, fMemoryManager); fStackTop--; @@ -177,7 +180,7 @@ void NamespaceScope::addPrefix(const XMLCh* const prefixToAdd, const unsigned int uriId) { if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); + ThrowXMLwithMemMgr(EmptyStackException, XMLExcepts::ElemStack_EmptyStack, fMemoryManager); // Get a convenience pointer to the stack top row StackElem* curRow = fStack[fStackTop - 1]; diff --git a/src/xercesc/validators/schema/SchemaAttDefList.cpp b/src/xercesc/validators/schema/SchemaAttDefList.cpp index c1773abeeae17d67b97872378ab422fe11ea3146..170e27f9534f012e6c9749d8bdc1463aacaa7567 100644 --- a/src/xercesc/validators/schema/SchemaAttDefList.cpp +++ b/src/xercesc/validators/schema/SchemaAttDefList.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/11/13 23:20:47 peiyongz * initSize * @@ -110,7 +113,7 @@ SchemaAttDefList::SchemaAttDefList(RefHash2KeysTableOf<SchemaAttDef>* const list ,fCount(0) ,fSize(0) { - fEnum = new (getMemoryManager()) RefHash2KeysTableOfEnumerator<SchemaAttDef>(listToUse); + fEnum = new (getMemoryManager()) RefHash2KeysTableOfEnumerator<SchemaAttDef>(listToUse, false, getMemoryManager()); fArray = (SchemaAttDef **)((getMemoryManager())->allocate( sizeof(SchemaAttDef*) << 1)); fSize = 2; } @@ -158,7 +161,7 @@ XMLAttDef* SchemaAttDefList::findAttDef( const XMLCh* const attURI , const XMLCh* const attName) { //need numeric URI id to locate the attribute, that's how it was stored - ThrowXML(RuntimeException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_InvalidId, getMemoryManager()); return 0; } @@ -168,7 +171,7 @@ SchemaAttDefList::findAttDef( const XMLCh* const attURI , const XMLCh* const attName) const { //need numeric URI id to locate the attribute, that's how it was stored - ThrowXML(RuntimeException, XMLExcepts::Pool_InvalidId); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_InvalidId, getMemoryManager()); return 0; } @@ -198,7 +201,7 @@ unsigned int SchemaAttDefList::getAttDefCount() const XMLAttDef &SchemaAttDefList::getAttDef(unsigned int index) { if(index >= fCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager()); return *(fArray[index]); } @@ -208,7 +211,7 @@ XMLAttDef &SchemaAttDefList::getAttDef(unsigned int index) const XMLAttDef &SchemaAttDefList::getAttDef(unsigned int index) const { if(index >= fCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex); + ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager()); return *(fArray[index]); } @@ -248,7 +251,7 @@ void SchemaAttDefList::serialize(XSerializeEngine& serEng) serEng >> fSize; if (!fEnum && fList) { - fEnum = new (getMemoryManager()) RefHash2KeysTableOfEnumerator<SchemaAttDef>(fList); + fEnum = new (getMemoryManager()) RefHash2KeysTableOfEnumerator<SchemaAttDef>(fList, false, getMemoryManager()); } if(fSize) { diff --git a/src/xercesc/validators/schema/SchemaElementDecl.cpp b/src/xercesc/validators/schema/SchemaElementDecl.cpp index f717c1dafa6cb559babf51554d33c3181bbc832b..134086190f8af32aaae189610fea76411a2b9df1 100644 --- a/src/xercesc/validators/schema/SchemaElementDecl.cpp +++ b/src/xercesc/validators/schema/SchemaElementDecl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.17 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.16 2003/12/12 18:36:37 peiyongz * getObjectType() * @@ -330,7 +333,7 @@ XMLAttDefList& SchemaElementDecl::getAttDefList() const { if (!fComplexTypeInfo) { - ThrowXML(RuntimeException, XMLExcepts::DV_InvalidOperation); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::DV_InvalidOperation, getMemoryManager()); } return fComplexTypeInfo->getAttDefList(); diff --git a/src/xercesc/validators/schema/SchemaGrammar.hpp b/src/xercesc/validators/schema/SchemaGrammar.hpp index 95bd487b01d2a87f558666404bd935b1873ea4fd..92f508b073a3440a7e3d6b3d52d39d252b2aec26 100644 --- a/src/xercesc/validators/schema/SchemaGrammar.hpp +++ b/src/xercesc/validators/schema/SchemaGrammar.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.13 2003/11/14 22:35:09 neilg * changes in support of second phase of XSModel implementation; thanks to David Cargill * @@ -451,13 +454,13 @@ private: inline RefHash3KeysIdPoolEnumerator<SchemaElementDecl> SchemaGrammar::getElemEnumerator() const { - return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool); + return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool, false, fMemoryManager); } inline NameIdPoolEnumerator<XMLNotationDecl> SchemaGrammar::getNotationEnumerator() const { - return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool); + return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager); } inline RefHashTableOf<XMLAttDef>* SchemaGrammar::getAttributeDeclRegistry() const { diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp index d9dae74f1b13d337b48348217f7f7bf8b6db3108..34be1d77d1f01860ab7553705a2fa34d7dd3794a 100644 --- a/src/xercesc/validators/schema/SchemaValidator.cpp +++ b/src/xercesc/validators/schema/SchemaValidator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.48 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.47 2003/12/03 20:00:27 neilg * PSVI fix: cannot allow validator to reset its element content buffer before exposing it to the application * @@ -356,7 +359,7 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl // the element decl in our own way of looking at them. // if (!elemDecl) - ThrowXML(RuntimeException, XMLExcepts::Val_InvalidElemId); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_InvalidElemId, fMemoryManager); // // Get the content spec type of this element. This will tell us what @@ -493,7 +496,7 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl // if the flag is FIXED, then this value must be same as default value if ((((SchemaElementDecl*)elemDecl)->getMiscFlags() & SchemaSymbols::XSD_FIXED) != 0) { - if (fCurrentDatatypeValidator->compare(value, elemDefaultValue) != 0 ) + if (fCurrentDatatypeValidator->compare(value, elemDefaultValue, fMemoryManager) != 0 ) { emitError(XMLValid::FixedDifferentFromActual, elemDecl->getFullName()); fErrorOccurred = true; @@ -513,7 +516,7 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl { try { - fCurrentDatatypeValidator->validate(value, getScanner()->getValidationContext()); + fCurrentDatatypeValidator->validate(value, getScanner()->getValidationContext(), fMemoryManager); } catch (XMLException& idve) { @@ -541,7 +544,7 @@ int SchemaValidator::checkContent (XMLElementDecl* const elemDecl } else { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMType, fMemoryManager); } // must rely on scanner to clear fDatatypeBuffer @@ -672,11 +675,13 @@ void SchemaValidator::validateAttrValue (const XMLAttDef* attDef notationBuf.append(&attrValue[colonPos + 1]); attDefDV->validate(notationBuf.getRawBuffer() - , context); + , context + , fMemoryManager); } else { attDefDV->validate(attrValue - , context); + , context + , fMemoryManager); } } @@ -1084,7 +1089,7 @@ void SchemaValidator::preContentValidation(bool reuseGrammar, // We need to verify that all of its possible values // (in the enum list) refer to valid notations. // - XMLCh* list = XMLString::replicate(curAttDef.getEnumeration()); + XMLCh* list = XMLString::replicate(curAttDef.getEnumeration(), fMemoryManager); ArrayJanitor<XMLCh> janList(list); // @@ -1147,7 +1152,7 @@ void SchemaValidator::preContentValidation(bool reuseGrammar, if (getScanner()->getValidationSchemaFullChecking()) { RefHashTableOf<ComplexTypeInfo>* complexTypeRegistry = sGrammar.getComplexTypeRegistry(); - RefHashTableOfEnumerator<ComplexTypeInfo> complexTypeEnum(complexTypeRegistry); + RefHashTableOfEnumerator<ComplexTypeInfo> complexTypeEnum(complexTypeRegistry, false, fMemoryManager); while (complexTypeEnum.hasMoreElements()) { ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement(); @@ -1157,7 +1162,7 @@ void SchemaValidator::preContentValidation(bool reuseGrammar, } RefHashTableOf<XercesGroupInfo>* groupInfoRegistry = sGrammar.getGroupInfoRegistry(); - RefHashTableOfEnumerator<XercesGroupInfo> groupEnum(groupInfoRegistry); + RefHashTableOfEnumerator<XercesGroupInfo> groupEnum(groupInfoRegistry, false, fMemoryManager); while (groupEnum.hasMoreElements()) { @@ -1369,7 +1374,7 @@ void SchemaValidator::checkParticleDerivationOk(SchemaGrammar* const aGrammar, // the contentspec which is not pointless. If the result is a non-pointless // group, Vector is filled in with the children of interest if (curNode && !baseNode) - ThrowXML(RuntimeException, XMLExcepts::PD_EmptyBase); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_EmptyBase, fMemoryManager); if (!curNode) return; @@ -1422,7 +1427,7 @@ void SchemaValidator::checkParticleDerivationOk(SchemaGrammar* const aGrammar, } default: { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_InvalidContentType, fMemoryManager); } } } @@ -1443,11 +1448,11 @@ void SchemaValidator::checkParticleDerivationOk(SchemaGrammar* const aGrammar, case ContentSpecNode::All: case ContentSpecNode::Leaf: { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_ForbiddenRes1, fMemoryManager); } default: { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_InvalidContentType, fMemoryManager); } } } @@ -1471,11 +1476,11 @@ void SchemaValidator::checkParticleDerivationOk(SchemaGrammar* const aGrammar, case ContentSpecNode::Sequence: case ContentSpecNode::Leaf: { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes2); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_ForbiddenRes2, fMemoryManager); } default: { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_InvalidContentType, fMemoryManager); } } } @@ -1499,11 +1504,11 @@ void SchemaValidator::checkParticleDerivationOk(SchemaGrammar* const aGrammar, case ContentSpecNode::Sequence: case ContentSpecNode::Leaf: { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes3); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_ForbiddenRes3, fMemoryManager); } default: { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_InvalidContentType, fMemoryManager); } } } @@ -1537,11 +1542,11 @@ void SchemaValidator::checkParticleDerivationOk(SchemaGrammar* const aGrammar, } case ContentSpecNode::Leaf: { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes4); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_ForbiddenRes4, fMemoryManager); } default: { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_InvalidContentType, fMemoryManager); } } } @@ -1618,14 +1623,14 @@ SchemaValidator::checkNSCompat(const ContentSpecNode* const derivedSpecNode, if (toCheckOccurence && !isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_OccurRangeE, - derivedSpecNode->getElement()->getLocalPart()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_OccurRangeE, + derivedSpecNode->getElement()->getLocalPart(), fMemoryManager); } // check wildcard subset if (!wildcardEltAllowsNamespace(baseSpecNode, derivedSpecNode->getElement()->getURI())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NSCompat1, - derivedSpecNode->getElement()->getLocalPart()); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NSCompat1, + derivedSpecNode->getElement()->getLocalPart(), fMemoryManager); } } @@ -1669,7 +1674,7 @@ SchemaValidator::checkNameAndTypeOK(SchemaGrammar* const currentGrammar, const XMLCh* baseName = baseSpecNode->getElement()->getLocalPart(); if (!XMLString::equals(derivedName, baseName) || derivedURI != baseURI) { - ThrowXML(RuntimeException, XMLExcepts::PD_NameTypeOK1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NameTypeOK1, fMemoryManager); } // case of mixed complex types with attributes only @@ -1679,7 +1684,7 @@ SchemaValidator::checkNameAndTypeOK(SchemaGrammar* const currentGrammar, if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_OccurRangeE, derivedName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_OccurRangeE, derivedName, fMemoryManager); } SchemaGrammar* aGrammar = currentGrammar; @@ -1711,7 +1716,7 @@ SchemaValidator::checkNameAndTypeOK(SchemaGrammar* const currentGrammar, if (((baseFlags & SchemaSymbols::XSD_NILLABLE) == 0) && ((derivedFlags & SchemaSymbols::XSD_NILLABLE) != 0)) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK2, derivedName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NameTypeOK2, derivedName, fMemoryManager); } const XMLCh* derivedDefVal = derivedElemDecl->getDefaultValue(); @@ -1720,14 +1725,14 @@ SchemaValidator::checkNameAndTypeOK(SchemaGrammar* const currentGrammar, if (baseDefVal && (baseFlags & SchemaSymbols::XSD_FIXED) != 0 && ((derivedFlags & SchemaSymbols::XSD_FIXED) == 0 || !XMLString::equals(derivedDefVal, baseDefVal))) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK3, derivedName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NameTypeOK3, derivedName, fMemoryManager); } int derivedBlockSet = derivedElemDecl->getBlockSet(); int baseBlockSet = baseElemDecl->getBlockSet(); if ((derivedBlockSet & baseBlockSet) != baseBlockSet) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK4, derivedName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NameTypeOK4, derivedName, fMemoryManager); } // check identity constraints @@ -1785,7 +1790,7 @@ SchemaValidator::checkICRestriction(const SchemaElementDecl* const derivedElemDe unsigned int baseICCount = baseElemDecl->getIdentityConstraintCount(); if (derivedICCount > baseICCount) { - ThrowXML2(RuntimeException, XMLExcepts::PD_NameTypeOK6, derivedElemName, baseElemName); + ThrowXMLwithMemMgr2(RuntimeException, XMLExcepts::PD_NameTypeOK6, derivedElemName, baseElemName, fMemoryManager); } for (unsigned int i=0; i < derivedICCount; i++) { @@ -1802,7 +1807,7 @@ SchemaValidator::checkICRestriction(const SchemaElementDecl* const derivedElemDe } if (!found) { - ThrowXML2(RuntimeException, XMLExcepts::PD_NameTypeOK7, derivedElemName, baseElemName); + ThrowXMLwithMemMgr2(RuntimeException, XMLExcepts::PD_NameTypeOK7, derivedElemName, baseElemName, fMemoryManager); } } } @@ -1824,7 +1829,7 @@ SchemaValidator::checkTypesOK(const SchemaElementDecl* const derivedElemDecl, if (derivedElemDecl->getModelType() == SchemaElementDecl::Simple) { if (baseType != SchemaElementDecl::Simple) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName, fMemoryManager); } if (!rInfo) { @@ -1833,7 +1838,7 @@ SchemaValidator::checkTypesOK(const SchemaElementDecl* const derivedElemDecl, if (bInfo || bDV == 0 || !bDV->isSubstitutableBy(derivedElemDecl->getDatatypeValidator())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName, fMemoryManager); } return; @@ -1852,7 +1857,7 @@ SchemaValidator::checkTypesOK(const SchemaElementDecl* const derivedElemDecl, } if (!rInfo) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName); + ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName, fMemoryManager); } } @@ -1895,7 +1900,7 @@ SchemaValidator::checkRecurse(SchemaGrammar* const currentGrammar, if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_Recurse1, fMemoryManager); } // check for mapping of children @@ -1948,7 +1953,7 @@ SchemaValidator::checkRecurse(SchemaGrammar* const currentGrammar, } if (codeToThrow != XMLExcepts::NoError) { - ThrowXML(RuntimeException, codeToThrow); + ThrowXMLwithMemMgr(RuntimeException, codeToThrow, fMemoryManager); } } @@ -1958,11 +1963,11 @@ void SchemaValidator::checkNSSubset(const ContentSpecNode* const derivedSpecNode // check Occurrence ranges if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_NSSubset1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NSSubset1, fMemoryManager); } if (!isWildCardEltSubset(derivedSpecNode, baseSpecNode)) { - ThrowXML(RuntimeException, XMLExcepts::PD_NSSubset2); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NSSubset2, fMemoryManager); } } @@ -2018,7 +2023,7 @@ SchemaValidator::checkNSRecurseCheckCardinality(SchemaGrammar* const currentGram if (toCheckOccurence && !isOccurrenceRangeOK(derivedMin, derivedMax, baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_NSRecurseCheckCardinality1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NSRecurseCheckCardinality1, fMemoryManager); } // Check that each member of the group is a valid restriction of the wildcard @@ -2042,7 +2047,7 @@ SchemaValidator::checkRecurseUnordered(SchemaGrammar* const currentGrammar, // check Occurrence ranges if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_Recurse1, fMemoryManager); } XMLExcepts::Codes codeToThrow = XMLExcepts::NoError; @@ -2103,7 +2108,7 @@ SchemaValidator::checkRecurseUnordered(SchemaGrammar* const currentGrammar, } if (codeToThrow != XMLExcepts::NoError) { - ThrowXML(RuntimeException, codeToThrow); + ThrowXMLwithMemMgr(RuntimeException, codeToThrow, fMemoryManager); } } @@ -2129,7 +2134,7 @@ SchemaValidator::checkMapAndSum(SchemaGrammar* const currentGrammar, if (!isOccurrenceRangeOK(derivedMin, derivedMax, baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_Recurse1, fMemoryManager); } // check for mapping of children @@ -2152,7 +2157,7 @@ SchemaValidator::checkMapAndSum(SchemaGrammar* const currentGrammar, // didn't find a match. if (!matched) { - ThrowXML(RuntimeException, XMLExcepts::PD_MapAndSum); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_MapAndSum, fMemoryManager); } } diff --git a/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp b/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp index 6f3b7e3f5f07b9e0876fe1b2b9b52d1b72f5fa5b..4a5e2ca90425279c51947446eb755c0f5edd65d0 100644 --- a/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp +++ b/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/12/17 00:18:40 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/07/31 17:14:27 peiyongz * Grammar embed grammar description * @@ -144,7 +147,7 @@ bool SubstitutionGroupComparator::isEquivalentTo(QName* const anElement if (!fGrammarResolver || !fStringPool ) { - ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::SubGrpComparator_NGR, anElement->getMemoryManager()); } unsigned int uriId = anElement->getURI(); diff --git a/src/xercesc/validators/schema/TraverseSchema.cpp b/src/xercesc/validators/schema/TraverseSchema.cpp index c8ed00ddcfc0f8db06f7cf07c398a9e450b9e9ae..606846c9f6ba8910befbb87536f96bb239f36df0 100644 --- a/src/xercesc/validators/schema/TraverseSchema.cpp +++ b/src/xercesc/validators/schema/TraverseSchema.cpp @@ -1872,7 +1872,7 @@ TraverseSchema::traverseAny(const DOMElement* const elem) { } else { - BaseRefVectorOf<XMLCh>* nameSpaceTokens = XMLString::tokenizeString(nameSpace); + BaseRefVectorOf<XMLCh>* nameSpaceTokens = XMLString::tokenizeString(nameSpace, fMemoryManager); ValueVectorOf<unsigned int> uriList(8, fGrammarPoolMemoryManager); ContentSpecNode* firstNode = 0; ContentSpecNode* secondNode = 0; @@ -1892,7 +1892,8 @@ TraverseSchema::traverseAny(const DOMElement* const elem) { else { try { anyURIDV->validate(tokenElem - , fSchemaGrammar->getValidationContext()); + , fSchemaGrammar->getValidationContext() + , fMemoryManager); } catch(const XMLException& excep) { reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); @@ -2308,7 +2309,8 @@ void TraverseSchema::traverseAttributeDecl(const DOMElement* const elem, try { dv->validate(valueToCheck - , fSchemaGrammar->getValidationContext()); + , fSchemaGrammar->getValidationContext() + , fMemoryManager); } catch (const XMLException& excep) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); @@ -2871,7 +2873,7 @@ TraverseSchema::traverseByList(const DOMElement* const rootElem, // create & register validator for "generated" type try { newDV = fDatatypeRegistry->createDatatypeValidator( - qualifiedName, baseValidator, 0, 0, true, finalSet); + qualifiedName, baseValidator, 0, 0, true, finalSet, true, fMemoryManager ); } catch (const XMLException& excep) { reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); @@ -2978,7 +2980,7 @@ TraverseSchema::traverseByRestriction(const DOMElement* const rootElem, const XMLCh* facetName = content->getLocalName(); try { - scope = fAttributeCheck.getFacetId(facetName); + scope = fAttributeCheck.getFacetId(facetName, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -3107,7 +3109,7 @@ TraverseSchema::traverseByRestriction(const DOMElement* const rootElem, if (fixedFlag) { - XMLString::binToText(fixedFlag, fixedFlagStr, 15, 10); + XMLString::binToText(fixedFlag, fixedFlagStr, 15, 10, fGrammarPoolMemoryManager); facets->put((void*) SchemaSymbols::fgATT_FIXED, new (fGrammarPoolMemoryManager) KVStringPair(SchemaSymbols::fgATT_FIXED, fixedFlagStr, fGrammarPoolMemoryManager)); } @@ -3116,7 +3118,7 @@ TraverseSchema::traverseByRestriction(const DOMElement* const rootElem, fSchemaGrammar->putAnnotation(enums, janEnumAnnot.release()); try { - newDV = fDatatypeRegistry->createDatatypeValidator(qualifiedName, baseValidator, facets, enums, false, finalSet); + newDV = fDatatypeRegistry->createDatatypeValidator(qualifiedName, baseValidator, facets, enums, false, finalSet, true, fMemoryManager); } catch (const XMLException& excep) { reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); @@ -3243,7 +3245,7 @@ TraverseSchema::traverseByUnion(const DOMElement* const rootElem, janValidators.orphan(); try { - newDV = fDatatypeRegistry->createDatatypeValidator(qualifiedName, validators, finalSet); + newDV = fDatatypeRegistry->createDatatypeValidator(qualifiedName, validators, finalSet, true, fMemoryManager); } catch (const XMLException& excep) { reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); @@ -3505,7 +3507,7 @@ void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, // if not a valid facet, break from the loop try { - scope = fAttributeCheck.getFacetId(facetName); + scope = fAttributeCheck.getFacetId(facetName, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -3573,15 +3575,16 @@ void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, (void*) SchemaSymbols::fgELT_PATTERN, new (fGrammarPoolMemoryManager) KVStringPair ( - SchemaSymbols::fgELT_PATTERN, - pattern.getRawBuffer() + SchemaSymbols::fgELT_PATTERN + , pattern.getRawBuffer() + , fGrammarPoolMemoryManager ) ); } if (fixedFlag) { - XMLString::binToText(fixedFlag, fixedFlagStr, 15, 10); + XMLString::binToText(fixedFlag, fixedFlagStr, 15, 10, fGrammarPoolMemoryManager); facets->put((void*) SchemaSymbols::fgATT_FIXED, new (fGrammarPoolMemoryManager) KVStringPair(SchemaSymbols::fgATT_FIXED, fixedFlagStr, fGrammarPoolMemoryManager)); } @@ -3594,7 +3597,7 @@ void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, ( qualifiedName, typeInfo->getBaseDatatypeValidator(), - facets, enums, false, 0 + facets, enums, false, 0, true, fMemoryManager ) ); } @@ -3893,7 +3896,8 @@ SchemaAttDef* TraverseSchema::traverseAnyAttribute(const DOMElement* const elem) try { anyURIDV->validate(token - , fSchemaGrammar->getValidationContext()); + , fSchemaGrammar->getValidationContext() + , fMemoryManager); } catch(const XMLException& excep) { reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); @@ -4199,7 +4203,7 @@ bool TraverseSchema::traverseIdentityConstraint(IdentityConstraint* const ic, fBuffer.append(fgDotForwardSlash); } - int chOffset = XMLString::indexOf(xpathExpr, chPipe, startIndex); + int chOffset = XMLString::indexOf(xpathExpr, chPipe, startIndex, fMemoryManager); if (chOffset == -1) break; @@ -5587,7 +5591,8 @@ void TraverseSchema::processAttributeDeclRef(const DOMElement* const elem, else { try { attDV->validate(valueConstraint - , fSchemaGrammar->getValidationContext()); + , fSchemaGrammar->getValidationContext() + , fMemoryManager); } catch(const XMLException& excep) { reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); @@ -5638,7 +5643,7 @@ void TraverseSchema::checkMinMax(ContentSpecNode* const specNode, } else { try { - minOccurs = XMLString::parseInt(minOccursStr); + minOccurs = XMLString::parseInt(minOccursStr, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -5666,7 +5671,7 @@ void TraverseSchema::checkMinMax(ContentSpecNode* const specNode, } else { try { - maxOccurs = XMLString::parseInt(maxOccursStr); + maxOccurs = XMLString::parseInt(maxOccursStr, fMemoryManager); } catch(const OutOfMemoryException&) { @@ -5687,8 +5692,8 @@ void TraverseSchema::checkMinMax(ContentSpecNode* const specNode, XMLCh tmpMinStr[128]; XMLCh tmpMaxStr[128]; - XMLString::binToText(minOccurs, tmpMinStr, 127, 10); - XMLString::binToText(maxOccurs, tmpMaxStr, 127, 10); + XMLString::binToText(minOccurs, tmpMinStr, 127, 10, fMemoryManager); + XMLString::binToText(maxOccurs, tmpMaxStr, 127, 10, fMemoryManager); if (maxOccurs < 1) { reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, @@ -6442,15 +6447,15 @@ InputSource* TraverseSchema::resolveSchemaLocation(const XMLCh* const loc, try { - XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), normalizedURI); + XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), normalizedURI, fMemoryManager); if (urlTmp.isRelative()) { - ThrowXML(MalformedURLException, - XMLExcepts::URL_NoProtocolPresent); + ThrowXMLwithMemMgr(MalformedURLException, + XMLExcepts::URL_NoProtocolPresent, fMemoryManager); } else { if (fScanner->getStandardUriConformant() && urlTmp.hasInvalidChar()) - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); + ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_MalformedURL, fMemoryManager); srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -8379,7 +8384,7 @@ TraverseSchema::checkElemDeclValueConstraint(const DOMElement* const elem, try { - validator->validate(valConstraint); + validator->validate(valConstraint,0,fMemoryManager); isValid = true; } catch(const XMLException& excep) diff --git a/src/xercesc/validators/schema/TraverseSchema.hpp b/src/xercesc/validators/schema/TraverseSchema.hpp index 2ccc79a0c3454e8864fb53bc8800e178dccd1a9f..0fa5af6c2d2ef008768bfa7e0eaebb81a2f92194 100644 --- a/src/xercesc/validators/schema/TraverseSchema.hpp +++ b/src/xercesc/validators/schema/TraverseSchema.hpp @@ -920,7 +920,7 @@ inline const XMLCh* TraverseSchema::genAnonTypeName(const XMLCh* const prefix) { XMLCh anonCountStr[16]; // a count of 15 digits should be enough - XMLString::binToText(fAnonXSTypeCount++, anonCountStr, 15, 10); + XMLString::binToText(fAnonXSTypeCount++, anonCountStr, 15, 10, fMemoryManager); fBuffer.set(prefix); fBuffer.append(anonCountStr); diff --git a/src/xercesc/validators/schema/identity/FieldActivator.cpp b/src/xercesc/validators/schema/identity/FieldActivator.cpp index 0462b67a25f0c259a5503b80d3d5fbdf7c3039b7..1c02b767f3b3c33dcc753b14e347d96aad244b70 100644 --- a/src/xercesc/validators/schema/identity/FieldActivator.cpp +++ b/src/xercesc/validators/schema/identity/FieldActivator.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/12/17 00:18:41 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.6 2003/12/16 18:41:15 knoaman * Make IC_Field stateless * @@ -111,7 +114,7 @@ FieldActivator::FieldActivator(const FieldActivator& other) , fMemoryManager(other.fMemoryManager) { fMayMatch = new (fMemoryManager) ValueHashTableOf<bool>(29, new (fMemoryManager) HashPtr(), fMemoryManager); - ValueHashTableOfEnumerator<bool> mayMatchEnum(other.fMayMatch); + ValueHashTableOfEnumerator<bool> mayMatchEnum(other.fMayMatch, false, fMemoryManager); // Build key set while (mayMatchEnum.hasMoreElements()) diff --git a/src/xercesc/validators/schema/identity/ValueStore.cpp b/src/xercesc/validators/schema/identity/ValueStore.cpp index 783d264002440631c7916d6e5ae6f0090d439668..df095871632ca721d7223682815164d193f2ea1d 100644 --- a/src/xercesc/validators/schema/identity/ValueStore.cpp +++ b/src/xercesc/validators/schema/identity/ValueStore.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/12/17 00:18:41 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.8 2003/12/16 18:41:15 knoaman * Make IC_Field stateless * @@ -315,7 +318,7 @@ bool ValueStore::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const // are the validators equal? // As always we are obliged to compare by reference... if (dv1 == dv2) { - return ((dv1->compare(val1, val2)) == 0); + return ((dv1->compare(val1, val2, fMemoryManager)) == 0); } // see if this.fValidator is derived from value.fValidator: @@ -323,14 +326,14 @@ bool ValueStore::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const for(; !tempVal || tempVal == dv2; tempVal = tempVal->getBaseValidator()) ; if (tempVal) { // was derived! - return ((dv2->compare(val1, val2)) == 0); + return ((dv2->compare(val1, val2, fMemoryManager)) == 0); } // see if value.fValidator is derived from this.fValidator: for(tempVal = dv2; !tempVal || tempVal == dv1; tempVal = tempVal->getBaseValidator()) ; if(tempVal) { // was derived! - return ((dv1->compare(val1, val2)) == 0); + return ((dv1->compare(val1, val2, fMemoryManager)) == 0); } // if we're here it means the types weren't related. Must fall back to strings: diff --git a/src/xercesc/validators/schema/identity/ValueStoreCache.cpp b/src/xercesc/validators/schema/identity/ValueStoreCache.cpp index 2874d762e56b532404d6c5aef22b689e6e9d33d7..32f27e38389cdf3df55b25fdfea58b5ae3a36b60 100644 --- a/src/xercesc/validators/schema/identity/ValueStoreCache.cpp +++ b/src/xercesc/validators/schema/identity/ValueStoreCache.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:41 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/10/01 16:32:42 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * @@ -159,7 +162,7 @@ void ValueStoreCache::endElement() { } RefHashTableOf<ValueStore>* oldMap = fGlobalMapStack->pop(); - RefHashTableOfEnumerator<ValueStore> mapEnum(oldMap); + RefHashTableOfEnumerator<ValueStore> mapEnum(oldMap, false, fMemoryManager); // Janitor<RefHashTableOf<ValueStore> > janMap(oldMap); while (mapEnum.hasMoreElements()) { diff --git a/src/xercesc/validators/schema/identity/XPathMatcher.cpp b/src/xercesc/validators/schema/identity/XPathMatcher.cpp index eff426d320503ea6a68cae0f01266f91bb132925..c98334bda980c19b04827a1dd1e96e43b1093bc3 100644 --- a/src/xercesc/validators/schema/identity/XPathMatcher.cpp +++ b/src/xercesc/validators/schema/identity/XPathMatcher.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.10 2003/12/17 00:18:41 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.9 2003/10/01 16:32:42 neilg * improve handling of out of memory conditions, bug #23415. Thanks to David Cargill. * @@ -418,7 +421,7 @@ void XPathMatcher::matched(const XMLCh* const content, // --------------------------------------------------------------------------- int XPathMatcher::getInitialDepth() const { - ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager); return 0; // to make some compilers happy } diff --git a/src/xercesc/validators/schema/identity/XercesXPath.cpp b/src/xercesc/validators/schema/identity/XercesXPath.cpp index 16625f9ec5784c00860139aa4ffb994067f01ee1..6d390ff90b41a4b8bd6370546bea24e089eb169c 100644 --- a/src/xercesc/validators/schema/identity/XercesXPath.cpp +++ b/src/xercesc/validators/schema/identity/XercesXPath.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2003/12/17 00:18:41 cargilld + * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data. + * * Revision 1.11 2003/10/17 21:18:04 peiyongz * using XTemplateSerializer * @@ -444,7 +447,7 @@ void XercesXPath::checkForSelectedAttributes() { if (stepSize) { if (locPath->getStep(stepSize - 1)->getAxisType() == XercesStep::ATTRIBUTE) { - ThrowXML(XPathException, XMLExcepts::XPath_NoAttrSelector); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoAttrSelector, fMemoryManager); } } } @@ -480,13 +483,13 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, case XercesXPath::EXPRTOKEN_OPERATOR_UNION: { if (i == 0) { - ThrowXML(XPathException, XMLExcepts::XPath_NoUnionAtStart); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoUnionAtStart, fMemoryManager); } int stepsSize = stepsVector->size(); if (stepsSize == 0) { - ThrowXML(XPathException, XMLExcepts::XPath_NoMultipleUnion); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoMultipleUnion, fMemoryManager); } fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector)); @@ -505,7 +508,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, { // consume QName token if (i == tokenCount - 1) { - ThrowXML(XPathException, XMLExcepts::XPath_MissingAttr); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_MissingAttr, fMemoryManager); } aToken = tokens.elementAt(++i); @@ -513,7 +516,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, if (aToken != XercesXPath::EXPRTOKEN_NAMETEST_QNAME && aToken!= XercesXPath::EXPRTOKEN_NAMETEST_ANY && aToken!= XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE) { - ThrowXML(XPathException, XMLExcepts::XPath_ExpectedToken1); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedToken1, fMemoryManager); } bool isNamespaceAtt=false; @@ -545,7 +548,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, } if (aToken != -1 && scopeContext && uri == fEmptyNamespaceId) { - ThrowXML1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix); + ThrowXMLwithMemMgr1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix, fMemoryManager); } if (isNamespaceAtt) { @@ -576,7 +579,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, case XercesXPath::EXPRTOKEN_DOUBLE_COLON: { // should never have a bare double colon - ThrowXML(XPathException, XMLExcepts::XPath_NoDoubleColon); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoDoubleColon, fMemoryManager); } case XercesXPath::EXPRTOKEN_AXISNAME_CHILD: { @@ -584,7 +587,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, i++; if (i == tokenCount - 1) { - ThrowXML(XPathException, XMLExcepts::XPath_ExpectedStep1); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep1, fMemoryManager); } firstTokenOfLocationPath=false; @@ -617,7 +620,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, } if (aToken != -1 && scopeContext && uri == fEmptyNamespaceId) { - ThrowXML1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix); + ThrowXMLwithMemMgr1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix, fMemoryManager); } if (isNamespace) { @@ -654,7 +657,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, if (aToken == XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH){ if (++i == tokenCount - 1) { - ThrowXML(XPathException, XMLExcepts::XPath_ExpectedStep2); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep2, fMemoryManager); } if (i+1 < tokenCount) { @@ -662,7 +665,7 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, aToken = tokens.elementAt(i+1); if (aToken == XercesXPath::EXPRTOKEN_OPERATOR_SLASH) { - ThrowXML(XPathException, XMLExcepts::XPath_NoForwardSlash); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoForwardSlash, fMemoryManager); } } // build step @@ -676,21 +679,21 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, } case XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH: { - ThrowXML(XPathException, XMLExcepts::XPath_NoDoubleForwardSlash); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoDoubleForwardSlash, fMemoryManager); } case XercesXPath::EXPRTOKEN_OPERATOR_SLASH: { if (i == 0) { - ThrowXML(XPathException, XMLExcepts::XPath_NoForwardSlashAtStart); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoForwardSlashAtStart, fMemoryManager); } // keep on truckin' if (firstTokenOfLocationPath) { - ThrowXML(XPathException, XMLExcepts::XPath_NoSelectionOfRoot); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoSelectionOfRoot, fMemoryManager); } if (i == tokenCount - 1) { - ThrowXML(XPathException, XMLExcepts::XPath_ExpectedStep3); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep3, fMemoryManager); } firstTokenOfLocationPath=false; @@ -705,10 +708,10 @@ void XercesXPath::parseExpression(XMLStringPool* const stringPool, if (stepsSize == 0) { if (!fLocationPaths || fLocationPaths->size() == 0) { - ThrowXML(XPathException, XMLExcepts::XPath_EmptyExpr); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_EmptyExpr, fMemoryManager); } else { - ThrowXML(XPathException, XMLExcepts::XPath_NoUnionAtEnd); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoUnionAtEnd, fMemoryManager); } } @@ -921,7 +924,7 @@ bool XPathScanner::scanExpression(const XMLCh* const data, break; } } else { - ThrowXML(XPathException, XMLExcepts::XPath_InvalidChar); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_InvalidChar, tokens->getMemoryManager()); } break; @@ -1431,7 +1434,7 @@ int XPathScanner::scanNumber(const XMLCh* const data, } if (part != 0) { - ThrowXML(RuntimeException, XMLExcepts::XPath_FindSolution); + ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::XPath_FindSolution, tokens->getMemoryManager()); } } } @@ -1476,7 +1479,7 @@ void XPathScannerForSchema::addToken(ValueVectorOf<int>* const tokens, return; } - ThrowXML(XPathException, XMLExcepts::XPath_TokenNotSupported); + ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_TokenNotSupported, tokens->getMemoryManager()); } XERCES_CPP_NAMESPACE_END