39#include <cppthread/log.h>
44#include <libutf8/libutf8.h>
49#include <snapdev/poison.h>
90 if(
f_opt->is_defined())
92 return f_opt->get_value().empty();
112 if(
f_opt->is_defined())
114 return f_opt->get_value().length();
117 return f_opt->get_default().length();
149 if(
f_opt->is_defined())
151 return f_opt->get_long();
154 if(!
f_opt->has_default())
162 cppthread::log << cppthread::log_level_t::error
163 <<
"invalid default value for a number ("
164 <<
f_opt->get_default()
165 <<
") in parameter --"
192 if(
f_opt->is_defined())
194 return f_opt->get_double();
197 if(!
f_opt->has_default())
205 cppthread::log << cppthread::log_level_t::error
206 <<
"invalid default value as a double number ("
207 <<
f_opt->get_default()
208 <<
") in parameter --"
226option_info_ref::operator std::string ()
const
228 if(f_opt->is_defined())
230 return f_opt->get_value();
233 return f_opt->get_default();
276 v = libutf8::to_u8string(value);
296 f_opt->set_value(0, std::string());
300 f_opt->set_value(0, value);
317 f_opt->set_value(0, value);
333 f_opt->set_value(0, value);
358 f_opt->set_value(0,
static_cast<std::string
>(*
this) +
v);
377 v += libutf8::to_u8string(value);
379 f_opt->set_value(0,
static_cast<std::string
>(*
this) +
v);
400 f_opt->set_value(0,
static_cast<std::string
>(*
this) +
v);
416 f_opt->set_value(0,
static_cast<std::string
>(*
this) + value);
434 ,
static_cast<std::string
>(*
this) +
static_cast<std::string
>(value));
454 return static_cast<std::string
>(*this) + value;
469 return static_cast<std::string
>(*this) + libutf8::to_u8string(value);
488 return static_cast<std::string
>(*this) + value;
503 return static_cast<std::string
>(*this) + value;
518 return static_cast<std::string
>(*this)
519 +
static_cast<std::string
>(value);
535 return value +
static_cast<std::string
>(
rhs);
551 return libutf8::to_u8string(value) +
static_cast<std::string
>(
rhs);
571 return value +
static_cast<std::string
>(
rhs);
587 return value +
static_cast<std::string
>(
rhs);
597option_info_ref::operator
bool ()
const
629 return static_cast<std::string
>(*this) == value;
643 return static_cast<std::string
>(*this) == value;
658 return static_cast<std::string
>(*this) ==
static_cast<std::string
>(value);
676 return static_cast<std::string
>(*this) != value;
690 return static_cast<std::string
>(*this) != value;
705 return static_cast<std::string
>(*this) !=
static_cast<std::string
>(value);
723 return static_cast<std::string
>(*this) < value;
737 return static_cast<std::string
>(*this) < value;
752 return static_cast<std::string
>(*this) <
static_cast<std::string
>(value);
770 return static_cast<std::string
>(*this) <= value;
784 return static_cast<std::string
>(*this) <= value;
799 return static_cast<std::string
>(*this) <=
static_cast<std::string
>(value);
817 return static_cast<std::string
>(*this) > value;
831 return static_cast<std::string
>(*this) > value;
846 return static_cast<std::string
>(*this) >
static_cast<std::string
>(value);
864 return static_cast<std::string
>(*this) >= value;
878 return static_cast<std::string
>(*this) >= value;
893 return static_cast<std::string
>(*this) >=
static_cast<std::string
>(value);
914 return value ==
static_cast<std::string
>(
rhs);
930 return value ==
static_cast<std::string
>(
rhs);
950 return value !=
static_cast<std::string
>(
rhs);
966 return value !=
static_cast<std::string
>(
rhs);
1018 if(value ==
nullptr)
1054 if(value ==
nullptr)
1058 return value >
static_cast<std::string
>(
rhs);
1074 return value >
static_cast<std::string
>(
rhs);
1090 if(value ==
nullptr)
1094 return value >=
static_cast<std::string
>(
rhs);
1110 return value >=
static_cast<std::string
>(
rhs);
size_t length() const
Return the length of the option's value.
size_t size() const
Return the length of the option's value.
friend bool operator>(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
bool operator!() const
Check whether the value is an empty string or not.
friend bool operator<=(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
long get_long() const
Retrieve the referenced option as a long.
double get_double() const
Retrieve the referenced option as a double.
bool empty() const
Retrieve the length of the option's value.
option_info::pointer_t f_opt
option_info_ref & operator+=(char value)
Append the character value to this option's value.
friend bool operator<(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
friend bool operator!=(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
friend std::string operator+(char value, option_info_ref const &rhs)
Concatenate a character and an option reference value.
friend bool operator==(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
option_info_ref(option_info::pointer_t opt)
Initialize a reference to an option_info object.
option_info_ref & operator=(char value)
Set the option value to value.
friend bool operator>=(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
std::shared_ptr< option_info > pointer_t
static bool convert_string(std::string const &number, double &result)
Convert a string to a double value.
static bool convert_string(std::string const &number, std::int64_t &result)
Convert a string to an std::int64_t value.
Definitions of the advanced getopt exceptions.
The advgetopt environment to parse command line options.
bool operator<(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
constexpr flag_t option_flags_merge()
bool operator==(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
bool operator>=(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
std::string operator+(char value, option_info_ref const &rhs)
Concatenate a character and an option reference value.
bool operator<=(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
bool operator>(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
bool operator!=(char const *value, option_info_ref const &rhs)
Compare value with the value of the right hand-side option.
Declaration of the option_info class used to record available options.
Declaration of validators which can be used to verify the parameters.
Declaration of validators which can be used to verify the parameters.