Class CmdLine
Defined in File cmd_line.hpp
Inheritance Relationships
Base Type
public ecl::CmdLineInterface
(Class CmdLineInterface)
Class Documentation
-
class CmdLine : public ecl::CmdLineInterface
Manages the command line parsing object.
The base class that manages the command line definition and passes along the parsing to the appropriate Arg classes.
Public Functions
-
inline CmdLine(const std::string &message, const char delimiter = ' ', const std::string &version = "none", bool helpAndVersion = true)
Command line constructor. Defines how the arguments will be parsed.
- Parameters:
message – - The message to be used in the usage output.
delimiter – - The character that is used to separate the argument flag/name from the value. Defaults to ‘ ‘ (space).
version – - The version number to be used in the —version switch.
helpAndVersion – - Whether or not to create the Help and Version switches. Defaults to true.
-
inline virtual void add(Arg &a)
Adds an argument to the list of arguments to be parsed.
- Parameters:
a – - Argument to be added.
-
inline virtual void add(Arg *a)
An alternative add. Functionally identical.
- Parameters:
a – - Argument to be added.
-
inline virtual void xorAdd(Arg &a, Arg &b)
Add two Args that will be xor’d. If this method is used, add does not need to be called.
- Parameters:
a – - Argument to be added and xor’d.
b – - Argument to be added and xor’d.
-
inline virtual void xorAdd(std::vector<Arg*> &xors)
Add a list of Args that will be xor’d. If this method is used, add does not need to be called.
- Parameters:
xors – - List of Args to be added and xor’d.
-
inline virtual void parse(int argc, char **argv)
Parses the command line.
- Parameters:
argc – - Number of arguments.
argv – - Array of arguments.
-
inline virtual CmdLineOutput *getOutput()
Returns the CmdLineOutput object.
-
inline virtual void setOutput(CmdLineOutput *co)
- Parameters:
co – - CmdLineOutput object that we want to use instead.
-
inline virtual std::string &getVersion()
Returns the version string.
-
inline virtual std::string &getProgramName()
Returns the program name string.
-
inline virtual XorHandler &getXorHandler()
Returns the XorHandler.
-
inline virtual char getDelimiter()
Returns the delimiter string.
-
inline virtual std::string &getMessage()
Returns the message string.
-
inline virtual bool hasHelpAndVersion()
Indicates whether or not the help and version switches were created automatically.
Protected Functions
-
inline bool _emptyCombined(const std::string &s)
Checks whether a name/flag string matches entirely matches the Arg::blankChar. Used when multiple switches are combined into a single argument.
- Parameters:
s – - The message to be used in the usage.
Protected Attributes
-
std::string _progName
The name of the program. Set to argv[0].
-
std::string _message
A message used to describe the program. Used in the usage output.
-
std::string _version
The version to be displayed with the —version switch.
-
int _numRequired
The number of arguments that are required to be present on the command line. This is set dynamically, based on the Args added to the CmdLine object.
-
char _delimiter
The character that is used to separate the argument flag/name from the value. Defaults to ‘ ‘ (space).
-
XorHandler _xorHandler
The handler that manages xoring lists of args.
-
std::list<Arg*> _argDeleteOnExitList
A list of Args to be explicitly deleted when the destructor is called. At the moment, this only includes the three default Args.
-
std::list<Visitor*> _visitorDeleteOnExitList
A list of Visitors to be explicitly deleted when the destructor is called. At the moment, these are the Vistors created for the default Args.
-
CmdLineOutput *_output
Object that handles all output for the CmdLine.
-
inline CmdLine(const std::string &message, const char delimiter = ' ', const std::string &version = "none", bool helpAndVersion = true)