40#include    <cppthread/log.h> 
   50#include    <snapdev/poison.h> 
  103        return opt->is_defined();
 
 
  161        return opt->has_default();
 
 
  196        return opt->get_default();
 
  199    return std::string();
 
 
  253        throw getopt_logic_error(
 
  256                + 
" option defined.");
 
  260    if(!opt->is_defined())
 
  262        std::string 
const d(opt->get_default());
 
  265            throw getopt_logic_error(
 
  268                    + 
" option was not defined on the command line and it has no or an empty default.");
 
  275            throw getopt_logic_error(
 
  276                      "invalid default number \"" 
  284        result = opt->get_long(idx);
 
  289    if(result < min || result > max)
 
  291        cppthread::log << cppthread::log_level_t::error
 
  293                       << 
" is out of bounds (" 
  297                       << 
" inclusive) in parameter --" 
 
  361        throw getopt_logic_error(
 
  364                + 
" option defined.");
 
  368    if(!opt->is_defined())
 
  370        std::string 
const d(opt->get_default());
 
  373            throw getopt_logic_error(
 
  376                    + 
" option was not defined on the command line and it has no or an empty default.");
 
  383            throw getopt_logic_error(
 
  384                      "invalid default number \"" 
  393        result = opt->get_double(idx);
 
  398    if(result < min || result > max)
 
  400        cppthread::log << cppthread::log_level_t::error
 
  402                       << 
" is out of bounds (" 
  406                       << 
" inclusive) in parameter --" 
 
  443      std::string 
const & name
 
  452        throw getopt_logic_error(
 
  455                + 
" option defined.");
 
  458    if(!opt->is_defined())
 
  460        if(opt->has_default())
 
  462            return opt->get_default();
 
  464        throw getopt_logic_error(
 
  467                + 
" option was not defined on the command line and it has no default.");
 
  473    std::string 
const value(opt->get_value(idx, raw));
 
  475    && opt->has_default()
 
  478        return opt->get_default();
 
 
  505        throw getopt_logic_error(
"argument name cannot be empty.");
 
  511        return std::string();
 
  514    if(!opt->is_defined())
 
  516        if(opt->has_default())
 
  518            return opt->get_default();
 
  520        return std::string();
 
  523    return opt->get_value(0);
 
 
  583        throw getopt_logic_error(
"argument name cannot be empty.");
 
  589        if(name.length() == 1)
 
  591            throw getopt_logic_error(
"argument name cannot be one letter if it does not exist in operator [].");
 
  596        opt = std::make_shared<option_info>(name);
 
 
  649            out << 
"warning: no version found." << std::endl;
 
  697            if(grp->f_name != 
nullptr 
  698            && *grp->f_name != 
'\0')
 
  700                std::string 
const name(grp->f_name);
 
  701                std::string 
const option_name(name + 
"-help");
 
  723            out << 
"warning: no copyright notice found." << std::endl;
 
  737            out << 
"warning: no license found." << std::endl;
 
  768                << 
" does not support an environment variable." 
  785                << 
" does not support configuration files." 
  790            out << 
"Configuration filenames:" << std::endl;
 
  793                out << 
" . " << n << std::endl;
 
  805            out << 
"/usr/share/advgetopt/options/" << std::endl;
 
  838        std::string 
const name(
get_string(
"print-option"));
 
 
Definitions of the advanced getopt class.
std::string get_string(std::string const &name, int idx=0, bool raw=false) const
Get the content of an option as a string.
string_list_t get_configuration_filenames(bool exists, bool writable, int argc=0, char *argv[]=nullptr) const
Generate a list of configuration filenames.
std::size_t size(std::string const &name) const
Retrieve the number of arguments.
options_environment f_options_environment
option_info::map_by_name_t f_options_by_name
bool is_defined(std::string const &name) const
Check whether a parameter is defined.
option_info::pointer_t get_option(std::string const &name, bool exact_option=false) const
Retrieve an option by name.
double get_double(std::string const &name, int idx=0, double min=std::numeric_limits< double >::min(), double max=std::numeric_limits< double >::max()) const
This function retrieves an argument as a double value.
std::string operator[](std::string const &name) const
Retrieve the value of an argument.
std::string get_default(std::string const &name) const
Get the default value for this option.
bool has_default(std::string const &name) const
Check whether an option has a default value.
void is_parsed() const
Verify that the parser is done.
flag_t process_system_options(std::basic_ostream< char > &out)
Process the system options.
long get_long(std::string const &name, int idx=0, long min=std::numeric_limits< long >::min(), long max=std::numeric_limits< long >::max()) const
This function retrieves an argument as a long value.
void show_option_sources(std::basic_ostream< char > &out)
Output the source of each option.
variables::pointer_t f_variables
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.
Declaration of the conf_file class used to read a configuration file.
Definitions of the advanced getopt exceptions.
The advgetopt environment to parse command line options.
static constexpr flag_t GETOPT_FLAG_SHOW_SYSTEM
constexpr flag_t SYSTEM_OPTION_HELP
static constexpr flag_t GETOPT_FLAG_DYNAMIC_CONFIGURATION
void less(std::basic_ostream< char > &out, std::string const &data)
Print out a string to the console or use less.
constexpr flag_t SYSTEM_OPTION_BUILD_DATE
static constexpr flag_t GETOPT_FLAG_GROUP_NONE
constexpr flag_t SYSTEM_OPTION_SHOW_OPTION_VALUE
constexpr flag_t SYSTEM_OPTION_NONE
constexpr flag_t SYSTEM_OPTION_VERSION
constexpr flag_t SYSTEM_OPTION_PATH_TO_OPTION_DEFINITIONS
constexpr flag_t SYSTEM_OPTION_LICENSE
constexpr flag_t SYSTEM_OPTION_CONFIGURATION_FILENAMES
constexpr flag_t SYSTEM_OPTION_CONFIG_DIR
std::string sanitizer_details()
Generate a string describing whether we're using the sanitizer.
static constexpr flag_t GETOPT_FLAG_REQUIRED
constexpr flag_t SYSTEM_OPTION_COPYRIGHT
constexpr flag_t SYSTEM_OPTION_ENVIRONMENT_VARIABLE_NAME
std::vector< std::string > string_list_t
static constexpr flag_t GETOPT_FLAG_SHOW_ALL
constexpr flag_t SYSTEM_OPTION_SHOW_OPTION_SOURCES
char const  * f_build_date
char const  * f_options_files_directory
char const  * f_build_time
char const  * f_project_name
char const  * f_environment_variable_name
group_description const  * f_groups
Declaration of validators which can be used to verify the parameters.
Declaration of validators which can be used to verify the parameters.
Definitions of the advanced getopt class version.
#define LIBADVGETOPT_COMPILER_VERSION