Command  0.3
Public Types | Public Member Functions | Protected Attributes | List of all members
command::Option< void > Class Reference

#include <option.h>

Inheritance diagram for command::Option< void >:
[legend]
Collaboration diagram for command::Option< void >:
[legend]

Public Types

typedef std::string OptionName
 
- Public Types inherited from command::Parameter
typedef class Parameter Type
 

Public Member Functions

 Option (const std::string &name, const std::string &description, std::function< void(void)> function)
 
virtual void handle ()
 
virtual bool understand (const std::string &argv)
 
virtual unsigned int valuePosition (const std::string &)
 
- Public Member Functions inherited from command::Parameter
 Parameter (const std::string &description)
 
virtual void handle ()=0
 
virtual bool understand (const std::string &)=0
 
virtual bool isRequired ()
 
virtual bool isUsed ()
 
virtual bool hungryForValue ()
 
virtual unsigned int valuePosition (const std::string &)=0
 
- Public Member Functions inherited from command::Descriptive
 Descriptive (const std::string &description)
 
const std::string & describe ()
 
- Public Member Functions inherited from command::Callable< void >
 Callable (std::function< void(void)> function)
 

Protected Attributes

const OptionName name
 
- Protected Attributes inherited from command::Parameter
bool used = false
 
- Protected Attributes inherited from command::Callable< void >
std::function< void(void)> func
 

Additional Inherited Members

- Protected Member Functions inherited from command::Callable< void >
void call ()
 

Detailed Description

Template class responsible for handling commandline options. Options are non-required, named parameters of program. This template specialization allows Options to work like switches. It means that just named parameter is needed to invoke command. No value is used.

Example: ./myprog OptionName ./myprog -h ./myprog –help

Constructor & Destructor Documentation

◆ Option()

command::Option< void >::Option ( const std::string &  name,
const std::string &  description,
std::function< void(void)>  function 
)
inline

Default constructor.

Parameters
nameName of the current Option
descriptionDescription of current Option
functionFunction used to handle current Option.

Member Function Documentation

◆ handle()

virtual void command::Option< void >::handle ( )
inlinevirtual

Method used for handling method calls linked with this Parameter

Implements command::Parameter.

◆ understand()

virtual bool command::Option< void >::understand ( const std::string &  argv)
inlinevirtual

Method used for checking if Option understands given user value. If so, current Option is flagged as used and no more checks against it will be done in future.

Passed value should be in form of: OptionName

Parameters
argvcommand line value against which test will be made. User value should be in format: OptionName.
Returns
If passed argv succesfully detected OptionName returns true and Option is set as used one. Otherwise returns false and can be used to check against next value.

Implements command::Parameter.

◆ valuePosition()

virtual unsigned int command::Option< void >::valuePosition ( const std::string &  )
inlinevirtual

Returns
position where value starts in passed string

Implements command::Parameter.

Member Data Documentation

◆ name

const OptionName command::Option< void >::name
protected

Current Option name


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