tclap 1.4.0
Public Types | Public Member Functions | List of all members
TCLAP::PredicateConstraint< T, Function, Text > Class Template Reference

Adapts an owned function or const function object to Constraint<T>. More...

#include <PredicateConstraint.h>

Inheritance diagram for TCLAP::PredicateConstraint< T, Function, Text >:
Inheritance graph
[legend]
Collaboration diagram for TCLAP::PredicateConstraint< T, Function, Text >:
Collaboration graph
[legend]

Public Types

typedef Function Predicate
 

Public Member Functions

 PredicateConstraint (const std::string &description, const std::string &shortId, const Function &function)
 Copies the callable and the two independently supplied strings.
 
 PredicateConstraint (const Function &function, const Text &text)
 Advanced form used by the rule factory to share validation/text state.
 
virtual ~PredicateConstraint ()
 
bool check (const T &value) const
 The method used to verify that the value parsed from the command line meets the constraint.
 
std::string description () const
 Returns a description of the Constraint.
 
std::string shortID () const
 Returns the short ID for the Constraint.
 
- Public Member Functions inherited from TCLAP::Constraint< T >
virtual ~Constraint ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from TCLAP::Constraint< T >
static std::string shortID (const Constraint< T > *constraint)
 

Detailed Description

template<class T, class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
class TCLAP::PredicateConstraint< T, Function, Text >

Adapts an owned function or const function object to Constraint<T>.

Function must accept const T& and return a value convertible to bool. The adapter copies the supplied callable; explicitly borrowed state inside it must remain alive. Args borrow the constraint itself: declare it before the arguments using it and do not move it after binding its address. Null function pointers are rejected with std::invalid_argument. Exceptions from the callable or text policy propagate unchanged from these methods.

MakeConstraint() deduces Function. MakeRuleConstraint() also obtains description()/shortID() from the same stored callable. Ordinary callers supply separate description and short-ID strings and need no text policy.

Definition at line 124 of file PredicateConstraint.h.

Member Typedef Documentation

◆ Predicate

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
typedef Function TCLAP::PredicateConstraint< T, Function, Text >::Predicate

Definition at line 126 of file PredicateConstraint.h.

Constructor & Destructor Documentation

◆ PredicateConstraint() [1/2]

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
TCLAP::PredicateConstraint< T, Function, Text >::PredicateConstraint ( const std::string &  description,
const std::string &  shortId,
const Function &  function 
)
inline

Copies the callable and the two independently supplied strings.

Definition at line 129 of file PredicateConstraint.h.

References TCLAP::internal::ValidateConstraintPredicate< Function >::check().

Here is the call graph for this function:

◆ PredicateConstraint() [2/2]

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
TCLAP::PredicateConstraint< T, Function, Text >::PredicateConstraint ( const Function &  function,
const Text &  text 
)
inline

Advanced form used by the rule factory to share validation/text state.

Definition at line 137 of file PredicateConstraint.h.

References TCLAP::internal::ValidateConstraintPredicate< Function >::check().

Here is the call graph for this function:

◆ ~PredicateConstraint()

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
virtual TCLAP::PredicateConstraint< T, Function, Text >::~PredicateConstraint ( )
inlinevirtual

Definition at line 142 of file PredicateConstraint.h.

Member Function Documentation

◆ check()

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
bool TCLAP::PredicateConstraint< T, Function, Text >::check ( const T &  value) const
inlinevirtual

The method used to verify that the value parsed from the command line meets the constraint.

Parameters
value- The value that will be checked.

Implements TCLAP::Constraint< T >.

Definition at line 144 of file PredicateConstraint.h.

◆ description()

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
std::string TCLAP::PredicateConstraint< T, Function, Text >::description ( ) const
inlinevirtual

Returns a description of the Constraint.

Implements TCLAP::Constraint< T >.

Definition at line 145 of file PredicateConstraint.h.

◆ shortID()

template<class T , class Function = bool (*)(const T &), class Text = internal::FixedConstraintText>
std::string TCLAP::PredicateConstraint< T, Function, Text >::shortID ( ) const
inlinevirtual

Returns the short ID for the Constraint.

Implements TCLAP::Constraint< T >.

Definition at line 146 of file PredicateConstraint.h.


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