sisi4s
Loading...
Searching...
No Matches
CLI::Validator Class Reference

Some validators that are provided. More...

#include <CLI11.hpp>

Inheritance diagram for CLI::Validator:
Collaboration diagram for CLI::Validator:

Public Member Functions

 Validator ()=default
 
 Validator (std::string validator_desc)
 Construct a Validator with just the description string.
 
 Validator (std::function< std::string(std::string &)> op, std::string validator_desc, std::string validator_name="")
 Construct Validator from basic information.
 
Validatoroperation (std::function< std::string(std::string &)> op)
 Set the Validator operation function.
 
std::string operator() (std::string &str) const
 
std::string operator() (const std::string &str) const
 
Validatordescription (std::string validator_desc)
 Specify the type string.
 
Validator description (std::string validator_desc) const
 Specify the type string.
 
std::string get_description () const
 Generate type description information for the Validator.
 
Validatorname (std::string validator_name)
 Specify the type string.
 
Validator name (std::string validator_name) const
 Specify the type string.
 
const std::string & get_name () const
 Get the name of the Validator.
 
Validatoractive (bool active_val=true)
 Specify whether the Validator is active or not.
 
Validator active (bool active_val=true) const
 Specify whether the Validator is active or not.
 
Validatornon_modifying (bool no_modify=true)
 Specify whether the Validator can be modifying or not.
 
Validatorapplication_index (int app_index)
 Specify the application index of a validator.
 
Validator application_index (int app_index) const
 Specify the application index of a validator.
 
int get_application_index () const
 Get the current value of the application index.
 
bool get_active () const
 Get a boolean if the validator is active.
 
bool get_modifying () const
 Get a boolean if the validator is allowed to modify the input returns true if it can modify the input.
 
Validator operator& (const Validator &other) const
 
Validator operator| (const Validator &other) const
 
Validator operator! () const
 Create a validator that fails when a given validator succeeds.
 

Protected Attributes

std::function< std::string()> desc_function_ {[]() { return std::string{}; }}
 This is the description function, if empty the description_ will be used.
 
std::function< std::string(std::string &)> func_ {[](std::string &) { return std::string{}; }}
 
std::string name_ {}
 The name for search purposes of the Validator.
 
int application_index_ = -1
 A Validator will only apply to an indexed value (-1 is all elements)
 
bool active_ {true}
 Enable for Validator to allow it to be disabled if need be.
 
bool non_modifying_ {false}
 specify that a validator should not modify the input
 

Detailed Description

Some validators that are provided.

These are simple std::string(const std::string&) validators that are useful. They return a string if the validation fails. A custom struct is provided, as well, with the same user semantics, but with the ability to provide a new type name.

Constructor & Destructor Documentation

◆ Validator() [1/3]

CLI::Validator::Validator ( )
default

◆ Validator() [2/3]

CLI::Validator::Validator ( std::string  validator_desc)
inlineexplicit

Construct a Validator with just the description string.

◆ Validator() [3/3]

CLI::Validator::Validator ( std::function< std::string(std::string &)>  op,
std::string  validator_desc,
std::string  validator_name = "" 
)
inline

Construct Validator from basic information.

Member Function Documentation

◆ active() [1/2]

Validator & CLI::Validator::active ( bool  active_val = true)
inline

Specify whether the Validator is active or not.

◆ active() [2/2]

Validator CLI::Validator::active ( bool  active_val = true) const
inline

Specify whether the Validator is active or not.

◆ application_index() [1/2]

Validator & CLI::Validator::application_index ( int  app_index)
inline

Specify the application index of a validator.

◆ application_index() [2/2]

Validator CLI::Validator::application_index ( int  app_index) const
inline

Specify the application index of a validator.

◆ description() [1/2]

Validator & CLI::Validator::description ( std::string  validator_desc)
inline

Specify the type string.

◆ description() [2/2]

Validator CLI::Validator::description ( std::string  validator_desc) const
inline

Specify the type string.

◆ get_active()

bool CLI::Validator::get_active ( ) const
inline

Get a boolean if the validator is active.

◆ get_application_index()

int CLI::Validator::get_application_index ( ) const
inline

Get the current value of the application index.

◆ get_description()

std::string CLI::Validator::get_description ( ) const
inline

Generate type description information for the Validator.

Here is the caller graph for this function:

◆ get_modifying()

bool CLI::Validator::get_modifying ( ) const
inline

Get a boolean if the validator is allowed to modify the input returns true if it can modify the input.

◆ get_name()

const std::string & CLI::Validator::get_name ( ) const
inline

Get the name of the Validator.

Here is the caller graph for this function:

◆ name() [1/2]

Validator & CLI::Validator::name ( std::string  validator_name)
inline

Specify the type string.

Here is the caller graph for this function:

◆ name() [2/2]

Validator CLI::Validator::name ( std::string  validator_name) const
inline

Specify the type string.

◆ non_modifying()

Validator & CLI::Validator::non_modifying ( bool  no_modify = true)
inline

Specify whether the Validator can be modifying or not.

Here is the caller graph for this function:

◆ operation()

Validator & CLI::Validator::operation ( std::function< std::string(std::string &)>  op)
inline

Set the Validator operation function.

◆ operator!()

Validator CLI::Validator::operator! ( ) const
inline

Create a validator that fails when a given validator succeeds.

◆ operator&()

Validator CLI::Validator::operator& ( const Validator other) const
inline

Combining validators is a new validator. Type comes from left validator if function, otherwise only set if the same.

◆ operator()() [1/2]

std::string CLI::Validator::operator() ( const std::string &  str) const
inline

This is the required operator for a Validator - provided to help users (CLI11 uses the member func directly)

◆ operator()() [2/2]

std::string CLI::Validator::operator() ( std::string &  str) const
inline

This is the required operator for a Validator - provided to help users (CLI11 uses the member func directly)

◆ operator|()

Validator CLI::Validator::operator| ( const Validator other) const
inline

Combining validators is a new validator. Type comes from left validator if function, otherwise only set if the same.

Member Data Documentation

◆ active_

bool CLI::Validator::active_ {true}
protected

Enable for Validator to allow it to be disabled if need be.

◆ application_index_

int CLI::Validator::application_index_ = -1
protected

A Validator will only apply to an indexed value (-1 is all elements)

◆ desc_function_

std::function<std::string()> CLI::Validator::desc_function_ {[]() { return std::string{}; }}
protected

This is the description function, if empty the description_ will be used.

◆ func_

std::function<std::string(std::string &)> CLI::Validator::func_ {[](std::string &) { return std::string{}; }}
protected

This is the base function that is to be called. Returns a string error message if validation fails.

◆ name_

std::string CLI::Validator::name_ {}
protected

The name for search purposes of the Validator.

◆ non_modifying_

bool CLI::Validator::non_modifying_ {false}
protected

specify that a validator should not modify the input


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