]> Dogcows Code - chaz/yoink/blobdiff - src/stlplus/portability/subprocesses.hpp
import stlplus 3.7
[chaz/yoink] / src / stlplus / portability / subprocesses.hpp
index 0369daad40b6b5c645c52e4533968ab5a54772bd..c60aa5ee5c702f84a43e9585482400bea52b09e7 100644 (file)
@@ -4,9 +4,9 @@
 \r
 //   Author:    Andy Rushton\r
 //   Copyright: (c) Southampton University 1999-2004\r
-//              (c) Andy Rushton           2004-2009\r
+//              (c) Andy Rushton           2004 onwards\r
 //   License:   BSD License, see ../docs/license.html\r
-  \r
+\r
 //   Platform-independent wrapper around the very platform-specific handling of\r
 //   subprocesses. Uses the C++ convention that all resources must be contained in\r
 //   an object so that when a subprocess object goes out of scope the subprocess\r
@@ -102,11 +102,17 @@ namespace stlplus
 #else\r
 #define ENVIRON_TYPE char**\r
 #endif\r
+  class subprocess;\r
+  class async_subprocess;\r
 \r
   class env_vector\r
   {\r
   private:\r
     ENVIRON_TYPE m_env;\r
+    friend class subprocess;\r
+    friend class async_subprocess;\r
+    // access the env_vector as an envp type - used for passing to subprocesses\r
+    ENVIRON_TYPE envp (void) const;\r
 \r
   public:\r
     // create an env_vector vector from the current process\r
@@ -116,16 +122,16 @@ namespace stlplus
 \r
     env_vector& operator = (const env_vector&);\r
 \r
-    void clear (void);\r
-\r
     // manipulate the env_vector by adding or removing variables\r
     // adding a name that already exists replaces its value\r
     void add (const std::string& name, const std::string& value);\r
     bool remove (const std::string& name);\r
+    void clear (void);\r
 \r
     // get the value associated with a name\r
     // the first uses an indexed notation (e.g. env["PATH"] )\r
     // the second is a function based form (e.g. env.get("PATH"))\r
+    bool present(const std::string& name) const;\r
     std::string operator [] (const std::string& name) const;\r
     std::string get (const std::string& name) const;\r
 \r
@@ -135,9 +141,6 @@ namespace stlplus
     // get the name=value pairs by index (in the range 0 to size()-1)\r
     std::pair<std::string,std::string> operator [] (unsigned index) const throw(std::out_of_range);\r
     std::pair<std::string,std::string> get (unsigned index) const throw(std::out_of_range);\r
-\r
-    // access the env_vector as an envp type - used for passing to subprocesses\r
-    ENVIRON_TYPE envp (void) const;\r
   };\r
 \r
   ////////////////////////////////////////////////////////////////////////////////\r
@@ -155,7 +158,7 @@ namespace stlplus
 \r
   class subprocess\r
   {\r
-  private:\r
+  protected:\r
 \r
     PID_TYPE m_pid;\r
 #ifdef MSWINDOWS\r
@@ -167,6 +170,7 @@ namespace stlplus
     env_vector m_env;\r
     int m_err;\r
     int m_status;\r
+    void set_error(int);\r
 \r
   public:\r
     subprocess(void);\r
@@ -174,6 +178,7 @@ namespace stlplus
 \r
     void add_variable(const std::string& name, const std::string& value);\r
     bool remove_variable(const std::string& name);\r
+    const env_vector& get_variables(void) const;\r
 \r
     bool spawn(const std::string& path, const arg_vector& argv,\r
                bool connect_stdin = false, bool connect_stdout = false, bool connect_stderr = false);\r
@@ -208,7 +213,7 @@ namespace stlplus
 \r
   class backtick_subprocess : public subprocess\r
   {\r
-  private:\r
+  protected:\r
     std::string m_text;\r
   public:\r
     backtick_subprocess(void);\r
@@ -226,7 +231,7 @@ namespace stlplus
 \r
   class async_subprocess\r
   {\r
-  private:\r
+  protected:\r
     PID_TYPE m_pid;\r
 #ifdef MSWINDOWS\r
     HANDLE m_job;\r
@@ -245,6 +250,7 @@ namespace stlplus
 \r
     void add_variable(const std::string& name, const std::string& value);\r
     bool remove_variable(const std::string& name);\r
+    const env_vector& get_variables(void) const;\r
 \r
     bool spawn(const std::string& path, const arg_vector& argv,\r
                bool connect_stdin = false, bool connect_stdout = false, bool connect_stderr = false);\r
This page took 0.021753 seconds and 4 git commands to generate.