Scarab  v3.4.1
Project 8 C++ Utility Library
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Validator Class Reference

Some validators that are provided. More...

#include <CLI11.hpp>

Inheritance diagram for Validator:
Inheritance graph

Public Member Functions

 Validator ()=default
 
 Validator (std::string validator_desc)
 Construct a Validator with just the description string. More...
 
 Validator (std::function< std::string(std::string &)> op, std::string validator_desc, std::string validator_name="")
 
Validatoroperation (std::function< std::string(std::string &)> op)
 Set the Validator operation function. More...
 
std::string operator() (std::string &str) const
 
std::string operator() (const std::string &str) const
 
Validatordescription (std::string validator_desc)
 Specify the type string. More...
 
std::string get_description () const
 Generate type description information for the Validator. More...
 
Validatorname (std::string validator_name)
 Specify the type string. More...
 
const std::string & get_name () const
 Get the name of the Validator. More...
 
Validatoractive (bool active_val=true)
 Specify whether the Validator is active or not. More...
 
Validatornon_modifying (bool no_modify=true)
 Specify whether the Validator can be modifying or not. More...
 
bool get_active () const
 Get a boolean if the validator is active. More...
 
bool get_modifying () const
 Get a boolean if the validator is allowed to modify the input returns true if it can modify the input. More...
 
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. More...
 

Protected Attributes

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

Private Member Functions

void _merge_description (const Validator &val1, const Validator &val2, const std::string &merger)
 

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.

Definition at line 1551 of file CLI11.hpp.

Constructor & Destructor Documentation

◆ Validator() [1/3]

Validator ( )
default

◆ Validator() [2/3]

Validator ( std::string  validator_desc)
inlineexplicit

Construct a Validator with just the description string.

Definition at line 1569 of file CLI11.hpp.

◆ Validator() [3/3]

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

Definition at line 1571 of file CLI11.hpp.

Member Function Documentation

◆ _merge_description()

void _merge_description ( const Validator val1,
const Validator val2,
const std::string &  merger 
)
inlineprivate

Definition at line 1708 of file CLI11.hpp.

◆ active()

Validator& active ( bool  active_val = true)
inline

Specify whether the Validator is active or not.

Definition at line 1621 of file CLI11.hpp.

◆ description()

Validator& description ( std::string  validator_desc)
inline

Specify the type string.

Definition at line 1602 of file CLI11.hpp.

◆ get_active()

bool get_active ( ) const
inline

Get a boolean if the validator is active.

Definition at line 1633 of file CLI11.hpp.

◆ get_description()

std::string get_description ( ) const
inline

Generate type description information for the Validator.

Definition at line 1607 of file CLI11.hpp.

◆ get_modifying()

bool get_modifying ( ) const
inline

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

Definition at line 1636 of file CLI11.hpp.

◆ get_name()

const std::string& get_name ( ) const
inline

Get the name of the Validator.

Definition at line 1619 of file CLI11.hpp.

◆ name()

Validator& name ( std::string  validator_name)
inline

Specify the type string.

Definition at line 1614 of file CLI11.hpp.

◆ non_modifying()

Validator& non_modifying ( bool  no_modify = true)
inline

Specify whether the Validator can be modifying or not.

Definition at line 1627 of file CLI11.hpp.

◆ operation()

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

Set the Validator operation function.

Definition at line 1575 of file CLI11.hpp.

◆ operator &()

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.

Definition at line 1640 of file CLI11.hpp.

◆ operator!()

Validator operator! ( ) const
inline

Create a validator that fails when a given validator succeeds.

Definition at line 1686 of file CLI11.hpp.

◆ operator()() [1/2]

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

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

Definition at line 1581 of file CLI11.hpp.

◆ operator()() [2/2]

std::string 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)

Definition at line 1596 of file CLI11.hpp.

◆ operator|()

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.

Definition at line 1664 of file CLI11.hpp.

Member Data Documentation

◆ active_

bool active_ {true}
protected

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

Definition at line 1562 of file CLI11.hpp.

◆ desc_function_

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

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

Definition at line 1554 of file CLI11.hpp.

◆ func_

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

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

Definition at line 1558 of file CLI11.hpp.

◆ name_

std::string name_
protected

The name for search purposes of the Validator.

Definition at line 1560 of file CLI11.hpp.

◆ non_modifying_

bool non_modifying_ {false}
protected

specify that a validator should not modify the input

Definition at line 1564 of file CLI11.hpp.


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