diff options
Diffstat (limited to 'src/support')
-rw-r--r-- | src/support/filesystem_context.cc | 24 | ||||
-rw-r--r-- | src/support/filesystem_context.h | 28 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc new file mode 100644 index 0000000..d3f9614 --- /dev/null +++ b/src/support/filesystem_context.cc @@ -0,0 +1,24 @@ +#include "filesystem_context.h" + +namespace InputXSLT { + +FilesystemContext::FilesystemContext(const std::string& path): + path_(path) { } + +boost::filesystem::path FilesystemContext::resolve( + const std::string& path) const { + return boost::filesystem::path(this->path_ / path); +} + +boost::filesystem::path FilesystemContext::resolve( + const xalan::XalanDOMString& path) const { + xalan::CharVectorType castHelper; + path.transcode(castHelper); + + return this->resolve(std::string( + castHelper.begin(), + castHelper.end() + )); +} + +} diff --git a/src/support/filesystem_context.h b/src/support/filesystem_context.h new file mode 100644 index 0000000..d5836f1 --- /dev/null +++ b/src/support/filesystem_context.h @@ -0,0 +1,28 @@ +#ifndef INPUTXSLT_SRC_SUPPORT_FILESYSTEM_CONTEXT_H_ +#define INPUTXSLT_SRC_SUPPORT_FILESYSTEM_CONTEXT_H_ + +#include <xalanc/XalanDOM/XalanDOMString.hpp> + +#include "boost/filesystem.hpp" + +#include <string> + +#include "common.h" + +namespace InputXSLT { + +class FilesystemContext { + public: + explicit FilesystemContext(const std::string&); + + boost::filesystem::path resolve(const std::string&) const; + boost::filesystem::path resolve(const xalan::XalanDOMString&) const; + + private: + const boost::filesystem::path path_; + +}; + +} + +#endif // INPUTXSLT_SRC_SUPPORT_FILESYSTEM_CONTEXT_H_ |