diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd_line.cpp | 7 | ||||
-rw-r--r-- | src/handle.cpp | 18 | ||||
-rw-r--r-- | src/path.cpp | 3 | ||||
-rw-r--r-- | src/pipe.cpp | 19 | ||||
-rw-r--r-- | src/process.cpp | 52 | ||||
-rw-r--r-- | src/process_io.cpp | 77 | ||||
-rw-r--r-- | src/shmem.cpp | 17 |
7 files changed, 21 insertions, 172 deletions
diff --git a/src/cmd_line.cpp b/src/cmd_line.cpp index d2eeab5..3fc0a7e 100644 --- a/src/cmd_line.cpp +++ b/src/cmd_line.cpp @@ -9,7 +9,6 @@ #include <winapi/utils.hpp> #include <boost/algorithm/string.hpp> -#include <boost/config.hpp> // clang-format off #include <windows.h> @@ -87,11 +86,11 @@ CommandLine CommandLine::from_main(int argc, wchar_t* argv[]) { return CommandLine{narrow_all(argc, argv)}; } -CommandLine::CommandLine(const std::vector<std::string>& argv) : m_args(argv) { +CommandLine::CommandLine(const std::vector<std::string>& argv) : m_args{argv} { m_argv0 = split_argv0(m_args); } -CommandLine::CommandLine(std::vector<std::string>&& argv) : m_args(std::move(argv)) { +CommandLine::CommandLine(std::vector<std::string>&& argv) : m_args{std::move(argv)} { m_argv0 = split_argv0(m_args); } @@ -128,7 +127,7 @@ std::string CommandLine::escape(const std::string& arg) { } std::string CommandLine::escape_cmd(const std::string& arg) { - BOOST_STATIC_CONSTEXPR auto escape_symbol = '^'; + static constexpr auto escape_symbol = '^'; static const std::string dangerous_symbols{"^!\"%&()<>|"}; auto safe = escape(arg); diff --git a/src/handle.cpp b/src/handle.cpp index 66f878f..2260aa3 100644 --- a/src/handle.cpp +++ b/src/handle.cpp @@ -8,8 +8,6 @@ #include <winapi/handle.hpp> #include <winapi/utils.hpp> -#include <boost/config.hpp> - #include <windows.h> #include <cassert> @@ -36,21 +34,7 @@ bool is_std_handle(HANDLE handle) { } // namespace -Handle::Handle(HANDLE impl) : m_impl(impl) {} - -Handle::Handle(Handle&& other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); -} - -Handle& Handle::operator=(Handle other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); - return *this; -} - -void Handle::swap(Handle& other) BOOST_NOEXCEPT_OR_NOTHROW { - using std::swap; - swap(m_impl, other.m_impl); -} +Handle::Handle(HANDLE impl) : m_impl{impl} {} bool Handle::is_valid() const { return m_impl && is_valid(m_impl.get()); diff --git a/src/path.cpp b/src/path.cpp index 7848df2..409fc44 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -9,6 +9,7 @@ #include <windows.h> +#include <cstddef> #include <limits> #include <stdexcept> #include <string> @@ -18,7 +19,7 @@ namespace winapi { namespace { std::wstring do_canonicalize(const std::wstring& path) { - BOOST_STATIC_CONSTEXPR std::size_t init_buffer_size = MAX_PATH; + static constexpr std::size_t init_buffer_size = MAX_PATH; static_assert(init_buffer_size > 0, "init_buffer_size must be positive"); std::vector<wchar_t> buffer; diff --git a/src/pipe.cpp b/src/pipe.cpp index 299ab0f..d649657 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -7,8 +7,6 @@ #include <winapi/handle.hpp> #include <winapi/pipe.hpp> -#include <boost/config.hpp> - #include <windows.h> #include <cstring> @@ -26,7 +24,7 @@ void create_pipe(Handle& read_end, Handle& write_end) { attributes.nLength = sizeof(attributes); attributes.bInheritHandle = TRUE; - BOOST_STATIC_CONSTEXPR DWORD buffer_size = 16 * 1024; + static constexpr DWORD buffer_size = 16 * 1024; const auto ret = ::CreatePipe(&read_end_impl, &write_end_impl, &attributes, buffer_size); @@ -44,19 +42,4 @@ Pipe::Pipe() { create_pipe(m_read_end, m_write_end); } -Pipe::Pipe(Pipe&& other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); -} - -Pipe& Pipe::operator=(Pipe other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); - return *this; -} - -void Pipe::swap(Pipe& other) BOOST_NOEXCEPT_OR_NOTHROW { - using std::swap; - swap(m_read_end, other.m_read_end); - swap(m_write_end, other.m_write_end); -} - } // namespace winapi diff --git a/src/process.cpp b/src/process.cpp index 5e9ac13..9a602c8 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -11,8 +11,6 @@ #include <winapi/resource.hpp> #include <winapi/utf8.hpp> -#include <boost/config.hpp> - // clang-format off #include <windows.h> #include <shellapi.h> @@ -61,7 +59,7 @@ Handle create_process(ProcessParameters& params) { * * Another useful link is https://ikriv.com/dev/cpp/ConsoleProxy/flags. */ - BOOST_STATIC_CONSTEXPR DWORD default_dwCreationFlags = CREATE_UNICODE_ENVIRONMENT; + static constexpr DWORD default_dwCreationFlags = CREATE_UNICODE_ENVIRONMENT; STARTUPINFOW startup_info; std::memset(&startup_info, 0, sizeof(startup_info)); @@ -125,7 +123,7 @@ Handle shell_execute(const ShellParameters& params) { const auto lpFile = widen(params.cmd_line.get_argv0()); const auto lpParameters = widen(params.cmd_line.args_to_string()); - BOOST_STATIC_CONSTEXPR uint32_t default_fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI; + static constexpr uint32_t default_fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI; auto fMask = default_fMask; auto nShow = SW_SHOWDEFAULT; @@ -240,38 +238,6 @@ std::string get_exe_path(const Handle& process) { } // 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); -} - -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); -} - Process Process::create(ProcessParameters params) { return Process{create_process(params)}; } @@ -316,20 +282,6 @@ DWORD Process::read_permissions() { return default_permissions() | PROCESS_VM_READ; } -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); -} - bool Process::is_running() const { const auto ret = ::WaitForSingleObject(static_cast<HANDLE>(m_handle), 0); diff --git a/src/process_io.cpp b/src/process_io.cpp index e18558c..149081b 100644 --- a/src/process_io.cpp +++ b/src/process_io.cpp @@ -8,95 +8,42 @@ #include <winapi/path.hpp> #include <winapi/process_io.hpp> -#include <boost/config.hpp> - #include <string> #include <utility> namespace winapi { namespace process { -Stdin::Stdin() : Stream(Handle::std_in()) {} +Stdin::Stdin() : Stream{Handle::std_in()} {} -Stdout::Stdout() : Stream(Handle::std_out()) {} +Stdout::Stdout() : Stream{Handle::std_out()} {} -Stderr::Stderr() : Stream(Handle::std_err()) {} +Stderr::Stderr() : Stream{Handle::std_err()} {} -Stdin::Stdin(const std::string& path) : Stream(File::open_r(path)) {} +Stdin::Stdin(const std::string& path) : Stream{File::open_r(path)} {} -Stdin::Stdin(const CanonicalPath& path) : Stream(File::open_r(path)) {} +Stdin::Stdin(const CanonicalPath& path) : Stream{File::open_r(path)} {} -Stdout::Stdout(const std::string& path) : Stream(File::open_w(path)) {} +Stdout::Stdout(const std::string& path) : Stream{File::open_w(path)} {} -Stdout::Stdout(const CanonicalPath& path) : Stream(File::open_w(path)) {} +Stdout::Stdout(const CanonicalPath& path) : Stream{File::open_w(path)} {} -Stderr::Stderr(const std::string& path) : Stream(File::open_w(path)) {} +Stderr::Stderr(const std::string& path) : Stream{File::open_w(path)} {} -Stderr::Stderr(const CanonicalPath& path) : Stream(File::open_w(path)) {} +Stderr::Stderr(const CanonicalPath& path) : Stream{File::open_w(path)} {} -Stdin::Stdin(Pipe& pipe) : Stream(std::move(pipe.read_end())) { +Stdin::Stdin(Pipe& pipe) : Stream{std::move(pipe.read_end())} { pipe.write_end().dont_inherit(); } -Stdout::Stdout(Pipe& pipe) : Stream(std::move(pipe.write_end())) { +Stdout::Stdout(Pipe& pipe) : Stream{std::move(pipe.write_end())} { pipe.read_end().dont_inherit(); } -Stderr::Stderr(Pipe& pipe) : Stream(std::move(pipe.write_end())) { +Stderr::Stderr(Pipe& pipe) : Stream{std::move(pipe.write_end())} { pipe.read_end().dont_inherit(); } -Stream::Stream(Stream&& other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); -} - -Stream& Stream::operator=(Stream other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); - return *this; -} - -void Stream::swap(Stream& other) BOOST_NOEXCEPT_OR_NOTHROW { - using std::swap; - swap(handle, other.handle); -} - -Stdin::Stdin(Stdin&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream(std::move(other)) {} - -Stdin& Stdin::operator=(Stdin other) BOOST_NOEXCEPT_OR_NOTHROW { - Stream::operator=(std::move(other)); - return *this; -} - -Stdout::Stdout(Stdout&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream(std::move(other)) {} - -Stdout& Stdout::operator=(Stdout other) BOOST_NOEXCEPT_OR_NOTHROW { - Stream::operator=(std::move(other)); - return *this; -} - -Stderr::Stderr(Stderr&& other) BOOST_NOEXCEPT_OR_NOTHROW : Stream(std::move(other)) {} - -Stderr& Stderr::operator=(Stderr other) BOOST_NOEXCEPT_OR_NOTHROW { - Stream::operator=(std::move(other)); - return *this; -} - -IO::IO(IO&& other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); -} - -IO& IO::operator=(IO other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); - return *this; -} - -void IO::swap(IO& other) BOOST_NOEXCEPT_OR_NOTHROW { - using std::swap; - swap(std_in, other.std_in); - swap(std_out, other.std_out); - swap(std_err, other.std_err); -} - void IO::close() { std_in.handle.close(); std_out.handle.close(); diff --git a/src/shmem.cpp b/src/shmem.cpp index c1f3757..a636f4e 100644 --- a/src/shmem.cpp +++ b/src/shmem.cpp @@ -9,8 +9,6 @@ #include <winapi/utf8.hpp> #include <winapi/utils.hpp> -#include <boost/config.hpp> - #include <windows.h> #include <cstddef> @@ -70,19 +68,4 @@ SharedMemory SharedMemory::open(const std::string& name) { return {std::move(mapping), addr}; } -SharedMemory::SharedMemory(SharedMemory&& other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); -} - -SharedMemory& SharedMemory::operator=(SharedMemory other) BOOST_NOEXCEPT_OR_NOTHROW { - swap(other); - return *this; -} - -void SharedMemory::swap(SharedMemory& other) BOOST_NOEXCEPT_OR_NOTHROW { - using std::swap; - swap(m_handle, other.m_handle); - swap(m_addr, other.m_addr); -} - } // namespace winapi |