52 Arg(
int argc ,
char ** argv ) ;
61 explicit Arg(
const std::string & full_command_line ) ;
64 Arg(
const Path &
exe ,
const std::string & command_line_tail ) ;
83 static Path exe( std::nothrow_t ) ;
88 std::size_t
c()
const ;
92 std::string
v( std::size_t i )
const ;
96 std::string
v( std::size_t i ,
const std::string & default_ )
const ;
99 std::string
prefix()
const ;
103 static const char *
prefix(
char ** argv ) noexcept ;
107 bool contains( std::string_view option , std::size_t option_args = 0U ,
bool case_sensitive =
true )
const ;
114 std::size_t
count( std::string_view option )
const ;
118 std::size_t
index( std::string_view option , std::size_t option_args = 0U ,
119 std::size_t default_ = 0U )
const ;
123 std::size_t
match(
const std::string &
prefix )
const ;
127 bool remove( std::string_view option , std::size_t option_args = 0U ) ;
131 std::string
removeValue( std::string_view option ,
const std::string & default_ = {} ) ;
135 std::string
removeAt( std::size_t option_index , std::size_t option_args = 0U ) ;
144 StringArray::const_iterator
cbegin()
const ;
147 StringArray::const_iterator
cend()
const ;
152 explicit Arg( Windows ) ;
153 std::size_t find(
bool , std::string_view , std::size_t , std::size_t * )
const ;
154 static bool strmatch(
bool , std::string_view , std::string_view ) ;
155 void parseImp(
const std::string & ) ;
156 static Path exeImp(
bool do_throw ) ;
157 void osinit(
int ,
char ** ) ;
158 void split(
const std::string & ) ;
169 parseImp( nowide::getCommandLine() ) ;
175 inline G::StringArray::const_iterator begin(
const G::Arg & arg ) {
return arg.
cbegin() ; }
176 inline G::StringArray::const_iterator end(
const G::Arg & arg ) {
return arg.
cend() ; }
A class which holds a represention of the argc/argv command line array, and supports simple command-l...
std::size_t c() const
Returns the number of tokens in the command line, including the program name.
static Arg windows()
Factory function for Windows using GetCommandLineW().
std::size_t match(const std::string &prefix) const
Returns the index of the first argument that matches the given prefix.
std::string v(std::size_t i) const
Returns the i'th argument.
std::size_t index(std::string_view option, std::size_t option_args=0U, std::size_t default_=0U) const
Returns the index of the given option.
Arg(int argc, char **argv)
Constructor taking argc/argv directly from main().
std::size_t count(std::string_view option) const
Returns the number of times the given string appears in the list of arguments.
std::string removeAt(std::size_t option_index, std::size_t option_args=0U)
Removes the given argument and the following 'option_args' ones.
StringArray::const_iterator cend() const
Returns the end iterator.
std::string prefix() const
Returns the basename of v(0) without any extension.
std::string removeValue(std::string_view option, const std::string &default_={})
Removes the given single-valued option and its value.
StringArray array(unsigned int shift=0U) const
Returns the arguments as a string array, with an optional shift.
bool remove(std::string_view option, std::size_t option_args=0U)
Removes the given option and its arguments.
static Path exe()
Returns Process::exe() or in exceptional circumstances an absolute path constructed from v0() and the...
bool contains(std::string_view option, std::size_t option_args=0U, bool case_sensitive=true) const
Returns true if the command line contains the given option with enough command line arguments left to...
StringArray::const_iterator cbegin() const
Returns a begin iterator, advanced to exclude argv0.
static Path v0()
Returns a copy of argv[0] from the first call to the argc/argv constructor overload or windows().
A Path object represents a file system path.
Contains inline functions that convert to and from UTF-8 strings in order to call wide-character "W()...
std::vector< std::string > StringArray
A std::vector of std::strings.