34#include <cppthread/log.h>
39#include <snapdev/trim_string.h>
44#include <snapdev/poison.h>
64 validator::register_validator(*
this);
69 return std::string(
"double");
74 return std::make_shared<validator_double>(data);
136 std::string::size_type
const pos(
r.find(
"..."));
137 if(
pos == std::string::npos)
141 cppthread::log << cppthread::log_level_t::error
143 <<
" is not a valid standalone value;"
144 " it must be a valid floating point,"
145 " optionally preceded by a sign (+ or -)."
153 std::string
const min_value(snapdev::trim_string(
r.substr(0,
pos)));
158 cppthread::log << cppthread::log_level_t::error
160 <<
" is not a valid value for your range's start;"
161 " it must be a valid floating point,"
162 " optionally preceded by a sign (+ or -)."
168 std::string
const max_value(snapdev::trim_string(
r.substr(
pos + 3)));
173 cppthread::log << cppthread::log_level_t::error
175 <<
" is not a valid value for your range's end;"
176 " it must be a valid floating point,"
177 " optionally preceded by a sign (+ or -)."
185 cppthread::log << cppthread::log_level_t::error
187 <<
" has to be smaller or equal to "
189 <<
"; you have an invalid range."
207 return std::string(
"double");
250 set_error(
"not a valid floating point number.");
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.
void set_error(std::string const &msg) const
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.