winapi_common
|
Command line for the current process or for launching new processes. More...
Public Member Functions | |
CommandLine ()=default | |
CommandLine (const std::string &argv0, const std::vector< std::string > &args={}) | |
CommandLine (std::string &&argv0, std::vector< std::string > &&args={}) | |
CommandLine (std::vector< std::string > argv) | |
std::string | to_string () const |
std::string | args_to_string () const |
std::string | get_argv0 () const |
bool | has_args () const |
const std::vector< std::string > & | get_args () const |
std::vector< std::string > | get_argv () const |
Static Public Member Functions | |
static CommandLine | query () |
static CommandLine | parse (const std::string &src) |
static CommandLine | from_main (int argc, wchar_t *argv[]) |
static std::string | escape (const std::string &) |
static std::string | escape_cmd (const std::string &) |
Command line for the current process or for launching new processes.
This class takes care of proper parsing and stringifying command line arguments so that they are safe to use with CreateProcess, ShellExecute, etc.
Definition at line 21 of file cmd_line.hpp.
|
default |
Build an empty command line. It won't have neither argv[0], nor any other args.
|
inlineexplicit |
Build a command line.
argv0 | UTF-8 string, argv[0]. |
args | List of UTF-8 strings, other arguments. |
Definition at line 50 of file cmd_line.hpp.
|
inlineexplicit |
Build a command line.
argv0 | UTF-8 string, argv[0]. |
args | List of UTF-8 strings, other arguments. |
Definition at line 58 of file cmd_line.hpp.
|
explicit |
Build a command line.
argv | List of UTF-8 strings, including argv[0]. |
Definition at line 89 of file cmd_line.cpp.
|
static |
Get the command line used to launch this process.
Definition at line 75 of file cmd_line.cpp.
|
static |
Parse a command line from a string.
src | UTF-8 encoded string. |
Definition at line 79 of file cmd_line.cpp.
|
static |
Build a command line from main() arguments.
argc | Length of the argv array. |
argv | UTF-16 encoded strings. |
Definition at line 83 of file cmd_line.cpp.
std::string winapi::CommandLine::to_string | ( | ) | const |
Build a string that represents this command line.
Definition at line 138 of file cmd_line.cpp.
std::string winapi::CommandLine::args_to_string | ( | ) | const |
Build a string that represents this command line, but omit argv[0].
Definition at line 142 of file cmd_line.cpp.
|
inline |
|
inline |
Test if this command line has any additional arguments besides argv[0].
Definition at line 90 of file cmd_line.hpp.
|
inline |
Get list of arguments for this command line beyond argv[0].
Definition at line 96 of file cmd_line.hpp.
std::vector< std::string > winapi::CommandLine::get_argv | ( | ) | const |
Get list of arguments for this command line.
Definition at line 146 of file cmd_line.cpp.