34#include <cppthread/log.h>
39#include <snapdev/not_used.h>
40#include <snapdev/trim_string.h>
45#include <snapdev/poison.h>
65 validator::register_validator(*
this);
70 return std::string(
"double");
75 snapdev::NOT_USED(data);
76 return std::make_shared<validator_double>(data);
138 std::string::size_type
const pos(
r.find(
"..."));
139 if(
pos == std::string::npos)
143 cppthread::log << cppthread::log_level_t::error
145 <<
" is not a valid standalone value;"
146 " it must be a valid floating point,"
147 " optionally preceeded by a sign (+ or -)."
155 std::string
const min_value(snapdev::trim_string(
r.substr(0,
pos)));
160 cppthread::log << cppthread::log_level_t::error
162 <<
" is not a valid value for your range's start;"
163 " it must be a valid floating point,"
164 " optionally preceeded by a sign (+ or -)."
170 std::string
const max_value(snapdev::trim_string(
r.substr(
pos + 3)));
175 cppthread::log << cppthread::log_level_t::error
177 <<
" is not a valid value for your range's end;"
178 " it must be a valid floating point,"
179 " optionally preceeded by a sign (+ or -)."
187 cppthread::log << cppthread::log_level_t::error
189 <<
" has to be smaller or equal to "
191 <<
"; you have an invalid range."
209 return std::string(
"double");
275 char const *
start(value.c_str());
293 return end ==
start + value.length()
validator_double_factory()
virtual std::string get_name() const override
virtual std::shared_ptr< validator > create(string_list_t const &data) const override
virtual bool validate(std::string const &value) const override
Determine whether value is a double.
virtual std::string name() const override
Return the name of this validator.
range_t::vector_t f_allowed_values
static bool convert_string(std::string const &number, double &result)
Convert a string to a double value.
validator_double(string_list_t const &data)
Initialize the double validator.
validator_double_factory g_validator_double_factory
The advgetopt environment to parse command line options.
constexpr flag_t option_flags_merge()
std::vector< std::string > string_list_t
Declaration of validators which can be used to verify the parameters.