X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Futil%2FParserPool.cpp;h=576f3f766c359d5b88a671809ec6d5a0afbc812d;hb=81b488b2790e7bdeb2f43560b1d4a7d22c3dfdf5;hp=6da2911cc534fb17485fa4194d579754f22ed9b5;hpb=bd026f07e729e66127b3efd48aee443fba815af3;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/util/ParserPool.cpp b/xmltooling/util/ParserPool.cpp index 6da2911..576f3f7 100644 --- a/xmltooling/util/ParserPool.cpp +++ b/xmltooling/util/ParserPool.cpp @@ -1,17 +1,21 @@ -/* - * Copyright 2001-2009 Internet2 +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. */ /** @@ -110,7 +114,7 @@ ParserPool::~ParserPool() DOMDocument* ParserPool::newDocument() { - return DOMImplementationRegistry::getDOMImplementation(NULL)->createDocument(); + return DOMImplementationRegistry::getDOMImplementation(nullptr)->createDocument(); } #ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS @@ -128,20 +132,20 @@ DOMDocument* ParserPool::parse(DOMLSInput& domsrc) doc->release(); throw XMLParserException("XML error(s) during parsing, check log for specifics"); } - parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)NULL); + parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)nullptr); parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true); checkinBuilder(janitor.release()); return doc; } catch (XMLException& ex) { - parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)NULL); + parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)nullptr); parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true); checkinBuilder(janitor.release()); auto_ptr_char temp(ex.getMessage()); throw XMLParserException(string("Xerces error during parsing: ") + (temp.get() ? temp.get() : "no message")); } catch (XMLToolingException&) { - parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)NULL); + parser->getDomConfig()->setParameter(XMLUni::fgDOMErrorHandler, (void*)nullptr); parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true); checkinBuilder(janitor.release()); throw; @@ -163,20 +167,20 @@ DOMDocument* ParserPool::parse(DOMInputSource& domsrc) doc->release(); throw XMLParserException("XML error(s) during parsing, check log for specifics"); } - parser->setErrorHandler(NULL); + parser->setErrorHandler(nullptr); parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true); checkinBuilder(janitor.release()); return doc; } catch (XMLException& ex) { - parser->setErrorHandler(NULL); + parser->setErrorHandler(nullptr); parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true); checkinBuilder(janitor.release()); auto_ptr_char temp(ex.getMessage()); throw XMLParserException(string("Xerces error during parsing: ") + (temp.get() ? temp.get() : "no message")); } catch (XMLToolingException&) { - parser->setErrorHandler(NULL); + parser->setErrorHandler(nullptr); parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true); checkinBuilder(janitor.release()); throw; @@ -262,7 +266,7 @@ bool ParserPool::loadCatalog(const XMLCh* pathname) log.debug("loading XML catalog from %s", temp.get()); } - LocalFileInputSource fsrc(NULL,pathname); + LocalFileInputSource fsrc(nullptr,pathname); Wrapper4InputSource domsrc(&fsrc,false); try { DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(domsrc); @@ -281,8 +285,8 @@ bool ParserPool::loadCatalog(const XMLCh* pathname) Lock lock(m_lock); for (XMLSize_t i=0; igetLength(); i++) { root=static_cast(mappings->item(i)); - const XMLCh* from=root->getAttributeNS(NULL,systemId); - const XMLCh* to=root->getAttributeNS(NULL,uri); + const XMLCh* from=root->getAttributeNS(nullptr,systemId); + const XMLCh* to=root->getAttributeNS(nullptr,uri); m_schemaLocMap[from]=to; } m_schemaLocations.erase(); @@ -314,7 +318,7 @@ DOMInputSource* ParserPool::resolveEntity( xmltooling::NDC ndc("resolveEntity"); #endif if (!systemId) - return NULL; + return nullptr; Category& log=Category::getInstance(XMLTOOLING_LOGCAT".ParserPool"); if (log.isDebugEnabled()) { @@ -351,7 +355,7 @@ DOMLSParser* ParserPool::createBuilder() { static const XMLCh impltype[] = { chLatin_L, chLatin_S, chNull }; DOMImplementation* impl=DOMImplementationRegistry::getDOMImplementation(impltype); - DOMLSParser* parser=static_cast(impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS,NULL); + DOMLSParser* parser=static_cast(impl)->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS,nullptr); parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, m_namespaceAware); if (m_schemaAware) { parser->getDomConfig()->setParameter(XMLUni::fgDOMNamespaces, true); @@ -467,7 +471,7 @@ StreamInputSource::StreamBinInputStream::curPos() const #ifdef XMLTOOLING_XERCESC_64BITSAFE const XMLCh* StreamInputSource::StreamBinInputStream::getContentType() const { - return NULL; + return nullptr; } #endif @@ -496,18 +500,18 @@ xsecsize_t StreamInputSource::StreamBinInputStream::readBytes(XMLByte* const toF #ifdef XMLTOOLING_LITE -URLInputSource::URLInputSource(const XMLCh* url, const char* systemId) : InputSource(systemId), m_url(url) +URLInputSource::URLInputSource(const XMLCh* url, const char* systemId, string* cacheTag) : InputSource(systemId), m_url(url) { } -URLInputSource::URLInputSource(const DOMElement* e, const char* systemId) : InputSource(systemId) +URLInputSource::URLInputSource(const DOMElement* e, const char* systemId, string* cacheTag) : InputSource(systemId) { static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i); static const XMLCh url[] = UNICODE_LITERAL_3(u,r,l); - const XMLCh* attr = e->getAttributeNS(NULL, url); + const XMLCh* attr = e->getAttributeNS(nullptr, url); if (!attr || !*attr) { - attr = e->getAttributeNS(NULL, uri); + attr = e->getAttributeNS(nullptr, uri); if (!attr || !*attr) throw IOException("No URL supplied via DOM to URLInputSource constructor."); } @@ -523,19 +527,23 @@ BinInputStream* URLInputSource::makeStream() const #else -URLInputSource::URLInputSource(const XMLCh* url, const char* systemId) - : InputSource(systemId), m_url(url), m_root(NULL) +URLInputSource::URLInputSource(const XMLCh* url, const char* systemId, string* cacheTag) + : InputSource(systemId), m_cacheTag(cacheTag), m_url(url), m_root(nullptr) { } -URLInputSource::URLInputSource(const DOMElement* e, const char* systemId) - : InputSource(systemId), m_root(e) +URLInputSource::URLInputSource(const DOMElement* e, const char* systemId, string* cacheTag) + : InputSource(systemId), m_cacheTag(cacheTag), m_root(e) { } BinInputStream* URLInputSource::makeStream() const { - return m_root ? new CurlURLInputStream(m_root) : new CurlURLInputStream(m_url.get()); + return m_root ? new CurlURLInputStream(m_root, m_cacheTag) : new CurlURLInputStream(m_url.get(), m_cacheTag); } #endif + +const char URLInputSource::asciiStatusCodeElementName[] = "URLInputSourceStatus"; + +const XMLCh URLInputSource::utf16StatusCodeElementName[] = UNICODE_LITERAL_20(U,R,L,I,n,p,u,t,S,o,u,r,c,e,S,t,a,t,u,s);