add pipestream ctor overload for vectors of string
[libi2ncommon] / src / pipestream.hxx
index 6f83006..d13f312 100644 (file)
@@ -33,6 +33,7 @@ on this file might be covered by the GNU General Public License.
 #include <streambuf>
 #include <istream>
 #include <ostream>
+#include <vector>
 
 struct ExecResult
 {
@@ -55,6 +56,7 @@ typedef struct ExecResult ExecResult;
 
 std::string capture_exec(const std::string& command, ExecResult &rescode);
 std::string capture_exec(const char *const *command, ExecResult &rescode);
+std::string capture_exec(const std::vector<std::string>& command, ExecResult &rescode);
 
 inline std::string capture_exec (const std::string &command)
 {
@@ -68,6 +70,12 @@ inline std::string capture_exec(const char *const *command)
     return capture_exec(command,r);
 }
 
+inline std::string capture_exec(const std::vector<std::string>& command)
+{
+    ExecResult r;
+    return capture_exec(command,r);
+}
+
 /** @brief runs command and provides buffered input for it through pipe
  *
  * opens pipe to command using popen; exit status available after destruction
@@ -91,6 +99,7 @@ protected:
 public:
     inpipebuf(const std::string& command);
     inpipebuf(const char *const *command);
+    inpipebuf(const std::vector<std::string> &command);
 
     ~inpipebuf();
 
@@ -117,6 +126,10 @@ public:
             : std::istream(&buf), buf(command)
     {}
 
+    inpipestream(const std::vector<std::string> &command)
+            : std::istream(&buf), buf(command)
+    {}
+
     void store_exit_status(bool *_status_set, int *_exit_status)
     { buf.store_exit_status(_status_set, _exit_status); }
 };