46 Arg(
int argc ,
char ** argv ) ;
58 void parse( HINSTANCE hinstance ,
const std::string & command_line_tail ) ;
63 void parse(
const std::string & command_line ) ;
67 void reparse(
const std::string & command_line_tail ) ;
72 static std::string
v0() ;
77 static std::string
exe(
bool do_throw =
true ) ;
83 std::size_t
c()
const ;
87 std::string
v( std::size_t i )
const ;
91 std::string
v( std::size_t i ,
const std::string & default_ )
const ;
94 std::string
prefix()
const ;
98 static const char *
prefix(
char ** argv ) noexcept ;
102 bool contains(
const std::string & option , std::size_t option_args = 0U ,
bool case_sensitive =
true )
const ;
109 std::size_t
count(
const std::string & option ) ;
113 std::size_t
index(
const std::string & option , std::size_t option_args = 0U ,
114 std::size_t default_ = 0U )
const ;
118 std::size_t
match(
const std::string &
prefix )
const ;
122 bool remove(
const std::string & option , std::size_t option_args = 0U ) ;
126 std::string
removeAt( std::size_t option_index , std::size_t option_args = 0U ) ;
135 std::size_t find(
bool ,
const std::string & , std::size_t , std::size_t * )
const ;
136 static bool strmatch(
bool ,
const std::string & ,
const std::string & ) ;
137 void parseImp(
const std::string & ) ;
141 static bool m_first ;
142 static std::string m_v0 ;
143 static std::string m_cwd ;
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 std::string exe(bool do_throw=true)
Returns Process::exe() or an absolute path constructed from v0() and possibly using the cwd.
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(const std::string &option, std::size_t option_args=0U, std::size_t default_=0U) const
Returns the index of the given option.
std::string removeAt(std::size_t option_index, std::size_t option_args=0U)
Removes the given argument and the following 'option_args' ones.
std::string prefix() const
Returns the basename of v(0) without any extension.
bool contains(const std::string &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 array(unsigned int shift=0U) const
Returns the arguments as a string array, with an optional shift.
bool remove(const std::string &option, std::size_t option_args=0U)
Removes the given option and its arguments.
void parse(HINSTANCE hinstance, const std::string &command_line_tail)
Parses the given command-line tail, splitting it up into an array of tokens.
static std::string v0()
Returns a copy of argv[0] from the first call to the constructor that takes argc/argv.
std::size_t count(const std::string &option)
Returns the number of times the given string appears in the list of arguments.
Arg()
Default constructor. Initialise with parse().
void reparse(const std::string &command_line_tail)
Reinitialises the object with the given command-line tail.
std::vector< std::string > StringArray
A std::vector of std::strings.