39 #ifndef __PROGRAM_OPTIONS_LITE__
40 #define __PROGRAM_OPTIONS_LITE__
48 namespace program_options_lite
63 const char*
what()
const throw() {
return "Option Parse Failure"; }
70 virtual std::ostream&
error(
const std::string& where);
71 virtual std::ostream&
warn(
const std::string& where);
77 void doHelp(std::ostream& out,
Options& opts,
unsigned columns = 80);
87 OptionBase(
const std::string& name,
const std::string& desc)
106 Option(
const std::string& name, T& storage, T default_val,
const std::string& desc)
126 std::istringstream arg_ss (arg,std::istringstream::in);
127 arg_ss.exceptions(std::ios::failbit);
130 arg_ss >> opt_storage;
198 typedef std::map<std::string, NamesPtrList>
NamesMap;
217 operator()(
const std::string& name, T& storage, T default_val,
const std::string& desc =
"")
Option(const std::string &name, T &storage, T default_val, const std::string &desc)
std::list< std::string > opt_long
std::list< std::string > opt_short
void doHelp(ostream &out, Options &opts, unsigned columns)
void( Func)(Options &, const std::string &, ErrorReporter &)
void parse(const std::string &arg, ErrorReporter &error_reporter)
virtual std::ostream & warn(const std::string &where)
OptionSpecific(Options &parent_)
ErrorReporter default_error_reporter
OptionBase(const std::string &name, const std::string &desc)
void setDefaults(Options &opts)
const char * what() const
list< const char * > scanArgv(Options &opts, unsigned argc, const char *argv[], ErrorReporter &error_reporter)
virtual void parse(const std::string &arg, ErrorReporter &)=0
ParseFailure(std::string arg0, std::string val0)
OptionSpecific addOptions()
OptionSpecific & operator()(const std::string &name, OptionFunc::Func *func, const std::string &desc="")
OptionFunc(const std::string &name, Options &parent_, Func *func_, const std::string &desc)
std::list< Names * > NamesPtrList
virtual void setDefault()=0
void parseConfigFile(Options &opts, const string &filename, ErrorReporter &error_reporter)
std::map< std::string, NamesPtrList > NamesMap
OptionSpecific & operator()(const std::string &name, T &storage, T default_val, const std::string &desc="")
virtual std::ostream & error(const std::string &where)
void parse(const std::string &arg, ErrorReporter &)
void addOption(OptionBase *opt)