Remove non-xstring code.
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Fri, 22 May 2009 02:37:06 +0000 (02:37 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Fri, 22 May 2009 02:37:06 +0000 (02:37 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@582 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/util/ParserPool.cpp
xmltooling/util/ParserPool.h

index ee64178..25e4324 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright 2001-2008 Internet2
- * 
+ *
  * 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
@@ -16,7 +16,7 @@
 
 /**
  * ParserPool.cpp
- * 
+ *
  * A thread-safe pool of parsers that share characteristics.
  */
 
@@ -204,7 +204,7 @@ public:
 bool ParserPool::loadSchema(const XMLCh* nsURI, const XMLCh* pathname)
 {
     // Just check the pathname and then directly register the pair into the map.
-    
+
     auto_ptr_char p(pathname);
 #ifdef WIN32
     struct _stat stat_buf;
@@ -224,16 +224,9 @@ bool ParserPool::loadSchema(const XMLCh* nsURI, const XMLCh* pathname)
     }
 
     Lock lock(m_lock);
-#ifdef HAVE_GOOD_STL
     m_schemaLocMap[nsURI]=pathname;
     m_schemaLocations.erase();
     for_each(m_schemaLocMap.begin(),m_schemaLocMap.end(),doubleit<xstring>(m_schemaLocations,chSpace));
-#else
-    auto_ptr_char n(nsURI);
-    m_schemaLocMap[n.get()]=p.get();
-    m_schemaLocations.erase();
-    for_each(m_schemaLocMap.begin(),m_schemaLocMap.end(),doubleit<string>(m_schemaLocations,' '));
-#endif
 
     return true;
 }
@@ -273,7 +266,7 @@ bool ParserPool::loadCatalog(const XMLCh* pathname)
     try {
         DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(domsrc);
         XercesJanitor<DOMDocument> janitor(doc);
-        
+
         // Check root element.
         const DOMElement* root=doc->getDocumentElement();
         if (!XMLHelper::isNodeNamed(root,CATALOG_NS,catalog)) {
@@ -281,7 +274,7 @@ bool ParserPool::loadCatalog(const XMLCh* pathname)
             log.error("unknown root element, failed to load XML catalog from %s", temp.get());
             return false;
         }
-        
+
         // Fetch all the <system> elements.
         DOMNodeList* mappings=root->getElementsByTagNameNS(CATALOG_NS,system);
         Lock lock(m_lock);
@@ -289,20 +282,10 @@ bool ParserPool::loadCatalog(const XMLCh* pathname)
             root=static_cast<DOMElement*>(mappings->item(i));
             const XMLCh* from=root->getAttributeNS(NULL,systemId);
             const XMLCh* to=root->getAttributeNS(NULL,uri);
-#ifdef HAVE_GOOD_STL
             m_schemaLocMap[from]=to;
-#else
-            auto_ptr_char f(from);
-            auto_ptr_char t(to);
-            m_schemaLocMap[f.get()]=t.get();
-#endif
         }
         m_schemaLocations.erase();
-#ifdef HAVE_GOOD_STL
         for_each(m_schemaLocMap.begin(),m_schemaLocMap.end(),doubleit<xstring>(m_schemaLocations,chSpace));
-#else
-        for_each(m_schemaLocMap.begin(),m_schemaLocMap.end(),doubleit<string>(m_schemaLocations,' '));
-#endif
     }
     catch (exception& e) {
         log.error("catalog loader caught exception: %s", e.what());
@@ -339,7 +322,6 @@ DOMInputSource* ParserPool::resolveEntity(
         log.debug("asked to resolve %s with baseURI %s",sysId.get(),base.get() ? base.get() : "(null)");
     }
 
-#ifdef HAVE_GOOD_STL
     // Find well-known schemas in the specified location.
     map<xstring,xstring>::const_iterator i=m_schemaLocMap.find(systemId);
     if (i!=m_schemaLocMap.end())
@@ -354,31 +336,9 @@ DOMInputSource* ParserPool::resolveEntity(
     // We'll allow anything without embedded slashes.
     if (XMLString::indexOf(systemId, chForwardSlash)==-1)
         return new Wrapper4InputSource(new LocalFileInputSource(baseURI,systemId));
-#else
-    // Find well-known schemas in the specified location.
-    auto_ptr_char temp(systemId);
-    map<string,string>::const_iterator i=m_schemaLocMap.find(temp.get());
-    if (i!=m_schemaLocMap.end()) {
-        auto_ptr_XMLCh temp2(i->second.c_str());
-        return new Wrapper4InputSource(new LocalFileInputSource(baseURI,temp2.get()));
-    }
-
-    // Check for entity as a value in the map.
-    for (i=m_schemaLocMap.begin(); i!=m_schemaLocMap.end(); ++i) {
-        auto_ptr_XMLCh temp2(i->second.c_str());
-        if (XMLString::endsWith(temp2.get(), systemId))
-            return new Wrapper4InputSource(new LocalFileInputSource(baseURI,temp2.get()));
-    }
-
-    // We'll allow anything without embedded slashes.
-    if (XMLString::indexOf(systemId, chForwardSlash)==-1)
-        return new Wrapper4InputSource(new LocalFileInputSource(baseURI,systemId));
-#endif    
 
     // Shortcircuit the request.
-#ifdef HAVE_GOOD_STL
     auto_ptr_char temp(systemId);
-#endif
     log.debug("unauthorized entity request (%s), blocking it", temp.get());
     static const XMLByte nullbuf[] = {0};
     return new Wrapper4InputSource(new MemBufInputSource(nullbuf,0,systemId));
@@ -397,15 +357,10 @@ DOMLSParser* ParserPool::createBuilder()
         parser->getDomConfig()->setParameter(XMLUni::fgXercesSchema, true);
         parser->getDomConfig()->setParameter(XMLUni::fgDOMValidate, true);
         parser->getDomConfig()->setParameter(XMLUni::fgXercesCacheGrammarFromParse, true);
-        
+
         // We build a "fake" schema location hint that binds each namespace to itself.
-        // This ensures the entity resolver will be given the namespace as a systemId it can check. 
-#ifdef HAVE_GOOD_STL
+        // This ensures the entity resolver will be given the namespace as a systemId it can check.
         parser->getDomConfig()->setParameter(XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(m_schemaLocations.c_str()));
-#else
-        auto_ptr_XMLCh temp(m_schemaLocations.c_str());
-        parser->getDomConfig()->setParameter(XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(temp.get()));
-#endif
     }
     parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true);
     parser->getDomConfig()->setParameter(XMLUni::fgXercesDisableDefaultEntityResolution, true);
@@ -423,14 +378,8 @@ DOMLSParser* ParserPool::checkoutBuilder()
     }
     DOMLSParser* p=m_pool.top();
     m_pool.pop();
-    if (m_schemaAware) {
-#ifdef HAVE_GOOD_STL
+    if (m_schemaAware)
         p->getDomConfig()->setParameter(XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(m_schemaLocations.c_str()));
-#else
-        auto_ptr_XMLCh temp2(m_schemaLocations.c_str());
-        p->getDomConfig()->setParameter(XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(temp2.get()));
-#endif
-    }
     return p;
 }
 
@@ -455,15 +404,10 @@ DOMBuilder* ParserPool::createBuilder()
         parser->setFeature(XMLUni::fgXercesSchema, true);
         parser->setFeature(XMLUni::fgDOMValidation, true);
         parser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);
-        
+
         // We build a "fake" schema location hint that binds each namespace to itself.
-        // This ensures the entity resolver will be given the namespace as a systemId it can check. 
-#ifdef HAVE_GOOD_STL
+        // This ensures the entity resolver will be given the namespace as a systemId it can check.
         parser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(m_schemaLocations.c_str()));
-#else
-        auto_ptr_XMLCh temp(m_schemaLocations.c_str());
-        parser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(temp.get()));
-#endif
     }
     parser->setProperty(XMLUni::fgXercesSecurityManager, m_security);
     parser->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true);
@@ -481,14 +425,8 @@ DOMBuilder* ParserPool::checkoutBuilder()
     }
     DOMBuilder* p=m_pool.top();
     m_pool.pop();
-    if (m_schemaAware) {
-#ifdef HAVE_GOOD_STL
+    if (m_schemaAware)
         p->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(m_schemaLocations.c_str()));
-#else
-        auto_ptr_XMLCh temp2(m_schemaLocations.c_str());
-        p->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,const_cast<XMLCh*>(temp2.get()));
-#endif
-    }
     return p;
 }
 
index fefdddc..e901a02 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright 2001-2008 Internet2
- * 
+ *
  * 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
@@ -16,7 +16,7 @@
 
 /**
  * @file xmltooling/util/ParserPool.h
- * 
+ *
  * A thread-safe pool of parsers that share characteristics.
  */
 
@@ -60,7 +60,7 @@ namespace xmltooling {
     public:
         /**
          * Constructs a new pool
-         * 
+         *
          * @param namespaceAware    indicates whether parsers should be namespace-aware or not
          * @param schemaAware       indicates whether parsers should be schema-validating or not
          */
@@ -69,15 +69,15 @@ namespace xmltooling {
 
         /**
          * Creates a new document using a parser from this pool.
-         * 
+         *
          * @return new XML document
-         * 
+         *
          */
         xercesc::DOMDocument* newDocument();
 
         /**
          * Parses a document using a pooled parser with the proper settings
-         * 
+         *
          * @param domsrc An input source containing the content to be parsed
          * @return The DOM document resulting from the parse
          * @throws XMLParserException thrown if there was a problem reading, parsing, or validating the XML
@@ -92,7 +92,7 @@ namespace xmltooling {
 
         /**
          * Parses a document using a pooled parser with the proper settings
-         * 
+         *
          * @param is An input stream containing the content to be parsed
          * @return The DOM document resulting from the parse
          * @throws XMLParserException thrown if there was a problem reading, parsing, or validating the XML
@@ -101,21 +101,21 @@ namespace xmltooling {
 
         /**
          * Load an OASIS catalog file to map schema namespace URIs to filenames.
-         * 
+         *
          * This does not provide real catalog support; only the &lt;uri&gt; element
          * is supported to map from a namespace URI to a relative path or file:// URI.
-         * 
+         *
          * @param pathname  path to a catalog file
          * @return true iff the catalog was successfully processed
          */
         bool loadCatalog(const XMLCh* pathname);
-        
+
         /**
          * Load a schema explicitly from a local file.
-         * 
+         *
          * Note that "successful processing" does not imply that the schema is valid,
          * only that a reference to it was successfully registered with the pool.
-         * 
+         *
          * @param nsURI     XML namespace to load
          * @param pathname  path to schema file
          * @return true iff the schema was successfully processed
@@ -150,13 +150,9 @@ namespace xmltooling {
         void checkinBuilder(xercesc::DOMBuilder* builder);
 #endif
 
-#ifdef HAVE_GOOD_STL
         xstring m_schemaLocations;
         std::map<xstring,xstring> m_schemaLocMap;
-#else
-        std::string m_schemaLocations;
-        std::map<std::string,std::string> m_schemaLocMap;
-#endif
+
         bool m_namespaceAware,m_schemaAware;
 #ifdef XMLTOOLING_XERCESC_COMPLIANT_DOMLS
         std::stack<xercesc::DOMLSParser*> m_pool;
@@ -176,7 +172,7 @@ namespace xmltooling {
     public:
         /**
          * Constructs an input source around an input stream reference.
-         * 
+         *
          * @param is        reference to an input stream
          * @param systemId  optional system identifier to attach to the stream
          */
@@ -193,7 +189,7 @@ namespace xmltooling {
         public:
             /**
              * Constructs a Xerces input stream around a C++ input stream reference.
-             * 
+             *
              * @param is            reference to an input stream
              */
             StreamBinInputStream(std::istream& is) : m_is(is), m_pos(0) {}
@@ -227,7 +223,7 @@ namespace xmltooling {
     public:
         /**
          * Constructor.
-         * 
+         *
          * @param url       source of input
          * @param systemId  optional system identifier to attach to the source
          */
@@ -235,7 +231,7 @@ namespace xmltooling {
 
         /**
          * Constructor taking a DOM element supporting the following content:
-         * 
+         *
          * <dl>
          *  <dt>uri | url</dt>
          *  <dd>identifies the remote resource</dd>
@@ -244,7 +240,7 @@ namespace xmltooling {
          *  <dt>TransportOption elements, like so:</dt>
          *  <dd>&lt;TransportOption provider="CURL" option="150"&gt;0&lt;/TransportOption&gt;</dd>
          * </dl>
-         * 
+         *
          * @param e         DOM to supply configuration
          * @param systemId  optional system identifier to attach to the source
          */