[cpp-xmltooling COMMIT] in /branches/REL_1/xmltooling/util: ParserPool.cpp PathResolver.cpp

noreply at shibboleth.net noreply at shibboleth.net
Sun May 20 19:49:08 BST 2012


Author: scantor
Date: Sun May 20 19:49:08 2012
New Revision: 974

URL: http://svn.shibboleth.net/view/cpp-xmltooling?rev=974&view=rev
Log:
Add path resolution and env expansion to catalog path.

Modified:
    branches/REL_1/xmltooling/util/ParserPool.cpp
    branches/REL_1/xmltooling/util/PathResolver.cpp

Modified: branches/REL_1/xmltooling/util/ParserPool.cpp
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/util/ParserPool.cpp?rev=974&r1=973&r2=974&view=diff
==============================================================================
--- branches/REL_1/xmltooling/util/ParserPool.cpp (original)
+++ branches/REL_1/xmltooling/util/ParserPool.cpp Sun May 20 19:49:08 2012
@@ -29,6 +29,7 @@
 #include "logging.h"
 #include "util/CurlURLInputStream.h"
 #include "util/NDC.h"
+#include "util/PathResolver.h"
 #include "util/ParserPool.h"
 #include "util/Threads.h"
 #include "util/XMLHelper.h"
@@ -39,7 +40,6 @@
 #include <functional>
 #include <boost/algorithm/string.hpp>
 #include <boost/bind.hpp>
-#include <boost/tokenizer.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/sax/SAXException.hpp>
@@ -240,13 +240,13 @@
 bool ParserPool::loadCatalogs(const char* pathnames)
 {
     string temp(pathnames);
-    boost::tokenizer< char_separator<char> > catpaths(temp, char_separator<char>(PATH_SEPARATOR_STR));
-    for_each(
-        catpaths.begin(), catpaths.end(),
-        // Call loadCatalog with an inner call to s->c_str() on each entry.
-        boost::bind(static_cast<bool (ParserPool::*)(const char*)>(&ParserPool::loadCatalog), this, boost::bind(&string::c_str, _1))
-        );
-    return catpaths.begin() != catpaths.end();
+    vector<string> catpaths;
+    split(catpaths, temp, is_any_of(PATH_SEPARATOR_STR), algorithm::token_compress_on);
+    for (vector<string>::iterator i = catpaths.begin(); i != catpaths.end(); ++i) {
+        XMLToolingConfig::getConfig().getPathResolver()->resolve(*i, PathResolver::XMLTOOLING_XML_FILE);
+        loadCatalog(i->c_str());
+    }
+    return !catpaths.empty();
 }
 
 bool ParserPool::loadCatalog(const char* pathname)

Modified: branches/REL_1/xmltooling/util/PathResolver.cpp
URL: http://svn.shibboleth.net/view/cpp-xmltooling/branches/REL_1/xmltooling/util/PathResolver.cpp?rev=974&r1=973&r2=974&view=diff
==============================================================================
--- branches/REL_1/xmltooling/util/PathResolver.cpp (original)
+++ branches/REL_1/xmltooling/util/PathResolver.cpp Sun May 20 19:49:08 2012
@@ -101,6 +101,16 @@
 
 const string& PathResolver::resolve(string& s, file_type_t filetype, const char* pkgname, const char* prefix) const
 {
+#ifdef WIN32
+    // Check for possible environment variable(s).
+    if (s.find('%') != string::npos) {
+        char expbuf[MAX_PATH + 2];
+        DWORD cnt = ExpandEnvironmentStrings(s.c_str(), expbuf, sizeof(expbuf));
+        if (cnt != 0 && cnt <= sizeof(expbuf))
+            s = expbuf;
+    }
+#endif
+
     if (!isAbsolute(s.c_str())) {
         switch (filetype) {
             case XMLTOOLING_LIB_FILE:



More information about the commits mailing list