37#include    <cppthread/log.h> 
   42#include    <libutf8/libutf8.h> 
   47#include    <snapdev/trim_string.h> 
   52#include    <snapdev/poison.h> 
   73        validator::register_validator(*
this);
 
 
   78        return std::string(
"length");
 
 
   83        return std::make_shared<validator_length>(data);
 
 
 
 
  102        std::string::size_type 
const pos(
r.find(
"..."));
 
  103        if(
pos == std::string::npos)
 
  107                cppthread::log << cppthread::log_level_t::error
 
  109                               << 
" is not a valid standalone value for your ranges;" 
  110                                  " it must only be digits, optionally preceeded by a sign (+ or -)" 
  111                                  " and not overflow an int64_t value." 
  119            std::string 
const min_value(snapdev::trim_string(
r.substr(0, 
pos)));
 
  124                    cppthread::log << cppthread::log_level_t::error
 
  126                                   << 
" is not a valid value for your range's start;" 
  127                                      " it must only be digits, optionally preceeded by a sign (+ or -)" 
  128                                      " and not overflow an int64_t value." 
  134            std::string 
const max_value(snapdev::trim_string(
r.substr(
pos + 3)));
 
  139                    cppthread::log << cppthread::log_level_t::error
 
  141                                   << 
" is not a valid value for your range's end;" 
  142                                      " it must only be digits, optionally preceeded by a sign (+ or -)" 
  143                                      " and not overflow an int64_t value." 
  151                cppthread::log << cppthread::log_level_t::error
 
  153                               << 
" has to be smaller or equal to " 
  155                               << 
"; you have an invalid range." 
 
  173    return std::string(
"length");
 
 
  194    std::int64_t 
const length(
static_cast<std::int64_t
>(libutf8::u8length(value)));
 
  197        if(length >= 
f.f_minimum
 
  198        && length <= 
f.f_maximum)
 
 
virtual std::string get_name() const override
virtual std::shared_ptr< validator > create(string_list_t const &data) const override
validator_length_factory()
static bool convert_string(std::string const &number, std::int64_t &result)
Convert a string to an std::int64_t value.
virtual bool validate(std::string const &value) const override
Check the value against a list of length ranges.
virtual std::string name() const override
Return the name of this validator.
range_t::vector_t f_allowed_lengths
validator_length(string_list_t const &data)
validator_length_factory g_validator_length_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 the length validator.