aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--include/winapi/process.hpp44
-rw-r--r--src/process.cpp58
-rw-r--r--test/unit_tests/shared/command.hpp8
-rw-r--r--test/unit_tests/shared/console.hpp4
4 files changed, 108 insertions, 6 deletions
diff --git a/include/winapi/process.hpp b/include/winapi/process.hpp
index 095b50c..3c9a840 100644
--- a/include/winapi/process.hpp
+++ b/include/winapi/process.hpp
@@ -29,11 +29,19 @@ struct ProcessParameters {
explicit ProcessParameters(const CommandLine& cmd_line) : cmd_line{cmd_line} {}
+ // VS 2013 won't generate these automatically.
+ ProcessParameters(ProcessParameters&&) BOOST_NOEXCEPT_OR_NOTHROW;
+ ProcessParameters& operator=(ProcessParameters) BOOST_NOEXCEPT_OR_NOTHROW;
+ void swap(ProcessParameters& other) BOOST_NOEXCEPT_OR_NOTHROW;
+ ProcessParameters(const ProcessParameters&) = delete;
+
CommandLine cmd_line;
boost::optional<process::IO> io;
ConsoleCreationMode console_mode = ConsoleNew;
};
+void swap(ProcessParameters&, ProcessParameters&) BOOST_NOEXCEPT_OR_NOTHROW;
+
struct ShellParameters : ProcessParameters {
explicit ShellParameters(const CommandLine& cmd_line) : ProcessParameters{cmd_line} {}
@@ -43,9 +51,17 @@ struct ShellParameters : ProcessParameters {
return params;
}
+ // VS 2013 won't generate these automatically.
+ ShellParameters(ShellParameters&&) BOOST_NOEXCEPT_OR_NOTHROW;
+ ShellParameters& operator=(ShellParameters) BOOST_NOEXCEPT_OR_NOTHROW;
+ void swap(ShellParameters& other) BOOST_NOEXCEPT_OR_NOTHROW;
+ ShellParameters(const ShellParameters&) = delete;
+
boost::optional<std::string> verb;
};
+void swap(ShellParameters&, ShellParameters&) BOOST_NOEXCEPT_OR_NOTHROW;
+
class Process {
public:
static Process create(ProcessParameters);
@@ -55,6 +71,12 @@ public:
static Process shell(const ShellParameters&);
static Process shell(const CommandLine&);
+ // VS 2013 won't generate these automatically.
+ Process(Process&&) BOOST_NOEXCEPT_OR_NOTHROW;
+ Process& operator=(Process) BOOST_NOEXCEPT_OR_NOTHROW;
+ void swap(Process& other) BOOST_NOEXCEPT_OR_NOTHROW;
+ Process(const Process&) = delete;
+
bool is_running() const;
void wait() const;
void terminate(int ec = 0) const;
@@ -74,4 +96,26 @@ private:
Handle m_handle;
};
+void swap(Process& a, Process& b) BOOST_NOEXCEPT_OR_NOTHROW;
+
} // namespace winapi
+
+namespace std {
+
+template <>
+inline void swap(winapi::ProcessParameters& a,
+ winapi::ProcessParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+template <>
+inline void swap(winapi::ShellParameters& a, winapi::ShellParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+template <>
+inline void swap(winapi::Process& a, winapi::Process& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+} // namespace std
diff --git a/src/process.cpp b/src/process.cpp
index 1eca85a..2fe6f4b 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -160,6 +160,64 @@ Handle shell_execute(const ShellParameters& params) {
} // namespace
+ProcessParameters::ProcessParameters(ProcessParameters&& other) BOOST_NOEXCEPT_OR_NOTHROW
+ : cmd_line{std::move(other.cmd_line)},
+ io{std::move(other.io)},
+ console_mode{std::move(other.console_mode)} {}
+
+ProcessParameters& ProcessParameters::operator=(ProcessParameters other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+ return *this;
+}
+
+void ProcessParameters::swap(ProcessParameters& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ using std::swap;
+ swap(cmd_line, other.cmd_line);
+ swap(io, other.io);
+ swap(console_mode, other.console_mode);
+}
+
+void swap(ProcessParameters& a, ProcessParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+ShellParameters::ShellParameters(ShellParameters&& other) BOOST_NOEXCEPT_OR_NOTHROW
+ : ProcessParameters{std::move(other)},
+ verb{std::move(verb)} {}
+
+ShellParameters& ShellParameters::operator=(ShellParameters other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+ return *this;
+}
+
+void ShellParameters::swap(ShellParameters& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ using std::swap;
+ ProcessParameters::swap(other);
+ swap(verb, other.verb);
+}
+
+void swap(ShellParameters& a, ShellParameters& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
+Process::Process(Process&& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+}
+
+Process& Process::operator=(Process other) BOOST_NOEXCEPT_OR_NOTHROW {
+ swap(other);
+ return *this;
+}
+
+void Process::swap(Process& other) BOOST_NOEXCEPT_OR_NOTHROW {
+ using std::swap;
+ swap(m_handle, other.m_handle);
+}
+
+void swap(Process& a, Process& b) BOOST_NOEXCEPT_OR_NOTHROW {
+ a.swap(b);
+}
+
Process Process::create(ProcessParameters params) {
return Process{create_process(params)};
}
diff --git a/test/unit_tests/shared/command.hpp b/test/unit_tests/shared/command.hpp
index 69c230f..266903f 100644
--- a/test/unit_tests/shared/command.hpp
+++ b/test/unit_tests/shared/command.hpp
@@ -29,14 +29,14 @@ struct StdHandles {
HANDLE err;
};
+BOOST_STATIC_CONSTEXPR auto COMMAND_SHMEM_NAME = "shmem-test-cmd";
+
class Command {
public:
- BOOST_STATIC_CONSTEXPR auto SHMEM_NAME = "shmem-test-cmd";
-
typedef winapi::SharedObject<Command> Shared;
- static Shared create() { return Shared::create(SHMEM_NAME); }
- static Shared open() { return Shared::open(SHMEM_NAME); }
+ static Shared create() { return Shared::create(COMMAND_SHMEM_NAME); }
+ static Shared open() { return Shared::open(COMMAND_SHMEM_NAME); }
typedef boost::interprocess::interprocess_mutex mutex;
typedef boost::interprocess::interprocess_condition condition_variable;
diff --git a/test/unit_tests/shared/console.hpp b/test/unit_tests/shared/console.hpp
index 0a415e5..faa887c 100644
--- a/test/unit_tests/shared/console.hpp
+++ b/test/unit_tests/shared/console.hpp
@@ -26,9 +26,9 @@ class Buffer {
public:
typedef CONSOLE_SCREEN_BUFFER_INFO Info;
- Buffer() : m_handle{winapi::Handle::std_out()}, m_info{get_info(m_handle)} {}
+ Buffer() : m_handle{winapi::Handle::std_out()}, m_info(get_info(m_handle)) {}
- Buffer(winapi::Handle&& handle) : m_handle{std::move(handle)}, m_info{get_info(m_handle)} {}
+ Buffer(winapi::Handle&& handle) : m_handle{std::move(handle)}, m_info(get_info(m_handle)) {}
std::size_t get_columns() const { return m_info.dwSize.X; }