49#include <cppthread/log.h>
54#include <snapdev/int128_literal.h>
55#include <snapdev/math.h>
60#include <snapdev/poison.h>
81 validator::register_validator(*
this);
86 return std::string(
"size");
91 return std::make_shared<validator_size>(data);
137 else if(
r ==
"legacy")
143 cppthread::log << cppthread::log_level_t::error
145 <<
" is not a valid flag for the size validator."
161 return std::string(
"size");
177#pragma GCC diagnostic push
178#pragma GCC diagnostic ignored "-Wpedantic"
181 using namespace snapdev::literals;
188 set_error(
"invalid size suffix or number.");
191#pragma GCC diagnostic pop
248#pragma GCC diagnostic push
249#pragma GCC diagnostic ignored "-Wpedantic"
251 std::string
const & value
255 using namespace snapdev::literals;
260 std::string::size_type
pos(value.length());
263 char c(value[
pos - 1]);
279 std::string
const number(value.substr(0,
pos));
281 if(
pos < value.length())
288 for(;
pos < value.length(); ++
pos)
291 && value[
pos] <=
'Z')
477#pragma GCC diagnostic pop
virtual std::string get_name() const override
virtual std::shared_ptr< validator > create(string_list_t const &data) const override
static bool convert_string(std::string const &number, double &result)
Convert a string to a double value.
static constexpr flag_t VALIDATOR_SIZE_POWER_OF_TWO
static bool convert_string(std::string const &size, flag_t flags, __int128 &result)
Convert a string to a large integer (128 bits) value representing a size.
virtual std::string name() const override
Return the name of this validator.
validator_size(string_list_t const &data)
Initialize the size validator.
virtual bool validate(std::string const &value) const override
Determine whether value is a valid size.
void set_error(std::string const &msg) const
validator_size_factory g_validator_size_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.
Declaration of validators which can be used to verify the parameters.