add printing helper to pipestream status specification
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Thu, 4 Jan 2018 08:17:10 +0000 (09:17 +0100)
committerPhilipp Gesang <philipp.gesang@intra2net.com>
Tue, 14 Aug 2018 14:53:34 +0000 (16:53 +0200)
src/pipestream.hxx

index f283d87..4b645ef 100644 (file)
@@ -35,6 +35,8 @@ on this file might be covered by the GNU General Public License.
 #include <ostream>
 #include <vector>
 
+#include <stringfunc.hxx>
+
 struct ExecResult
 {
     /** if the program exited normally and returned a return code */
@@ -51,6 +53,17 @@ struct ExecResult
 
     /** errormessage if we have one */
     std::string error_message;
+
+    inline std::string format (void) const
+    {
+        return std::string ("(")
+            + "(normal_exit " + (this->normal_exit ? "T" : "F") + ") "
+              "(return_code '" + I2n::to_string ((int)this->return_code) + "') "
+              "(signal " + (this->terminated_by_signal
+                            ? strsignal (this->signal)
+                            : "<nil>") + "))"
+            ;
+    };
 };
 typedef struct ExecResult ExecResult;