From 0d670478b51c55e44f57995fe3ca8a4585723a6c Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 17 Jun 2014 21:28:04 +0200 Subject: Added context awareness to XObjectValue casting logic * added support for defining boost::filesystem::path as a external function parameter ** boost::filesystem::path parameters are resolved against the appropriate FilesystemContext and IncludeEntityResolver instances * xalan::XSLTInputSource parameter source paths are also resolved * removed need for passing a reference FilesystemContext to "constructDocument" methods ** they now only accept the parameters of the external function implemented by them ** all path resolution logic is wrapped by the newly created XObjectValue class * converted XObjectValue namespace into class ** the "get" template method is now a template member method ** this was needed to enable value casting logic to access the appropriate FilesystemContext and IncludeEntityResolver instances * this commit marks the next step towards the goals defined in 741a70f --- src/support/filesystem_context.cc | 63 ++++++++++++++------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) (limited to 'src/support/filesystem_context.cc') diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc index a18ec43..21548a5 100644 --- a/src/support/filesystem_context.cc +++ b/src/support/filesystem_context.cc @@ -4,52 +4,13 @@ #include #include "support/xalan_string.h" -#include "support/xerces_string_guard.h" namespace InputXSLT { -FilesystemContext::FilesystemContext(const boost::filesystem::path& path): - path_(boost::filesystem::canonical( - path.parent_path() - )) { } - -FilesystemContext::FilesystemContext(const std::string& path): - path_(boost::filesystem::canonical(path)) { } - -boost::filesystem::path FilesystemContext::resolve( - const std::string& path) const { - const boost::filesystem::path targetPath(path); - - if ( targetPath.is_absolute() ) { - return targetPath; - } else { - return absolute(this->path_ / targetPath); - } -} - -boost::filesystem::path FilesystemContext::resolve( - const xalan::XalanDOMString& path) const { - return this->resolve(toString(path)); -} - -void FilesystemContext::iterate( - const std::string& path, - const std::function& func -) const { - this->iterate(this->resolve(path), func); -} - -void FilesystemContext::iterate( - const xalan::XalanDOMString& path, - const std::function& func -) const { - this->iterate(toString(path), func); -} - void FilesystemContext::iterate( const boost::filesystem::path& directory, const std::function& func -) const { +) { std::vector directoryItems; std::copy_if( @@ -74,4 +35,26 @@ void FilesystemContext::iterate( ); } +FilesystemContext::FilesystemContext(const boost::filesystem::path& path): + path_(boost::filesystem::canonical( + path.parent_path() + )) { } + +FilesystemContext::FilesystemContext(const std::string& path): + path_(boost::filesystem::canonical(path)) { } + +boost::filesystem::path FilesystemContext::resolve( + const xalan::XalanDOMString& path) const { + return this->resolve(toString(path)); +} + +boost::filesystem::path FilesystemContext::resolve( + const boost::filesystem::path& path) const { + if ( path.is_absolute() ) { + return path; + } else { + return absolute(this->path_ / path); + } +} + } -- cgit v1.2.3