aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/winapi/cmd_line.hpp9
-rw-r--r--include/winapi/error.hpp9
-rw-r--r--include/winapi/process.hpp25
3 files changed, 40 insertions, 3 deletions
diff --git a/include/winapi/cmd_line.hpp b/include/winapi/cmd_line.hpp
index ac88286..60bc56a 100644
--- a/include/winapi/cmd_line.hpp
+++ b/include/winapi/cmd_line.hpp
@@ -21,6 +21,12 @@ public:
CommandLine() = default;
+ CommandLine(const std::string& argv0, const std::vector<std::string>& args = {})
+ : argv0(argv0), args(args) {}
+
+ CommandLine(std::string&& argv0, std::vector<std::string>&& args = {})
+ : argv0(std::move(argv0)), args(std::move(args)) {}
+
bool has_argv0() const { return !argv0.empty(); }
std::string get_argv0() const { return argv0; }
@@ -50,9 +56,6 @@ private:
CommandLine(std::vector<std::string>&& args) : args(std::move(args)) {}
- CommandLine(std::string&& argv0, std::vector<std::string>&& args = {})
- : argv0(std::move(argv0)), args(std::move(args)) {}
-
const std::string argv0;
const std::vector<std::string> args;
};
diff --git a/include/winapi/error.hpp b/include/winapi/error.hpp
index 4b3f1e0..89bcfed 100644
--- a/include/winapi/error.hpp
+++ b/include/winapi/error.hpp
@@ -9,6 +9,8 @@
#include <windows.h>
+#include <sstream>
+#include <stdexcept>
#include <string>
#include <system_error>
@@ -31,5 +33,12 @@ inline const CategoryWindows& category_windows() {
std::system_error windows(DWORD code, const char* function);
+template <typename Ret>
+std::runtime_error custom(Ret ret, const char* function) {
+ std::ostringstream oss;
+ oss << "Function " << function << " failed with error code " << ret;
+ return std::runtime_error{oss.str()};
+}
+
} // namespace error
} // namespace winapi
diff --git a/include/winapi/process.hpp b/include/winapi/process.hpp
new file mode 100644
index 0000000..d20ac38
--- /dev/null
+++ b/include/winapi/process.hpp
@@ -0,0 +1,25 @@
+// Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+// This file is part of the "winapi-common" project.
+// For details, see https://github.com/egor-tensin/winapi-common.
+// Distributed under the MIT License.
+
+#include "cmd_line.hpp"
+#include "handle.hpp"
+
+#include <utility>
+
+namespace winapi {
+
+class Process {
+public:
+ static Process create(const CommandLine&);
+
+ void wait();
+
+private:
+ explicit Process(Handle&& handle) : m_handle{std::move(handle)} {}
+
+ Handle m_handle;
+};
+
+} // namespace winapi