aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/function')
-rw-r--r--src/function/external_text_formatter.cc17
-rw-r--r--src/function/read_directory.cc13
-rw-r--r--src/function/read_file.cc8
-rw-r--r--src/function/read_xml_file.cc9
-rw-r--r--src/function/transform.cc8
5 files changed, 36 insertions, 19 deletions
diff --git a/src/function/external_text_formatter.cc b/src/function/external_text_formatter.cc
index d1b9e92..22f53c5 100644
--- a/src/function/external_text_formatter.cc
+++ b/src/function/external_text_formatter.cc
@@ -86,17 +86,20 @@ xercesc::DOMDocument* FunctionExternalTextFormatter::constructDocument(
boost::process::status status = formatterProcess.wait();
- if ( status.exited() ) {
- ResultNodeFacade result(domDocument, rootNode, "result");
+ ResultNodeFacade result(domDocument, rootNode, "output");
+ result.setAttribute("formatter", formatterPath);
+ result.setAttribute("code", std::to_string(status.exit_status()));
- result.setValueNode("code", std::to_string(status.exit_status()));
- result.setContent(importDocumentElement(outputStream, domDocument));
+ if ( status.exited() ) {
+ result.setAttribute("result", "success");
+ result.setContent(
+ importDocumentElement(outputStream, domDocument)->getChildNodes()
+ );
} else {
- ResultNodeFacade result(domDocument, rootNode, "error");
-
- result.setValueNode("code", std::to_string(status.exit_status()));
+ result.setAttribute("result", "error");
}
+
return domDocument;
}
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index f4baff6..e54e146 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -29,11 +29,18 @@ xercesc::DOMDocument* FunctionReadDirectory::constructDocument(
domDocument->getDocumentElement()
);
+ ResultNodeFacade result(domDocument, rootNode, "directory");
+ result.setAttribute("path", directoryPath.string());
+
if ( boost::filesystem::is_directory(directoryPath) ) {
+ result.setAttribute("result", "success");
+
+ xercesc::DOMNode* const resultNode = result.getNode();
+
fsContext.iterate(
directoryPath,
- [&domDocument, &rootNode](const boost::filesystem::path& p) {
- ResultNodeFacade result(domDocument, rootNode, "result");
+ [&domDocument, &resultNode](const boost::filesystem::path& p) {
+ ResultNodeFacade result(domDocument, resultNode, "entry");
switch ( boost::filesystem::status(p).type() ) {
case boost::filesystem::regular_file: {
@@ -60,7 +67,7 @@ xercesc::DOMDocument* FunctionReadDirectory::constructDocument(
result.setValueNode("full", boost::filesystem::canonical(p).string());
});
} else {
- ResultNodeFacade result(domDocument, rootNode, "error");
+ result.setAttribute("result", "error");
}
return domDocument;
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index 87423ab..79e321d 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -50,13 +50,15 @@ xercesc::DOMDocument* FunctionReadFile::constructDocument(
domDocument->getDocumentElement()
);
+ ResultNodeFacade result(domDocument, rootNode, "file");
+ result.setAttribute("path", filePath.string());
+
if ( boost::filesystem::is_regular_file(filePath) ) {
- ResultNodeFacade result(domDocument, rootNode, "result");
+ result.setAttribute("result", "success");
- result.setAttribute("name", filePath.filename().string());
result.setContent(readFile(filePath));
} else {
- ResultNodeFacade result(domDocument, rootNode, "error");
+ result.setAttribute("result", "success");
}
return domDocument;
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index 6d0fd04..2fa4f13 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -60,16 +60,17 @@ xercesc::DOMDocument* FunctionReadXmlFile::constructDocument(
domDocument->getDocumentElement()
);
- if ( boost::filesystem::is_regular_file(filePath) ) {
- ResultNodeFacade result(domDocument, rootNode, "result");
+ ResultNodeFacade result(domDocument, rootNode, "file");
+ result.setAttribute("path", filePath.string());
- result.setAttribute("name", filePath.filename().string());
+ if ( boost::filesystem::is_regular_file(filePath) ) {
+ result.setAttribute("result", "success");
result.setContent(
importDocumentElement(filePath, domDocument)
);
} else {
- ResultNodeFacade result(domDocument, rootNode, "error");
+ result.setAttribute("result", "error");
}
return domDocument;
diff --git a/src/function/transform.cc b/src/function/transform.cc
index e952018..ab8c51c 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -38,8 +38,8 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
domDocument->getDocumentElement()
);
- ResultNodeFacade result(domDocument, rootNode, "result");
- result.setAttribute("name", targetPath);
+ ResultNodeFacade result(domDocument, rootNode, "transformation");
+ result.setAttribute("target", targetPath);
try {
InputXSLT::TransformationFacade transformation(
@@ -48,8 +48,12 @@ xercesc::DOMDocument* FunctionTransform::constructDocument(
);
transformation.generate(targetPath, parameterObject);
+
+ result.setAttribute("result", "success");
}
catch (const ErrorCapacitor::exception& exception) {
+ result.setAttribute("result", "error");
+
for ( auto&& error : *(exception.getCachedErrors()) ) {
result.setValueNode("error", error);
}