![]() |
advgetopt 2.0.47
Parse complex command line arguments and configuration files in C++.
|
#include <validator_double.h>
Classes | |
struct | range_t |
Public Types | |
typedef std::shared_ptr< validator > | pointer_t |
typedef bool(* | to_double_t) (std::string const &number, double &result) |
typedef std::vector< pointer_t > | vector_t |
Public Member Functions | |
validator_double (string_list_t const &data) | |
Initialize the double validator. | |
virtual std::string | name () const override |
Return the name of this validator. | |
virtual bool | validate (std::string const &value) const override |
Determine whether value is a double. | |
Static Public Member Functions | |
static bool | convert_string (std::string const &number, double &result) |
Convert a string to a double value. | |
static pointer_t | create (std::string const &name, string_list_t const &data) |
static pointer_t | create (std::string const &name_and_params) |
Set the validator for this option. | |
static void | register_validator (validator_factory const &factory) |
Private Attributes | |
range_t::vector_t | f_allowed_values = range_t::vector_t() |
Definition at line 48 of file validator_double.h.
|
inherited |
Definition at line 64 of file validator.h.
typedef bool(* advgetopt::validator_double::to_double_t) (std::string const &number, double &result) |
Definition at line 52 of file validator_double.h.
|
inherited |
Definition at line 65 of file validator.h.
advgetopt::validator_double::validator_double | ( | string_list_t const & | range_list | ) |
The constructor accepts a string with values and ranges which are used to limit the values that can be used with this parameter.
Remember that the default does not have to be included in these values. It will still be viewed as valid.
The string uses the following format:
Note that a single number is considered to be a range and is managed the exact same way. A value which matches any of the ranges is considered valid.
The start and end values of a range are optional. If not specified, the start value is set to the minimum double value. If the not specified, the end value is set to the maximum double value.
Example:
This example allows all values between -10.01 and +10.05 inclusive and also allows the value 0.0005661.
This example allows all positive values and zero.
[in] | ranges | The ranges used to limit the double. |
Definition at line 133 of file validator_double.cpp.
References convert_string(), f_allowed_values, and advgetopt::option_flags_merge().
|
static |
This function is used to convert a string to a double with full boundary verification.
[in] | value | The value to be converted to a double. |
[out] | result | The resulting double. |
Definition at line 273 of file validator_double.cpp.
References advgetopt::option_flags_merge().
Referenced by validator_double(), advgetopt::validator_duration::convert_string(), advgetopt::validator_size::convert_string(), advgetopt::option_info_ref::get_double(), advgetopt::option_info::get_double(), advgetopt::getopt::get_double(), and validate().
|
staticinherited |
Definition at line 589 of file validator.cpp.
References advgetopt::validator::name(), and advgetopt::option_flags_merge().
Referenced by advgetopt::validator::create(), and advgetopt::option_info::set_validator().
|
staticinherited |
This function parses the specified name and optional parameters and create a corresponding validator for this option.
The name_and_params
string can be defined as:
The list of parameters is optional. There may be an empty, just one, or any number of parameters. How the parameters are parsed is left to the validator to decide.
If the input string is empty, the current validator, if one is installed, gets removed.
[in] | name_and_params | The validator name and parameters. |
Definition at line 626 of file validator.cpp.
References advgetopt::validator::create(), and advgetopt::option_flags_merge().
|
overridevirtual |
This function returns "double".
Implements advgetopt::validator.
Definition at line 207 of file validator_double.cpp.
|
staticinherited |
Definition at line 571 of file validator.cpp.
References advgetopt::option_flags_merge().
This function verifies that the specified value is a valid double.
It makes sures that the value is only composed of digits ([0-9]+
) and optionally has a decimal pointer followed by more digits and an optional exponent.
The number may also start with a sign ([-+]?
).
If ranges were defined, then the function also verifies that the value is within at least one of the ranges.
[in] | value | The value to validate. |
Implements advgetopt::validator.
Definition at line 230 of file validator_double.cpp.
References convert_string(), f_allowed_values, and advgetopt::option_flags_merge().
|
private |
Definition at line 74 of file validator_double.h.
Referenced by validator_double(), and validate().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.