Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::Util::Option Class Reference

#include <Option.h>

List of all members.


Detailed Description

This class represents and stores the properties of a command line option.

An option has a full name, an optional short name, a description (used for printing a usage statement), and an optional argument name. An option can be optional or required. An option can be repeatable, which means that it can be given more than once on the command line.

An option can be part of an option group. At most one option of each group may be specified on the command line.

An option can be bound to a configuration property. In this case, a configuration property will automatically receive the option's argument value.

A callback method can be specified for options. This method is called whenever an option is specified on the command line.

Option argument values can be automatically validated using a Validator.

Option instances are value objects.

Typcally, after construction, an Option object is immediately passed to an Options object.

An Option object can be created by chaining the constructor with any of the setter methods, as in the following example:

Option versionOpt("include", "I", "specify an include directory") .required(false) .repeatable(true) .argument("directory");

Definition at line 56 of file Option.h.


Public Member Functions

Optionargument (const std::string &name, bool required=true)
const std::string & argumentName () const
 Returns true if the argument is required.
bool argumentRequired () const
 Returns true if the options takes an (optional) argument.
const std::string & binding () const
Optionbinding (const std::string &propertyName, AbstractConfiguration *pConfig)
Optionbinding (const std::string &propertyName)
 Specifies the option group the option is part of.
AbstractOptionCallbackcallback () const
Optioncallback (const AbstractOptionCallback &cb)
AbstractConfigurationconfig () const
const std::string & description () const
 Returns the full name of the option.
Optiondescription (const std::string &text)
 Sets the full name of the option.
const std::string & fullName () const
 Returns the short name of the option.
OptionfullName (const std::string &name)
 Sets the short name of the option.
const std::string & group () const
 Returns the argument name, if specified.
Optiongroup (const std::string &group)
 Specifies that the option does not take an argument (default).
bool matchesFull (const std::string &option) const
bool matchesPartial (const std::string &option) const
bool matchesShort (const std::string &option) const
 Returns the configuration, if specified, or NULL otherwise.
OptionnoArgument ()
Optionoperator= (const Option &option)
 Destroys the Option.
 Option (const std::string &fullName, const std::string &shortName, const std::string &description, bool required, const std::string &argName, bool argOptional=false)
 Creates an option with the given properties.
 Option (const std::string &fullName, const std::string &shortName, const std::string &description, bool required=false)
 Creates an option with the given properties.
 Option (const std::string &fullName, const std::string &shortName)
 Creates an option from another one.
 Option (const Option &option)
 Creates an empty Option.
void process (const std::string &option, std::string &arg) const
bool repeatable () const
 Returns true if the option is required, false if not.
Optionrepeatable (bool flag)
bool required () const
 Returns the description of the option.
Optionrequired (bool flag)
 Sets the description of the option.
const std::string & shortName () const
OptionshortName (const std::string &name)
 Swaps the option with another one.
void swap (Option &option)
 Assignment operator.
bool takesArgument () const
Validatorvalidator () const
Optionvalidator (Validator *pValidator)
 ~Option ()
 Creates an option with the given properties.

Private Attributes

std::string _argName
bool _argRequired
std::string _binding
std::string _description
std::string _fullName
std::string _group
AbstractOptionCallback_pCallback
AbstractConfiguration_pConfig
Validator_pValidator
bool _repeatable
bool _required
std::string _shortName

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

Generated by  Doxygen 1.6.0   Back to index