arg  1.2
a C++ command-line parser
Public Member Functions | Protected Attributes | List of all members
arg::Parser Class Reference

The command-line parser. More...

#include <arg.hh>

Inheritance diagram for arg::Parser:
Inheritance graph
[legend]

Public Member Functions

void add_help (std::string const &msg)
 add additional help text between option helps
 
Optionadd_opt (int key, std::string const &name="", bool hide=false)
 add an Option
 
Optionadd_opt (std::string const &name, bool hide=false)
 add an Option without a specified key
 
Optionget_opt (std::string const &name)
 get an existing Option
 
std::vector< std::string > & args ()
 
void parse (int argc, char *argv[], bool ignore_unknown=false)
 perform command-line parsing More...
 
void set_header (std::string const &text)
 set the header in help
 
std::string const & get_header () const
 get the header text of help
 

Protected Attributes

std::string prog_name
 name to identify the program
 

Detailed Description

The command-line parser.

Examples
arg_ex0.cc, arg_ex1.cc, and arg_ex2.cc.

Member Function Documentation

◆ args()

vector< string > & Parser::args ( )

get the argument list

◆ parse()

void Parser::parse ( int  argc,
char *  argv[],
bool  ignore_unknown = false 
)

perform command-line parsing

Parameters
argccount of command-line tokens
argvc-string array of command-line tokens
ignore_unknownwhether to ignore unknown options
Examples
arg_ex0.cc, arg_ex1.cc, and arg_ex2.cc.