libvariant
 All Classes Namespaces Files Functions Enumerations Groups
Public Member Functions | List of all members
libvariant::ArgParse Class Reference

An argument parsing class that constructs a Variant from the command line. More...

#include <Variant/ArgParse.h>

Public Member Functions

 ArgParse (bool addhelp=true)
 addhelp true causes AddHelp to be called.
 
 ArgParse (const std::string &pname, bool addhelp=true)
 
ArgParseOption AddOption (const std::string &keypath, int shortOpt, const std::string &longOpt="", const std::string &helptxt="")
 Add the option and configure it as an option that takes an argument.
 
ArgParseOption At (const std::string &keypath)
 Convenience methods for getting an existing option.
 
ArgParseOption operator[] (const std::string &keypath)
 
ArgParseOption AddFlag (const std::string &keypath, int shortOpt, const std::string &longOpt="", const std::string &helptxt="")
 Add the option and configure it as an option that is default false and.
 
OptionGroup AddGroup (const std::string &name, const std::string &title="", const std::string &description="")
 Adds the group name.
 
OptionGroup GetGroup (const std::string &name)
 Returns the group name.
 
ArgParseOption AddArgument (const std::string &keypath, const std::string &helptxt="")
 Add a positional argument.
 
ArgParseOption At (size_t argumentIndex)
 Convenience methods for getting an existing argument.
 
ArgParseOption operator[] (size_t argumentIndex)
 
void ConflictResolution (bool resolve=true)
 When this is on, trying to add a second option with the same short option.
 
void AddConfigDefaults ()
 Add a –config and –print-config option.
 
void AddHelp ()
 Add -h,–help option with action ARGACTION_HELP.
 
void SetDescription (const std::string &txt)
 Set the description text that follows the usage message.
 
void SetEpilog (const std::string &txt)
 Set the epilog text at the end of help.
 
void SetProgramName (const std::string &pname, bool do_basename=true)
 Override the default program name.
 
std::string GetProgramName () const
 
void Merge (Variant newopts)
 
void Merge (const ArgParse &other)
 
void Validate () const
 Validate the argparse description against the internal schema.
 
Variant Parse (int argc, char *const *argv)
 Parse the arguments with the internal description.
 
void PrintHelp (bool advanced=false) const
 Print the help message and exit.
 
Variant GetDescription () const
 Return the Variant that describes the arguments.
 
Variant GenerateSchema () const
 Generate a schema for the Variant returned by Parse from the argument description.
 

Detailed Description

An argument parsing class that constructs a Variant from the command line.


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