From 61203b22e58cbcc0044745fbda5f06a7e347d1a1 Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Wed, 16 Nov 2011 21:33:46 +0000 Subject: [PATCH] Incorporate boost split/lambda. --- xmltooling/XMLToolingConfig.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index 740e100..bb7ba46 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -55,6 +55,10 @@ #endif #include +#include +#include +#include + #if defined(XMLTOOLING_LOG4SHIB) # include # include @@ -78,6 +82,8 @@ using namespace soap11; using namespace xmltooling::logging; using namespace xmltooling; using namespace xercesc; +using namespace boost::lambda; +using namespace boost; using namespace std; #ifdef WIN32 @@ -420,18 +426,13 @@ bool XMLToolingInternalConfig::init() // Load catalogs from path. if (!catalog_path.empty()) { - char* catpath=strdup(catalog_path.c_str()); - char* sep=nullptr; - char* start=catpath; - while (start && *start) { - sep=strchr(start,PATH_SEPARATOR_CHAR); - if (sep) - *sep=0; - auto_ptr_XMLCh temp(start); - m_validatingPool->loadCatalog(temp.get()); - start = sep ? sep + 1 : nullptr; - } - free(catpath); + vector catpaths; + split(catpaths, catalog_path, is_any_of(PATH_SEPARATOR_STR), algorithm::token_compress_on); + for_each( + catpaths.begin(), catpaths.end(), + // Call loadCatalog with an inner call to s->c_str() on each entry. + lambda::bind(static_cast(&ParserPool::loadCatalog), m_validatingPool, lambda::bind(&string::c_str,_1)) + ); } // default registrations @@ -651,7 +652,7 @@ bool XMLToolingInternalConfig::load_library(const char* path, void* context) throw runtime_error(string("detected error in xmltooling_extension_init: ") + resolved); SetErrorMode(em); } - catch(exception&) { + catch(std::exception&) { if (handle) FreeLibrary(handle); SetErrorMode(em); -- 2.1.4