TAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Attributes | List of all members
TAP::BaseArgument Class Referenceabstract

Base argument class, used both by actual Argument classes and constraints (ArgumentConstraint). More...

#include <BaseArgument.hpp>

Inheritance diagram for TAP::BaseArgument:
TAP::ArgumentConstraint< ConstraintType::Any > TAP::Argument TAP::ArgumentConstraint< CType > TAP::ArgumentSet TAP::TypedArgument< T, multi > TAP::TypedArgument< bool, false > TAP::TypedArgument< T, false > TAP::VariableArgument< T, multi > TAP::SwitchArgument TAP::ConstArgument< T > TAP::ValueArgument< T, multi >

Public Member Functions

 BaseArgument ()
 Base constructor.
 
 BaseArgument (const BaseArgument &)=default
 BaseArgument copy constructor.
 
 BaseArgument (BaseArgument &&)=default
 BaseArgument move constructor.
 
virtual ~BaseArgument ()
 BaseArgument destructor.
 
BaseArgumentoperator= (const BaseArgument &)=default
 BaseArgument assignment operator.
 
BaseArgumentoperator= (BaseArgument &&)=default
 BaseArgument move assignment operator.
 
virtual void find_all_arguments (std::vector< const Argument * > &collector) const =0
 Collect all Argument instances contained in this argument into the given vector. More...
 
 operator bool () const
 Boolean conversion operator (so you can do things like if (arg) { ... More...
 
virtual unsigned int count () const =0
 Return the actual count of occurrences. More...
 
BaseArgumentset_required (bool required=true)
 Mark the argument as required or not. More...
 
bool required () const
 Returns whether the argument is required. More...
 
virtual void check_valid () const =0
 Check if the argument constraints are satisfied. More...
 
virtual std::string usage () const =0
 Returns a string representing how the argument may be used on the command line. More...
 
virtual std::unique_ptr
< BaseArgument
clone () const &=0
 Make a clone of the BaseArgument. More...
 
virtual std::unique_ptr
< BaseArgument
clone ()&&=0
 Make a clone of the BaseArgument and move all data to it. More...
 

Protected Attributes

bool m_required = false
 True if the argument has to be set.
 

Detailed Description

Base argument class, used both by actual Argument classes and constraints (ArgumentConstraint).

Member Function Documentation

virtual void TAP::BaseArgument::check_valid ( ) const
pure virtual

Check if the argument constraints are satisfied.

Returns if this is the case, will throw an TAP::exception indicating the problem otherwise.

Implemented in TAP::Argument, TAP::ArgumentConstraint< CType >, and TAP::ArgumentConstraint< ConstraintType::Any >.

virtual std::unique_ptr<BaseArgument> TAP::BaseArgument::clone ( ) const
pure virtual
virtual std::unique_ptr<BaseArgument> TAP::BaseArgument::clone ( )
pure virtual

Make a clone of the BaseArgument and move all data to it.

Returns a pointer which is owned by the caller. The original object is no longer valid.

Returns
Clone of the BaseArgument (or sub-class thereof)

Implemented in TAP::SwitchArgument, TAP::ConstArgument< T >, TAP::ValueArgument< T, multi >, TAP::Argument, TAP::VariableArgument< T, multi >, TAP::ArgumentSet, TAP::ArgumentConstraint< CType >, TAP::TypedArgument< T, multi >, TAP::ArgumentConstraint< ConstraintType::Any >, TAP::TypedArgument< bool, false >, and TAP::TypedArgument< T, false >.

virtual unsigned int TAP::BaseArgument::count ( ) const
pure virtual

Return the actual count of occurrences.

Returns
Count of times this argument occurred

Implemented in TAP::Argument, TAP::ArgumentConstraint< CType >, and TAP::ArgumentConstraint< ConstraintType::Any >.

virtual void TAP::BaseArgument::find_all_arguments ( std::vector< const Argument * > &  collector) const
pure virtual

Collect all Argument instances contained in this argument into the given vector.

Parameters
collectorVector to store the arguments in

Implemented in TAP::Argument, TAP::ArgumentConstraint< CType >, and TAP::ArgumentConstraint< ConstraintType::Any >.

TAP::BaseArgument::operator bool ( ) const
inlineexplicit

Boolean conversion operator (so you can do things like if (arg) { ...

} ) It is set to true if and only if the argument is set.

Returns
True iff the argument is set
bool TAP::BaseArgument::required ( ) const
inline

Returns whether the argument is required.

Returns
True iff the argument is required
BaseArgument& TAP::BaseArgument::set_required ( bool  required = true)
inline

Mark the argument as required or not.

Parameters
requiredIf true, the argument must be set at least once (see min())
Returns
Reference to this argument
virtual std::string TAP::BaseArgument::usage ( ) const
pure virtual

Returns a string representing how the argument may be used on the command line.

Returns
The usage string

Implemented in TAP::Argument, TAP::VariableArgument< T, multi >, TAP::ArgumentConstraint< CType >, and TAP::ArgumentConstraint< ConstraintType::Any >.


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