From 6c205f4859588fc8dad786dce5f2fa32c75fd3f3 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Fri, 18 Apr 2014 22:19:46 +0200 Subject: 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 --- src/read_xml_file_command.h | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/read_xml_file_command.h') 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 + +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(this)->liaison = new xalan::XercesParserLiaison(); + if ( !this->parser_ ) { + this->parser_ = std::make_shared(); } - 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 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; - }; + +} -- cgit v1.2.3