Sharg 1.1.2-rc.1
The argument parser for bio-c++ tools.
Loading...
Searching...
No Matches
sharg::detail::validator_chain_adaptor< validator1_type, validator2_type > Class Template Reference

A helper struct to chain validators recursively via the pipe operator. More...

#include <sharg/validators.hpp>

+ Inheritance diagram for sharg::detail::validator_chain_adaptor< validator1_type, validator2_type >:

Public Types

using option_value_type
 The underlying type in both validators.
 

Public Member Functions

template<typename cmp_type >
requires std::invocable<validator1_type, cmp_type const> && std::invocable<validator2_type, cmp_type const>
void operator() (cmp_type const &cmp) const
 Calls the operator() of each validator on the value cmp.
 
std::string get_help_page_message () const
 Returns a message that can be appended to the (positional) options help page info.
 
Constructors, destructor and assignment
 validator_chain_adaptor ()=delete
 Deleted.
 
 validator_chain_adaptor (validator_chain_adaptor const &pf)=default
 Defaulted.
 
validator_chain_adaptoroperator= (validator_chain_adaptor const &pf)=default
 Defaulted.
 
 validator_chain_adaptor (validator_chain_adaptor &&)=default
 Defaulted.
 
validator_chain_adaptoroperator= (validator_chain_adaptor &&)=default
 Defaulted.
 
 validator_chain_adaptor (validator1_type vali1_, validator2_type vali2_)
 Constructing from two validators.
 
 ~validator_chain_adaptor ()=default
 The destructor.
 

Private Attributes

validator1_type vali1
 The first validator in the chain.
 
validator2_type vali2
 The second validator in the chain.
 

Detailed Description

template<validator validator1_type, validator validator2_type>
requires std::common_with<typename validator1_type::option_value_type, typename validator2_type::option_value_type>
class sharg::detail::validator_chain_adaptor< validator1_type, validator2_type >

A helper struct to chain validators recursively via the pipe operator.

Note that both validators must operate on the same option_value_type in order to avoid unexpected behaviour and ensure that the sharg::parser::add_option call is well-formed. (add_option(val, ...., validator) requires that val is of same type as validator::option_value_type).

Remarks
For a complete overview, take a look at Parser

Member Typedef Documentation

◆ option_value_type

template<validator validator1_type, validator validator2_type>
using sharg::detail::validator_chain_adaptor< validator1_type, validator2_type >::option_value_type

Constructor & Destructor Documentation

◆ validator_chain_adaptor()

template<validator validator1_type, validator validator2_type>
sharg::detail::validator_chain_adaptor< validator1_type, validator2_type >::validator_chain_adaptor ( validator1_type vali1_,
validator2_type vali2_ )
inline

Constructing from two validators.

Parameters
[in]vali1_Some validator to be chained to vali2_.
[in]vali2_Another validator to be chained to vali1_.

Member Function Documentation

◆ operator()()

template<validator validator1_type, validator validator2_type>
template<typename cmp_type >
requires std::invocable<validator1_type, cmp_type const> && std::invocable<validator2_type, cmp_type const>
void sharg::detail::validator_chain_adaptor< validator1_type, validator2_type >::operator() ( cmp_type const & cmp) const
inline

Calls the operator() of each validator on the value cmp.

Template Parameters
cmp_typeThe type of value to validate; must be invokable with each of the validator members.
Parameters
[in]cmpThe value to validate.

This function delegates to the validation of both of the chained validators by calling their operator() one after the other. The behaviour depends on the chained validators which may throw on input error.


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