1 #ifndef _theplu_yat_utility_commandline_ 2 #define _theplu_yat_utility_commandline_ 106 CommandLine(std::string str=
"Available options are:");
131 const std::vector<std::string>&
free_args(
void)
const;
143 void parse(
int argc,
char* argv[]);
180 template<
class Compare>
181 void sort(Compare compare);
190 friend std::ostream& operator<<(std::ostream& os,
const CommandLine& cl);
191 bool is_long_option(std::string str)
const;
192 bool is_short_option(std::string str)
const;
193 void parse(std::vector<std::string>::iterator& first,
194 std::vector<std::string>::iterator& last);
195 void parse_long(std::vector<std::string>::iterator& first,
196 std::vector<std::string>::iterator& last);
197 void parse_short(std::vector<std::string>::iterator& first,
198 std::vector<std::string>::iterator& last);
199 void parse_free_arg(std::vector<std::string>::iterator& first,
200 std::vector<std::string>::iterator& last);
201 std::string description_;
202 std::vector<std::string> free_arg_;
203 size_t free_arg_max_;
204 std::vector<Option*> options_;
205 std::map<char, Option*> short_options_;
206 std::map<std::string, Option*> long_options_;
208 std::string program_name_;
238 std::ostream& operator<<(std::ostream&,
const CommandLine&);
240 template<
class Compare>
243 std::sort(options_.begin(), options_.end(), compare);
std::string program_name(void) const
The Department of Theoretical Physics namespace as we define it.
void allow_free_args(size_t n)
Allow at most n free arguments.
const std::vector< std::string > & free_args(void) const
Arguments not associated with an Option.
void add(Option &)
Function to add an option.
CommandLine(std::string str="Available options are:")
default constructor
std::string try_help(void) const
void parse(int argc, char *argv[])
parse the commandline
Class for parsing the command line.
Definition: CommandLine.h:98
void sort(void)
Sort Options how they will appear in (help) output.
bool parsed(void) const
has the commandline been parsed already
virtual ~CommandLine(void)
Destructor.
Container of variables for an option.
Definition: Option.h:37