option_parser Class Reference

#include <option_parser.h>

Public Member Functions

template<typename T >
option_parseroperator() (T &value, const std::string &flag, const std::string &help)
 
template<typename T >
option_parseroperator() (const value_container< T > &value, const std::string &flag, const std::string &help)
 
bool is_help_requested (int argc, const char **argv)
 
void parse (int &argc, const char **argv)
 
void check_for_unknown_options (const int argc, const char **argv)
 
void display_help (std::ostream &out, const char *prefix="\t", const char *sep=": ", const char *postfix="\n")
 

Detailed Description

Container for options

Performs:

  1. Option parsing from the command line
  2. Display help message

Member Function Documentation

void check_for_unknown_options ( const int  argc,
const char **  argv 
)
inline

Check for unknown options

If any exist, throw an exception

void display_help ( std::ostream &  out,
const char *  prefix = "\t",
const char *  sep = ": ",
const char *  postfix = "\n" 
)
inline

Write option description to the given output stream

Parameters
outoutput stream
prefixprefix to option description
sepseparator between option name and description
postfixtrailing text
bool is_help_requested ( int  argc,
const char **  argv 
)
inline

Check if help was requested

Parameters
argcnumber of arguments
argvlist of string arguments
Returns
true if help was requested
option_parser& operator() ( T &  value,
const std::string &  flag,
const std::string &  help 
)
inline

Add option with corresponding value to the container

Parameters
valuereference to value to update (most be persistent!)
flagname of the option
helpoption description
Returns
reference to self
option_parser& operator() ( const value_container< T > &  value,
const std::string &  flag,
const std::string &  help 
)
inline

Add option with corresponding value to the container

Parameters
valuereference to value to update (most be persistent!)
flagname of the option
helpoption description
Returns
reference to self
void parse ( int &  argc,
const char **  argv 
)
inline

Parse a command line

Parameters
argcnumber of arguments
argvlist of string arguments

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