aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-20 23:30:25 +0200
committerAdrian Kummerländer2014-04-20 23:30:25 +0200
commit5f4f3f003e1f08e5495e0fe30fae18eb6029888d (patch)
tree3ede7d6c8f0cb6887fdecf635cc4757d3d0ec9b5 /src
parentab840f41154f01d85fec769da693035149689c39 (diff)
downloadInputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.tar
InputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.tar.gz
InputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.tar.bz2
InputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.tar.lz
InputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.tar.xz
InputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.tar.zst
InputXSLT-5f4f3f003e1f08e5495e0fe30fae18eb6029888d.zip
Switched filesystem interaction code to boost::filesystem
* while plain read access on files is doesn't require boost::filesystem it will greatly simplify the implementation of external directory traversal functions * it also improves the portability of relative path construction
Diffstat (limited to 'src')
-rw-r--r--src/function/read_file.cc16
-rw-r--r--src/function/read_file.h6
-rw-r--r--src/function/read_xml_file.cc15
-rw-r--r--src/function/read_xml_file.h6
4 files changed, 25 insertions, 18 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index ea7a758..19ecfc8 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -1,5 +1,7 @@
#include "read_file.h"
+#include "boost/filesystem/fstream.hpp"
+
#include <fstream>
namespace InputXSLT {
@@ -24,24 +26,20 @@ xalan::XObjectPtr FunctionReadFile::execute(
xalan::CharVectorType castHelper;
arguments[0]->str().transcode(castHelper);
- std::string fileName(this->path_);
- fileName.reserve(fileName.size() + castHelper.size());
-
- std::move(
+ const std::string fileName(
castHelper.begin(),
- castHelper.end(),
- fileName.end()
+ castHelper.end()
);
- std::ifstream file(fileName);
+ boost::filesystem::ifstream file(this->path_ / fileName);
- std::string content(
+ const std::string fileContent(
(std::istreambuf_iterator<char>(file)),
(std::istreambuf_iterator<char>())
);
return executionContext.getXObjectFactory().createString(
- xalan::XalanDOMString(content.data())
+ xalan::XalanDOMString(fileContent.data())
);
}
diff --git a/src/function/read_file.h b/src/function/read_file.h
index f800c37..f5bdb9d 100644
--- a/src/function/read_file.h
+++ b/src/function/read_file.h
@@ -1,13 +1,13 @@
#ifndef INPUTXSLT_SRC_FUNCTION_READ_FILE_H_
#define INPUTXSLT_SRC_FUNCTION_READ_FILE_H_
-#include <xalanc/Include/PlatformDefinitions.hpp>
-#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
#include <xalanc/XPath/XObjectFactory.hpp>
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
+#include "boost/filesystem.hpp"
+
#include <string>
#include "common.h"
@@ -31,7 +31,7 @@ class FunctionReadFile : public xalan::Function {
bool operator==(const FunctionReadFile&) const = delete;
private:
- const std::string path_;
+ const boost::filesystem::path path_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index be091a0..78f81c4 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -1,5 +1,7 @@
#include "read_xml_file.h"
+#include "boost/filesystem/fstream.hpp"
+
namespace InputXSLT {
FunctionReadXmlFile::FunctionReadXmlFile(const std::string& path):
@@ -24,12 +26,19 @@ xalan::XObjectPtr FunctionReadXmlFile::execute(
generalError(executionContext, context, locator);
}
- xalan::XalanDOMString fileName(this->path_.data());
- fileName.append(arguments[0]->str());
+ xalan::CharVectorType castHelper;
+ arguments[0]->str().transcode(castHelper);
+
+ const std::string fileName(
+ castHelper.begin(),
+ castHelper.end()
+ );
+
+ boost::filesystem::ifstream file(this->path_ / fileName);
return executionContext.getXObjectFactory().createNodeSet(
this->parser_.parseXMLStream(
- xalan::XSLTInputSource(fileName)
+ xalan::XSLTInputSource(file)
)
);
}
diff --git a/src/function/read_xml_file.h b/src/function/read_xml_file.h
index c755852..6877feb 100644
--- a/src/function/read_xml_file.h
+++ b/src/function/read_xml_file.h
@@ -1,14 +1,14 @@
#ifndef INPUTXSLT_SRC_FUNCTION_READ_XML_FILE_H_
#define INPUTXSLT_SRC_FUNCTION_READ_XML_FILE_H_
-#include <xalanc/Include/PlatformDefinitions.hpp>
-#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>
#include <xalanc/XPath/XObjectFactory.hpp>
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
+#include "boost/filesystem.hpp"
+
#include <string>
#include "common.h"
@@ -33,7 +33,7 @@ class FunctionReadXmlFile : public xalan::Function {
bool operator==(const FunctionReadXmlFile&) const = delete;
private:
- const std::string path_;
+ const boost::filesystem::path path_;
mutable xalan::XercesParserLiaison parser_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString& result) const;