46 typedef size_t size_type ;
48 Arg(
int argc ,
char * argv [] ) ;
60 void parse( HINSTANCE hinstance ,
const std::string & command_line_tail ) ;
65 void parse(
const std::string & command_line ) ;
69 void reparse(
const std::string & command_line_tail ) ;
77 static std::string
v0() ;
82 static std::string
exe(
bool do_throw =
true ) ;
91 std::string
v( size_type i )
const ;
95 std::string
prefix()
const ;
99 static const char *
prefix(
char * argv[] ) ;
103 bool contains(
const std::string & option , size_type option_args = 0U ,
bool case_sensitive =
true )
const ;
110 size_type
index(
const std::string & option , size_type option_args = 0U )
const ;
113 bool remove(
const std::string & option , size_type option_args = 0U ) ;
117 void removeAt( size_type option_index , size_type option_args = 0U ) ;
131 bool find(
bool ,
const std::string & , size_type , size_type * )
const ;
134 static bool match(
bool ,
const std::string & ,
const std::string & ) ;
135 void parseCore(
const std::string & ) ;
136 static void protect( std::string & ) ;
142 static bool m_first ;
143 static std::string m_v0 ;
144 static std::string m_cwd ;
std::string prefix() const
Returns the basename of v(0) without any extension.
std::vector< std::string > StringArray
A std::vector of std::strings.
Arg()
Default constructor. Initialise with parse().
static std::string exe(bool do_throw=true)
Returns Process::exe() or an absolute path constructed from v0().
Arg & operator=(const Arg &)
Assignment operator.
StringArray array(unsigned int shift=0U) const
Returns the arguments a string array, including the program name in the first position.
std::string v(size_type i) const
Returns the i'th argument.
void reparse(const std::string &command_line_tail)
Reinitialises the object with the given command-line tail.
size_type c() const
Returns the number of tokens in the command line, including the program name.
void parse(HINSTANCE hinstance, const std::string &command_line_tail)
Parses the given command-line tail, splitting it up into an array of tokens.
size_type index(const std::string &option, size_type option_args=0U) const
Returns the index of the given option. Returns zero if not present.
A class which holds a represention of the argc/argv command line array, and supports simple command-l...
void removeAt(size_type option_index, size_type option_args=0U)
Removes the given argument and the following 'option_args' ones.
bool contains(const std::string &option, size_type 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...
static std::string v0()
Returns a copy of argv[0] from the first call to the constructor that takes argc/argv.