TAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TAP::ArgumentConstraint< CType > Class Template Reference

Argument constraint class. More...

#include <ArgumentConstraint.hpp>

Inheritance diagram for TAP::ArgumentConstraint< CType >:
TAP::BaseArgument

Public Member Functions

template<typename... A>
 ArgumentConstraint (A &&...args)
 Construct a ArgumentConstraint with the (possibly empty) given list of arguments. More...
 
 ArgumentConstraint (const ArgumentConstraint &other)
 ArgumentConstraint copy constructor.
 
 ArgumentConstraint (ArgumentConstraint &&)=default
 ArgumentConstraint move constructor.
 
virtual ~ArgumentConstraint ()
 ArgumentConstraint destructor.
 
ArgumentConstraintoperator= (ArgumentConstraint other)
 ArgumentConstraint assignment operator.
 
ArgumentConstraintoperator= (ArgumentConstraint &&)=default
 ArgumentConstraint move assignment operator.
 
ArgumentConstraintoperator+= (Argument &arg)
 Appends the given argument to the constraint. More...
 
size_t size () const
 Returns the number of contained sub-arguments. More...
 
void find_all_arguments (std::vector< const Argument * > &collector) const override
 See BaseArgument::find_all_arguments()
 
void check_valid () const override
 See BaseArgument::set()
 
std::string usage () const override
 See BaseArgument::usage()
 
std::unique_ptr< BaseArgumentclone () const &override
 See BaseArgument::clone().
 
std::unique_ptr< BaseArgumentclone ()&&override
 See BaseArgument::clone().
 
- Public Member Functions inherited from TAP::BaseArgument
 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.
 
 operator bool () const
 Boolean conversion operator (so you can do things like if (arg) { ... More...
 
BaseArgumentset_required (bool required=true)
 Mark the argument as required or not. More...
 
bool required () const
 Returns whether the argument is required. More...
 

Protected Member Functions

template<typename Arg >
ArgumentConstraintadd (Arg &&arg)
 Add an argument to the constraint. More...
 
unsigned int count () const override
 Returns the number of child arguments which are set.
 
void diagnose_args () const
 Calls diagnose for all set child arguments.
 
std::string usageArgument (const Argument &arg) const
 Returns a string for usage representation of sub-arguments. More...
 
template<ConstraintType ACType>
std::string usageArgument (const ArgumentConstraint< ACType > &arg) const
 Returns a string for usage representation of sub-arguments. More...
 

Protected Attributes

std::vector< std::unique_ptr
< BaseArgument > > 
m_args
 Sub-arguments to check.
 
std::string m_usageString
 Stored usage string.
 
- Protected Attributes inherited from TAP::BaseArgument
bool m_required = false
 True if the argument has to be set.
 

Detailed Description

template<ConstraintType CType>
class TAP::ArgumentConstraint< CType >

Argument constraint class.

Given a set of sub-arguments, the constraint will check if the number of satisfied arguments fall within a certain range. Sub-arguments are allowed to be ArgumentConstraint instances themselves, thus allowing to nest constraints and build a tree. Template parameter CType indicates the type of the constraint, for possibilities see ConstraintType.

Constructor & Destructor Documentation

template<ConstraintType CType>
template<typename... A>
TAP::ArgumentConstraint< CType >::ArgumentConstraint ( A &&...  args)

Construct a ArgumentConstraint with the (possibly empty) given list of arguments.

Parameters
argsArguments to add

Member Function Documentation

template<ConstraintType CType>
template<typename Arg >
ArgumentConstraint& TAP::ArgumentConstraint< CType >::add ( Arg &&  arg)
protected

Add an argument to the constraint.

Parameters
argArgument to add
Returns
Reference to this ArgumentConstraint
template<ConstraintType CType>
ArgumentConstraint& TAP::ArgumentConstraint< CType >::operator+= ( Argument arg)
inline

Appends the given argument to the constraint.

Parameters
argArgument to append
Returns
Reference to this constraint
template<ConstraintType CType>
size_t TAP::ArgumentConstraint< CType >::size ( ) const
inline

Returns the number of contained sub-arguments.

Returns
Number of contained sub-arguments.
template<ConstraintType CType>
std::string TAP::ArgumentConstraint< CType >::usageArgument ( const Argument arg) const
protected

Returns a string for usage representation of sub-arguments.

Returns
String for usage representation of sub-arguments
template<ConstraintType CType>
template<ConstraintType ACType>
std::string TAP::ArgumentConstraint< CType >::usageArgument ( const ArgumentConstraint< ACType > &  arg) const
protected

Returns a string for usage representation of sub-arguments.

Returns
String for usage representation of sub-arguments

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