libshevek
Classes | Public Member Functions | List of all members
shevek::args Class Reference

Commandline and configuration file parsing helper. More...

#include <args.hh>

Classes

class  option
 Define an option which can be given to the program. More...

Public Member Functions

 args (int &argc, char **&argv, int min_args, int max_args, Glib::ustring const &description, Glib::ustring const &copyright_years=COPYRIGHT_YEARS, Glib::ustring const &copyright_email=(COPYRIGHT_EMAIL[0]== '\0'?PACKAGE_BUGREPORT:COPYRIGHT_EMAIL), Glib::ustring const &programmer=COPYRIGHT_AUTHOR, Glib::ustring const &email=PACKAGE_BUGREPORT, char const *programname=PACKAGE_NAME, char const *packagename=PACKAGE_TARNAME, char const *version=PACKAGE_VERSION)
template<unsigned size_>
 args (int &argc, char **&argv, option(&o)[size_], int min_args, int max_args, Glib::ustring const &description)
 Parse the commandline providing a list of possible options.
unsigned size () const
 The number of non-option arguments.
std::string const & operator[] (unsigned idx) const
 Get the non-option arguments.
std::vector< std::string >
::const_iterator 
begin () const
 Iterate over the non-option arguments.
std::vector< std::string >
::const_iterator 
end () const
 Iterate over the non-option arguments.

Detailed Description

Commandline and configuration file parsing helper.

Args is a commandline parsing helper. It allows giving the possible short and long options in a simple list and provides –help and –version output to the user of the program.

Usage: create an array of shevek::args::option, containing the desired options. create an instance of args and pass it argc and argv on the constructor. It will call all the callbacks of the options from the constructor. size () and operator[] can be used to access the non-option arguments.

Constructor & Destructor Documentation

shevek::args::args ( int &  argc,
char **&  argv,
int  min_args,
int  max_args,
Glib::ustring const &  description,
Glib::ustring const &  copyright_years = COPYRIGHT_YEARS,
Glib::ustring const &  copyright_email = (COPYRIGHT_EMAIL[0]== '\0'?PACKAGE_BUGREPORT:COPYRIGHT_EMAIL),
Glib::ustring const &  programmer = COPYRIGHT_AUTHOR,
Glib::ustring const &  email = PACKAGE_BUGREPORT,
char const *  programname = PACKAGE_NAME,
char const *  packagename = PACKAGE_TARNAME,
char const *  version = PACKAGE_VERSION 
)

Parse the commandline. Only the default arguments (–help, -h and –version) are understood.


The documentation for this class was generated from the following file: