aboutsummaryrefslogtreecommitdiff
path: root/src/function/execute.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-26 19:49:44 +0200
committerAdrian Kummerländer2014-05-26 19:49:44 +0200
commit86f8e73299e86b65affc1a71610dd061fa13bf5c (patch)
treee76856cd0f3b07638a4b73c7695014a39523f43a /src/function/execute.cc
parentc5a11763985172f54d0da8a2a2778f882f3656e5 (diff)
downloadInputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.tar
InputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.tar.gz
InputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.tar.bz2
InputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.tar.lz
InputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.tar.xz
InputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.tar.zst
InputXSLT-86f8e73299e86b65affc1a71610dd061fa13bf5c.zip
Revamped external execute function into a external text formatter function
* importing XML output of a called executable into the result document required special logic which clashed with a general execute function * general execute function may be implemented in the future ** support for external text formatters with XML output has a higher priority * current implementation enables calling a markdown parser and including the XHTML output into the document
Diffstat (limited to 'src/function/execute.cc')
-rw-r--r--src/function/execute.cc77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/function/execute.cc b/src/function/execute.cc
deleted file mode 100644
index f19ba75..0000000
--- a/src/function/execute.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "execute.h"
-
-#include <xercesc/dom/DOMDocument.hpp>
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/dom/DOMElement.hpp>
-
-#include <boost/process.hpp>
-
-#include "support/xerces_string_guard.h"
-#include "support/dom/result_node_facade.h"
-
-namespace InputXSLT {
-
-xercesc::DOMDocument* FunctionExecute::constructDocument(
- const InputXSLT::FilesystemContext&,
- const FunctionBase::parameter_tuple& parameters
-) {
- const std::string& executablePath(
- std::get<0>(parameters)
- );
-
- const std::string& stdinText(
- std::get<1>(parameters)
- );
-
- xercesc::DOMDocument* const domDocument(
- xercesc::DOMImplementation::getImplementation()->createDocument(
- nullptr,
- *XercesStringGuard<XMLCh>("content"),
- nullptr
- )
- );
-
- xercesc::DOMNode* const rootNode(
- domDocument->getDocumentElement()
- );
-
- boost::process::context context;
- context.stdout_behavior = boost::process::capture_stream();
- context.stdin_behavior = boost::process::capture_stream();
-
- boost::process::child process(
- boost::process::launch(
- executablePath,
- std::vector<std::string>{""},
- context
- )
- );
-
- boost::process::postream& inputStream = process.get_stdin();
- boost::process::pistream& outputStream = process.get_stdout();
-
- inputStream << stdinText;
- inputStream.close();
-
- const std::string resultText(
- (std::istreambuf_iterator<char>(outputStream)),
- (std::istreambuf_iterator<char>())
- );
-
- boost::process::status status = process.wait();
-
- if ( status.exited() ) {
- ResultNodeFacade result(domDocument, rootNode, "result");
-
- result.setValueNode("code", std::to_string(status.exit_status()));
- result.setValueNode("output", resultText);
- } else {
- ResultNodeFacade result(domDocument, rootNode, "error");
-
- result.setValueNode("code", std::to_string(status.exit_status()));
- }
-
- return domDocument;
-}
-
-}