diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-16 23:43:11 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-10-16 23:43:11 +0300 |
commit | fe03b65c8bd952ac26a516e23f4c04bb014455e9 (patch) | |
tree | 6881a7039c95f502409623441b7b5e29bd02a3d4 /include/winapi | |
parent | some more process creation tests (diff) | |
download | winapi-common-fe03b65c8bd952ac26a516e23f4c04bb014455e9.tar.gz winapi-common-fe03b65c8bd952ac26a516e23f4c04bb014455e9.zip |
CommandLine: saner API
Diffstat (limited to 'include/winapi')
-rw-r--r-- | include/winapi/cmd_line.hpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/include/winapi/cmd_line.hpp b/include/winapi/cmd_line.hpp index 60bc56a..176cf3d 100644 --- a/include/winapi/cmd_line.hpp +++ b/include/winapi/cmd_line.hpp @@ -17,7 +17,9 @@ class CommandLine { public: static CommandLine query(); - static CommandLine build_from_main(int argc, wchar_t* argv[]); + static CommandLine parse(const std::string&); + + static CommandLine from_main(int argc, wchar_t* argv[]); CommandLine() = default; @@ -27,37 +29,29 @@ public: 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; } - - std::string escape_argv0() const { return escape(get_argv0()); } + static std::string escape(const std::string&); - bool has_args() const { return !get_args().empty(); } + static std::string escape_cmd(const std::string&); - const std::vector<std::string>& get_args() const { return args; } + std::string to_string() const; - std::vector<std::string> escape_args() const; + std::string args_to_string() const; - static BOOST_CONSTEXPR char sep() { return ' '; } + std::string get_argv0() const { return argv0; } - std::string join_args() const; + bool has_args() const { return !get_args().empty(); } - std::string join() const; + const std::vector<std::string>& get_args() const { return args; } private: - static CommandLine build_from_string(const std::string&); - - static CommandLine build_from_string(std::wstring); + static BOOST_CONSTEXPR char token_sep() { return ' '; } - static std::string escape_for_cmd(const std::string&); - - static std::string escape(const std::string&); + std::string escape_argv0() const { return escape(get_argv0()); } - CommandLine(std::vector<std::string>&& args) : args(std::move(args)) {} + std::vector<std::string> escape_args() const; - const std::string argv0; - const std::vector<std::string> args; + std::string argv0; + std::vector<std::string> args; }; } // namespace winapi |