Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
CLI::Bound Class Reference

Produce a bounded range (factory). Min and max are inclusive. More...

#include <CLI11.hpp>

Inheritance diagram for CLI::Bound:
Collaboration diagram for CLI::Bound:

Public Member Functions

template<typename T >
 Bound (T min, T max)
 
template<typename T >
 Bound (T max)
 Range of one value is 0 to value.
 
- Public Member Functions inherited from CLI::Validator
 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.
 

Additional Inherited Members

- Protected Attributes inherited from CLI::Validator
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

Definition at line 2540 of file CLI11.hpp.

Constructor & Destructor Documentation

◆ Bound() [1/2]

template<typename T >
CLI::Bound::Bound ( T min,
T max )
inline

This bounds a value with min and max inclusive.

Note that the constructor is templated, but the struct is not, so C++17 is not needed to provide nice syntax for Range(a,b).

Definition at line 2546 of file CLI11.hpp.

2546 {
2547 std::stringstream out;
2548 out << detail::type_name<T>() << " bounded to [" << min << " - " << max << "]";
2549 description(out.str());
2550
2551 func_ = [min, max](std::string &input) {
2552 T val;
2553 bool converted = detail::lexical_cast(input, val);
2554 if(!converted) {
2555 return std::string("Value ") + input + " could not be converted";
2556 }
2557 if(val < min)
2558 input = detail::to_string(min);
2559 else if(val > max)
2560 input = detail::to_string(max);
2561
2562 return std::string{};
2563 };
2564 }
Validator & description(std::string validator_desc)
Specify the type string.
Definition CLI11.hpp:2142
std::function< std::string(std::string &)> func_
Definition CLI11.hpp:2096
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)
Definition CLI11.hpp:1053
const T & min(const T &a, const T &b)
Definition utility.hpp:140
#define T(meth, val, expected)
Here is the call graph for this function:

◆ Bound() [2/2]

template<typename T >
CLI::Bound::Bound ( T max)
inlineexplicit

Definition at line 2567 of file CLI11.hpp.

2567: Bound(static_cast<T>(0), max) {}
Bound(T min, T max)
Definition CLI11.hpp:2546

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