From 5fbca0993146982ab1dbb0d352c1e15e40b3de22 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Wed, 14 May 2014 20:55:51 +0200 Subject: Moved responsibility for argument conversion to FunctionBase descendants * external functions may expect arguments with a type different from boost::filesystem::path so they are only provided raw string values * moved xalan string conversion logic into separate compilation unit --- src/support/filesystem_context.cc | 19 +++---------------- src/support/xalan_string.cc | 19 +++++++++++++++++++ src/support/xalan_string.h | 17 +++++++++++++++++ 3 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 src/support/xalan_string.cc create mode 100644 src/support/xalan_string.h (limited to 'src/support') diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc index 30502b3..8395046 100644 --- a/src/support/filesystem_context.cc +++ b/src/support/filesystem_context.cc @@ -3,22 +3,9 @@ #include #include +#include "support/xalan_string.h" #include "support/xerces_string_guard.h" -namespace { - -inline std::string xalanToString(const xalan::XalanDOMString& text) { - xalan::CharVectorType castHelper; - text.transcode(castHelper); - - return std::string( - castHelper.begin(), - castHelper.end() - 1 - ); -} - -} - namespace InputXSLT { FilesystemContext::FilesystemContext(const xalan::Locator* locator): @@ -38,7 +25,7 @@ boost::filesystem::path FilesystemContext::resolve( boost::filesystem::path FilesystemContext::resolve( const xalan::XalanDOMString& path) const { - return this->resolve(xalanToString(path)); + return this->resolve(toString(path)); } void FilesystemContext::iterate( @@ -78,7 +65,7 @@ void FilesystemContext::iterate( const xalan::XalanDOMString& path, std::function func ) const { - this->iterate(xalanToString(path), func); + this->iterate(toString(path), func); } } diff --git a/src/support/xalan_string.cc b/src/support/xalan_string.cc new file mode 100644 index 0000000..b89f08b --- /dev/null +++ b/src/support/xalan_string.cc @@ -0,0 +1,19 @@ +#include "xalan_string.h" + +namespace InputXSLT { + +std::string toString(const xalan::XalanDOMString& text) { + xalan::CharVectorType castHelper; + text.transcode(castHelper); + + return std::string( + castHelper.begin(), + castHelper.end() - 1 + ); +} + +xalan::XalanDOMString toString(const std::string& text) { + return xalan::XalanDOMString(text.data()); +} + +} diff --git a/src/support/xalan_string.h b/src/support/xalan_string.h new file mode 100644 index 0000000..2220be5 --- /dev/null +++ b/src/support/xalan_string.h @@ -0,0 +1,17 @@ +#ifndef INPUTXSLT_SRC_SUPPORT_XALAN_STRING_H_ +#define INPUTXSLT_SRC_SUPPORT_XALAN_STRING_H_ + +#include + +#include + +#include "common.h" + +namespace InputXSLT { + +std::string toString(const xalan::XalanDOMString&); +xalan::XalanDOMString toString(const std::string&); + +} + +#endif // INPUTXSLT_SRC_SUPPORT_XALAN_STRING_H_ -- cgit v1.2.3