From def5c50960eea4c112647f88361a3ae7155901a8 Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Tue, 4 Jul 2023 00:48:00 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/wina?= =?UTF-8?q?pi-common@0c196cbe8b4927c78c02b2c7312fc69a507db845=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd__line_8hpp_source.html | 152 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 cmd__line_8hpp_source.html (limited to 'cmd__line_8hpp_source.html') diff --git a/cmd__line_8hpp_source.html b/cmd__line_8hpp_source.html new file mode 100644 index 0000000..0daf3a8 --- /dev/null +++ b/cmd__line_8hpp_source.html @@ -0,0 +1,152 @@ + + + + + + + +winapi_common: include/winapi/cmd_line.hpp Source File + + + + + + + + + +
+
+ + + + + + +
+
winapi_common +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
cmd_line.hpp
+
+
+
1 // Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+
2 // This file is part of the "winapi-common" project.
+
3 // For details, see https://github.com/egor-tensin/winapi-common.
+
4 // Distributed under the MIT License.
+
5 
+
6 #pragma once
+
7 
+
8 #include <string>
+
9 #include <utility>
+
10 #include <vector>
+
11 
+
12 namespace winapi {
+
13 
+
21 class CommandLine {
+
22 public:
+
24  static CommandLine query();
+
25 
+
30  static CommandLine parse(const std::string& src);
+
31 
+
37  static CommandLine from_main(int argc, wchar_t* argv[]);
+
38 
+
43  CommandLine() = default;
+
44 
+
50  explicit CommandLine(const std::string& argv0, const std::vector<std::string>& args = {})
+
51  : m_argv0{argv0}, m_args{args} {}
+
52 
+
58  explicit CommandLine(std::string&& argv0, std::vector<std::string>&& args = {})
+
59  : m_argv0{std::move(argv0)}, m_args{std::move(args)} {}
+
60 
+
65  explicit CommandLine(std::vector<std::string> argv);
+
66 
+
67  static std::string escape(const std::string&);
+
68 
+
69  static std::string escape_cmd(const std::string&);
+
70 
+
75  std::string to_string() const;
+
76 
+
81  std::string args_to_string() const;
+
82 
+
87  std::string get_argv0() const { return m_argv0; }
+
88 
+
90  bool has_args() const { return !get_args().empty(); }
+
91 
+
96  const std::vector<std::string>& get_args() const { return m_args; }
+
97 
+
102  std::vector<std::string> get_argv() const;
+
103 
+
104 private:
+
105  static constexpr char token_sep() { return ' '; }
+
106 
+
107  std::string escape_argv0() const { return escape(get_argv0()); }
+
108 
+
109  std::vector<std::string> escape_args() const;
+
110 
+
111  std::vector<std::string> escape_argv() const;
+
112 
+
113  std::string m_argv0;
+
114  std::vector<std::string> m_args;
+
115 };
+
116 
+
117 } // namespace winapi
+
Command line for the current process or for launching new processes.
Definition: cmd_line.hpp:21
+
static CommandLine from_main(int argc, wchar_t *argv[])
Definition: cmd_line.cpp:83
+
std::string get_argv0() const
Definition: cmd_line.hpp:87
+
CommandLine(const std::string &argv0, const std::vector< std::string > &args={})
Definition: cmd_line.hpp:50
+
static CommandLine query()
Definition: cmd_line.cpp:75
+
static CommandLine parse(const std::string &src)
Definition: cmd_line.cpp:79
+
CommandLine(std::string &&argv0, std::vector< std::string > &&args={})
Definition: cmd_line.hpp:58
+
std::vector< std::string > get_argv() const
Definition: cmd_line.cpp:146
+
std::string to_string() const
Definition: cmd_line.cpp:138
+ +
bool has_args() const
Definition: cmd_line.hpp:90
+
const std::vector< std::string > & get_args() const
Definition: cmd_line.hpp:96
+
std::string args_to_string() const
Definition: cmd_line.cpp:142
+
+ + + + -- cgit v1.2.3