TAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Types | Protected Attributes | List of all members
TAP::ValueArgument< T, multi > Class Template Reference

Implementation of TypedArgument that stores a value by itself, based on VariableArgument. More...

#include <TypedArgument.hpp>

Inheritance diagram for TAP::ValueArgument< T, multi >:
TAP::VariableArgument< T, multi > TAP::TypedArgument< T, multi > TAP::ValueAcceptor TAP::Argument TAP::BaseArgument

Public Member Functions

template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
 ValueArgument (std::string description, U &&...params)
 Create a positional ValueArgument using an internal variable to store the value. More...
 
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
 ValueArgument (std::string description, char flag, U &&...params)
 Create a ValueArgument using an internal variable to store the value, aliased to the given flag. More...
 
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
 ValueArgument (std::string description, const std::string &name, U &&...params)
 Create a ValueArgument using an internal variable to store the value, aliased to the given flag. More...
 
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
 ValueArgument (std::string description, char flag, const std::string &name, U &&...params)
 Create a ValueArgument using an internal variable to store the value, aliased to the given flag and name. More...
 
virtual ~ValueArgument ()=default
 ValueArgument destructor.
 
 ValueArgument (const ValueArgument &)=default
 ValueArgument copy constructor.
 
 ValueArgument (ValueArgument &&)=default
 ValueArgument move constructor.
 
ValueArgumentoperator= (const ValueArgument &)=default
 ValueArgument copy assignment operator. More...
 
ValueArgumentoperator= (ValueArgument &&)=default
 ValueArgument move assignment operator.
 
std::unique_ptr< BaseArgumentclone () const &override
 See BaseArgument::clone().
 
std::unique_ptr< BaseArgumentclone ()&&override
 See BaseArgument::clone().
 
- Public Member Functions inherited from TAP::VariableArgument< T, multi >
 VariableArgument (std::string description, ST *storage)
 Create a VariableArgument with given description and storage pointer. More...
 
 VariableArgument (std::string description, char flag, ST *storage)
 Create a VariableArgument with given description and storage pointer, aliased to the given flag. More...
 
 VariableArgument (std::string description, const std::string &name, ST *storage)
 Create a VariableArgument with given description and storage pointer, aliased to the given name. More...
 
 VariableArgument (std::string description, char flag, const std::string &name, ST *storage)
 Create a VariableArgument with given description and storage pointer, aliased to the given flag and name. More...
 
 VariableArgument (std::string description, ST &storage)
 Create a VariableArgument with given description and storage reference. More...
 
 VariableArgument (std::string description, char flag, ST &storage)
 Create a VariableArgument with given description and storage reference, aliased to the given flag. More...
 
 VariableArgument (std::string description, const std::string &name, ST &storage)
 Create a VariableArgument with given description and storage reference, aliased to the given name. More...
 
 VariableArgument (std::string description, char flag, const std::string &name, ST &storage)
 Create a VariableArgument with given description and storage reference, aliased to the given flag and name. More...
 
virtual ~VariableArgument ()=default
 VariableArgument destructor.
 
 VariableArgument (const VariableArgument &)=default
 VariableArgument copy constructor.
 
 VariableArgument (VariableArgument &&)=default
 VariableArgument move constructor.
 
VariableArgumentoperator= (const VariableArgument &)=default
 VariableArgument copy assignment operator.
 
VariableArgumentoperator= (VariableArgument &&)=default
 VariableArgument move assignment operator.
 
VariableArgumentvaluename (const std::string &valueName)
 Assign a human readable description for the value, used when describing the argument. More...
 
const std::string & valuename ()
 Return a human readable description for the value, used when describing the argument. More...
 
bool takes_value () const override
 See Argument::takes_value()
 
void set () const override
 Calling this function is an error, call set(std::string) instead.
 
void set (const std::string &value) const override
 See ValueAcceptor::set()
 
std::string usage () const override
 See Argument::usage()
 
std::string ident () const override
 See Argument::ident()
 
- Public Member Functions inherited from TAP::TypedArgument< T, multi >
const STvalue () const
 Returns the value of this argument. More...
 
virtual TypedArgumentcheck (TypedArgumentCheckFunc< T, multi > typedCheckFunc)
 See Argument::check()
 
- Public Member Functions inherited from TAP::Argument
 Argument (std::string description)
 Create an argument with flag and/or name set by description. More...
 
 Argument (std::string description, char flag)
 Create an argument that is identified by a flag. More...
 
 Argument (std::string description, std::string name)
 Create an argument that is identified by a name. More...
 
 Argument (std::string description, char flag, std::string name)
 Create an argument that is identified by both a name and flag. More...
 
 Argument (const Argument &)=default
 Argument copy constructor.
 
 Argument (Argument &&)=default
 Argument move constructor.
 
virtual ~Argument ()
 Argument destructor.
 
Argumentoperator= (const Argument &other)=default
 Argument assignment operator.
 
Argumentoperator= (Argument &&other)=default
 Argument move assignment operator.
 
Argumentalias (char flag)
 An a flag alias for the argument. More...
 
Argumentalias (std::string name)
 An a name alias for the argument. More...
 
Argumentalias (char flag, std::string name)
 An both a flag and name alias for the argument. More...
 
const std::string & description () const
 Returns the description of this argument. More...
 
virtual Argumentcheck (ArgumentCheckFunc checkFunc)
 Set the check function to use. More...
 
bool matches () const
 Returns a pointer to this argument if it matches as a positional argument, otherwise a null-pointer. More...
 
bool matches (char flag) const
 Returns a pointer to this argument if it matches the given flag with any alias, otherwise a null-pointer. More...
 
bool matches (const std::string &name) const
 Returns a pointer to this argument if it matches the given name with any alias, otherwise a null-pointer. More...
 
void find_all_arguments (std::vector< const Argument * > &collector) const override
 See BaseArgument::find_all_arguments()
 
Argumentmany (bool many=true)
 Allow the argument to occur multiple times or not. More...
 
Argumentmin (unsigned int min)
 Set the minimum number of required occurrences if set. More...
 
unsigned int min () const
 Returns the minimum number of occurrences of this argument for it to be satisfied if set. More...
 
Argumentmax (unsigned int max)
 Set the maximum number of required occurrences. More...
 
unsigned int max () const
 Returns the maximum number of occurrences of this argument. More...
 
unsigned int count () const override
 See BaseArgument::count()
 
bool can_set () const
 Returns whether this argument is still allowed to occur on the command line. More...
 
void check_valid () const override
 See BaseArgument::check_valid()
 
- 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 Types

using ST = typename VariableArgument< T, multi >::ST
 Make TypedArgument::ST accessible. More...
 
- Protected Types inherited from TAP::VariableArgument< T, multi >
using ST = typename TypedArgument< T, multi >::ST
 Make TypedArgument::ST accessible. More...
 
- Protected Types inherited from TAP::TypedArgument< T, multi >
using ST = typename std::conditional< !multi, T, std::vector< T > >::type
 Alias for the storage type (which is a vector for MultiValueArgument types)
 

Protected Attributes

std::shared_ptr< STm_ownStorage
 If the ValueArgument owns the variable storage, it is stored here.
 
- Protected Attributes inherited from TAP::VariableArgument< T, multi >
std::string m_valueName = std::string("value")
 Name of the accepted value, used in the identifier.
 
- Protected Attributes inherited from TAP::TypedArgument< T, multi >
STm_storage
 Pointer to value storage.
 
TypedArgumentCheckFunc< T, multi > m_typedCheckFunc = nullptr
 Callback for typed check.
 
- Protected Attributes inherited from TAP::Argument
std::string m_flags
 Flags this arguments matches.
 
std::vector< std::string > m_names
 Names this argument matches.
 
bool m_isPositional
 True if used as positional argument.
 
std::string m_description
 Description or help text of argument.
 
unsigned int m_min = 1
 Minimum number of occurrences if argument is set.
 
unsigned int m_max = 1
 Maximum number of occurrences. More...
 
std::shared_ptr< unsigned int > m_count
 Actual counted number of occurrences.
 
ArgumentCheckFunc m_checkFunc = nullptr
 Callback for check.
 
- Protected Attributes inherited from TAP::BaseArgument
bool m_required = false
 True if the argument has to be set.
 

Additional Inherited Members

- Protected Member Functions inherited from TAP::TypedArgument< T, multi >
 TypedArgument (std::string description, ST *storage)
 Create a TypedArgument with given description and storage pointer. More...
 
 TypedArgument (std::string description, char flag, ST *storage)
 Create a TypedArgument with given description and storage pointer, aliased to the given flag. More...
 
 TypedArgument (std::string description, const std::string &name, ST *storage)
 Create a TypedArgument with given description and storage pointer, aliased to the given name. More...
 
 TypedArgument (std::string description, char flag, const std::string &name, ST *storage)
 Create a TypedArgument with given description and storage pointer, aliased to the given flag and name. More...
 
template<bool m = multi>
std::enable_if<!m >::type check () const override
 See Argument::check()
 
template<bool m = multi>
std::enable_if< m >::type check () const override
 See Argument::check()
 

Detailed Description

template<typename T, bool multi = false>
class TAP::ValueArgument< T, multi >

Implementation of TypedArgument that stores a value by itself, based on VariableArgument.

Member Typedef Documentation

template<typename T , bool multi = false>
using TAP::ValueArgument< T, multi >::ST = typename VariableArgument<T, multi>::ST
protected

Make TypedArgument::ST accessible.

Constructor & Destructor Documentation

template<typename T , bool multi = false>
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
TAP::ValueArgument< T, multi >::ValueArgument ( std::string  description,
U &&...  params 
)
inline

Create a positional ValueArgument using an internal variable to store the value.

The parameter list is used to construct the value.

Parameters
descriptionDescription of the argument (used in help text)
paramsArguments passed to the constructor of the value storage
template<typename T , bool multi = false>
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
TAP::ValueArgument< T, multi >::ValueArgument ( std::string  description,
char  flag,
U &&...  params 
)
inline

Create a ValueArgument using an internal variable to store the value, aliased to the given flag.

The parameter list is used to construct the value.

Parameters
descriptionDescription of the argument (used in help text)
flagFlag identifier of this argument
paramsArguments passed to the constructor of the value storage
template<typename T , bool multi = false>
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
TAP::ValueArgument< T, multi >::ValueArgument ( std::string  description,
const std::string &  name,
U &&...  params 
)
inline

Create a ValueArgument using an internal variable to store the value, aliased to the given flag.

The parameter list is used to construct the value.

Parameters
descriptionDescription of the argument (used in help text)
nameName identifier of this argument
paramsArguments passed to the constructor of the value storage
template<typename T , bool multi = false>
template<typename... U, typename = typename std::enable_if< std::is_constructible<ST, U...>::value >::type>
TAP::ValueArgument< T, multi >::ValueArgument ( std::string  description,
char  flag,
const std::string &  name,
U &&...  params 
)
inline

Create a ValueArgument using an internal variable to store the value, aliased to the given flag and name.

The parameter list is used to construct the value.

Parameters
descriptionDescription of the argument (used in help text)
flagFlag identifier of this argument
nameName identifier of this argument
paramsArguments passed to the constructor of the value storage

Member Function Documentation

template<typename T , bool multi = false>
ValueArgument& TAP::ValueArgument< T, multi >::operator= ( const ValueArgument< T, multi > &  )
default

ValueArgument copy assignment operator.

Will copy the stored value if the other ValueArgument owns the variable, otherwise simply copies the pointer.


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