diff options
author | Adrian Kummerländer | 2014-04-19 15:01:33 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-04-19 15:01:33 +0200 |
commit | 334efe3383c436d61a8e5dd95b923cb0d5db9652 (patch) | |
tree | 591f2ab70e64fef5e74077000cfb010365fc5ce9 /src/function/read_file.cc | |
parent | 6c205f4859588fc8dad786dce5f2fa32c75fd3f3 (diff) | |
download | InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.gz InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.bz2 InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.lz InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.xz InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.zst InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.zip |
Further code style fixes
* .. in the face of the planned development of usable external functions using the current proof-of-concept coding
* replaced usage of std::shared_ptr in FunctionReadXmlFile class with explicit implementation of default and copy constructor
* separated implementation and interfaces
Diffstat (limited to 'src/function/read_file.cc')
-rw-r--r-- | src/function/read_file.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/function/read_file.cc b/src/function/read_file.cc new file mode 100644 index 0000000..efc1f61 --- /dev/null +++ b/src/function/read_file.cc @@ -0,0 +1,49 @@ +#include "read_file.h" + +namespace InputXSLT { + +xalan::XObjectPtr FunctionReadFile::execute( + xalan::XPathExecutionContext& executionContext, + xalan::XalanNode* context, + const xalan::Function::XObjectArgVectorType& arguments, + const xalan::Locator* locator +) const { + if ( arguments.size() != 1 ) { + xalan::XPathExecutionContext::GetAndReleaseCachedString guard( + executionContext + ); + + generalError(executionContext, context, locator); + } + + xalan::CharVectorType fileNameVector; + std::string fileNameString; + + arguments[0]->str().transcode(fileNameVector); + + std::move( + fileNameVector.begin(), + fileNameVector.end(), + fileNameString.begin() + ); + + return executionContext.getXObjectFactory().createString( + xalan::XalanDOMString( + InputXSLT::readFile(fileNameString).data() + ) + ); +} + +FunctionReadFile* FunctionReadFile::clone( + xalan::MemoryManager& manager) const { + return xalan::XalanCopyConstruct(manager, *this); +} + +const xalan::XalanDOMString& FunctionReadFile::getError( + xalan::XalanDOMString& result) const { + result.assign("The read-file() function expects one argument."); + + return result; +} + +} |