1
2
3
4
5
6 #ifndef SOULNG_UTIL_PROCESS_IMPL_INCLUDED
7 #define SOULNG_UTIL_PROCESS_IMPL_INCLUDED
8 #include <soulng/util/Process.hpp>
9 #if defined(_WIN32) && defined(__MINGW32__)
10 #ifndef __kernel_entry
11 #define __kernel_entry
12 #endif
13 #endif
14 #include <boost/process.hpp>
15 #include <string>
16
17 namespace soulng { namespace util {
18
19 class ProcessImpl
20 {
21 public:
22 ProcessImpl(const std::string& command, Process::Redirections redirections_);
23 ProcessImpl(const ProcessImpl&) = delete;
24 ProcessImpl& operator=(const ProcessImpl&) = delete;
25 ProcessImpl(ProcessImpl&&) = delete;
26 ProcessImpl& operator=(ProcessImpl&&) = delete;
27 bool Running();
28 void WaitForExit();
29 int ExitCode() const;
30 void Terminate();
31 bool Eof(Process::StdHandle handle);
32 std::string ReadLine(Process::StdHandle handle);
33 std::string ReadToEnd(Process::StdHandle handle);
34 void WriteLine(const std::string& line);
35 private:
36 Process::Redirections redirections;
37 boost::process::ipstream processStdOut;
38 boost::process::ipstream processStdErr;
39 boost::process::opstream processStdIn;
40 boost::process::child process;
41 bool stdOutEof;
42 bool stdErrEof;
43 };
44
45 } }
46
47 #endif // SOULNG_UTIL_PROCESS_IMPL_INCLUDED