aboutsummaryrefslogtreecommitdiff
path: root/src/read_xml_file_command.h
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-18 22:19:46 +0200
committerAdrian Kummerländer2014-04-18 22:19:46 +0200
commit6c205f4859588fc8dad786dce5f2fa32c75fd3f3 (patch)
tree46a87960849f2b8ee53f74bf2c2de98c1a0da526 /src/read_xml_file_command.h
parent6dd832dd0adb35f63148a0e7bd5bdcfb28516c3b (diff)
downloadInputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.tar
InputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.tar.gz
InputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.tar.bz2
InputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.tar.lz
InputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.tar.xz
InputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.tar.zst
InputXSLT-6c205f4859588fc8dad786dce5f2fa32c75fd3f3.zip
Code style improvements
* marked assignment and equality operators as deleted instead of making them private * XercesParserLiaison is stored in a std::shared_ptr specialization instance for scope guarding * moved implementation details into InputXSLT namespace
Diffstat (limited to 'src/read_xml_file_command.h')
-rw-r--r--src/read_xml_file_command.h39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/read_xml_file_command.h b/src/read_xml_file_command.h
index 96b6c5d..8aee39f 100644
--- a/src/read_xml_file_command.h
+++ b/src/read_xml_file_command.h
@@ -8,17 +8,19 @@
#include "utility.h"
-namespace xalan = xalanc_1_11;
+#include <memory>
+
+namespace InputXSLT {
class FunctionReadXmlFile : public xalan::Function {
public:
virtual xalan::XObjectPtr execute(
- xalan::XPathExecutionContext& executionContext,
- xalan::XalanNode* context,
- const xalan::Function::XObjectArgVectorType& args,
- const xalan::Locator* locator
+ xalan::XPathExecutionContext& executionContext,
+ xalan::XalanNode* context,
+ const xalan::Function::XObjectArgVectorType& arguments,
+ const xalan::Locator* locator
) const {
- if ( args.size() != 1 ) {
+ if ( arguments.size() != 1 ) {
xalan::XPathExecutionContext::GetAndReleaseCachedString guard(
executionContext
);
@@ -26,14 +28,14 @@ class FunctionReadXmlFile : public xalan::Function {
generalError(executionContext, context, locator);
}
- if ( this->liaison == nullptr ) {
- const_cast<FunctionReadXmlFile*>(this)->liaison = new xalan::XercesParserLiaison();
+ if ( !this->parser_ ) {
+ this->parser_ = std::make_shared<xalan::XercesParserLiaison>();
}
- xalan::XSLTInputSource file(args[0]->str());
-
return executionContext.getXObjectFactory().createNodeSet(
- liaison->parseXMLStream(file)
+ this->parser_->parseXMLStream(
+ xalan::XSLTInputSource(arguments[0]->str())
+ )
);
}
@@ -41,17 +43,18 @@ class FunctionReadXmlFile : public xalan::Function {
return xalan::XalanCopyConstruct(manager, *this);
}
- protected:
- xalan::XercesParserLiaison* liaison = nullptr;
+ FunctionReadXmlFile& operator=(const FunctionReadXmlFile&) = delete;
+ bool operator==(const FunctionReadXmlFile&) const = delete;
+
+ private:
+ mutable std::shared_ptr<xalan::XercesParserLiaison> parser_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString& result) const {
- result.assign("The read-file() function expects one argument.");
+ result.assign("The read-xml-file() function expects one argument.");
return result;
}
- private:
- FunctionReadXmlFile& operator=(const FunctionReadXmlFile&);
- bool operator==(const FunctionReadXmlFile&) const;
-
};
+
+}