93 ,
bool ignore_duplicates =
false);
95 std::string
const & filename
98 ,
bool ignore_duplicates =
false);
101 ,
bool ignore_duplicates =
false);
104 std::string
const & name
113 ,
char * argv[] =
nullptr);
121 std::string
const & str
123 ,
bool only_environment_variable =
false);
128 ,
bool only_environment_variable =
false);
131 , std::string
const & value
132 , std::string
const & filename
141 std::string
const & name
142 ,
bool exact_option =
false)
const;
145 ,
bool exact_option =
false)
const;
147 bool include_progname =
false
148 ,
bool keep_defaults =
false)
const;
149 bool is_defined(std::string
const & name)
const;
150 std::size_t
size(std::string
const & name)
const;
152 std::string
get_default(std::string
const & name)
const;
154 std::string
const & name
156 ,
long min = std::numeric_limits<long>::min()
157 ,
long max = std::numeric_limits<long>::max())
const;
159 std::string
const & name
161 ,
double min = std::numeric_limits<double>::min()
162 ,
double max = std::numeric_limits<double>::max())
const;
164 std::string
const & name
166 ,
bool raw =
false)
const;
167 std::string
operator [] (std::string
const & name)
const;
184 ,
char * argv[] =
nullptr)
const;
207 ,
char * argv[])
const;
210 ,
bool writable)
const;
Class used to parse command line options.
std::string get_group_name() const
Retrieve the group name if one is defined.
std::string get_string(std::string const &name, int idx=0, bool raw=false) const
Get the content of an option as a string.
std::string options_to_string(bool include_progname=false, bool keep_defaults=false) const
Transform all the defined options back in 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::string get_group_or_project_name() const
Retrieve the group or project name.
std::size_t size(std::string const &name) const
Retrieve the number of arguments.
options_environment f_options_environment
option_info::pointer_t get_alias_destination(option_info::pointer_t opt) const
Return the alias if there is one.
void initialize_parser(options_environment const &opt_env)
Initialize the parser.
void add_option_from_string(option_info::pointer_t opt, std::string const &value, std::string const &filename, string_list_t const &option_keys, option_source_t source=option_source_t::SOURCE_DIRECT)
Add an option with a value defined in a string.
void get_managed_configuration_filenames(string_list_t &names, bool writable, int argc, char *argv[]) const
Generate the list of managed configuration filenames.
void process_configuration_file(std::string const &filename)
Parse one specific configuration file and process the results.
void parse_configuration_files(int argc=0, char *argv[]=nullptr)
This function checks for arguments in configuration files.
void add_options(option_info::pointer_t opt, int &i, int argc, char **argv, string_list_t const &option_keys, option_source_t source=option_source_t::SOURCE_DIRECT)
Read parameters of the current option.
void get_direct_configuration_filenames(string_list_t &names, bool writable) const
Define the list of direct configuration filenames.
option_info::map_by_name_t f_options_by_name
void parse_string(std::string const &str, option_source_t source=option_source_t::SOURCE_DIRECT, bool only_environment_variable=false)
Parse a string similar to a command line argument.
std::string f_program_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.
std::string usage(flag_t show=GETOPT_FLAG_SHOW_MOST) const
Create a string of the command line arguments.
std::string get_environment_variable() const
void add_option(option_info::pointer_t opt, bool ignore_duplicates=false)
Add one option to the advgetopt object.
void parse_environment_variable()
Check for an environment variable.
option_info::map_by_short_name_t f_options_by_short_name
std::shared_ptr< getopt > pointer_t
static string_list_t find_config_dir(int argc, char *argv[])
Search for the "--config-dir" option in a set of arguments.
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 get_program_fullname() const
Get the full name of the program.
std::string operator[](std::string const &name) const
Retrieve the value of an argument.
void define_environment_variable_data()
Retrieve the environment variable string.
std::string get_default(std::string const &name) const
Get the default value for this option.
std::string f_program_fullname
static void add_configuration_filename(string_list_t &names, std::string const &add)
Add one configuration filename to our list.
variables::pointer_t get_variables() const
Retrieve a pointer to the variables defined in the getopt object.
std::string get_environment_variable_name() const
bool has_default(std::string const &name) const
Check whether an option has a default value.
std::string get_options_filename() const
Get the path and filename to options.
size_t get_configuration_filename_size() const
void parse_arguments(int argc, char *argv[], option_source_t source=option_source_t::SOURCE_DIRECT, bool only_environment_variable=false)
Parse an array of arguments.
void parse_options_info(option const *opts, bool ignore_duplicates=false)
Parse the options to option_info objects.
void parse_options_from_file()
Check for a file with option definitions.
void parse_program_name(char *argv[])
Transform the argv[0] parameter in the program name.
std::string f_environment_variable
std::string get_program_name() const
Get the basename of the program.
void is_parsed() const
Verify that the parser is done.
options_environment const & get_options_environment() const
Return a reference to the options environment.
void reset()
Reset all the options.
std::string get_project_name() const
Retrieve the project name if one is defined.
flag_t process_system_options(std::basic_ostream< char > &out)
Process the system options.
bool has_flag(flag_t flag) const
Check whether an environment flag is set or not.
void link_aliases()
Link options marked as a GETOPT_FLAG_ALIAS.
static string_list_t split_environment(std::string const &environment)
Transform a string in an array of arguments.
group_description const * find_group(flag_t group) const
Search for group in the list of group names.
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.
std::string get_output_filename() const
Determine the best suited file for updates.
std::string get_configuration_filename(int idx) const
option_info::map_by_name_t const & get_options() const
Retrieve the complete list of options.
void show_option_sources(std::basic_ostream< char > &out)
Output the source of each option.
void finish_parsing(int argc, char *argv[])
Actually parse everything.
void parse_options_from_group_names()
Transform group names in –<name>-help commands.
variables::pointer_t f_variables
option_info::pointer_t f_default_option
void set_short_name(std::string const &name, short_name_t short_name)
Assign a short name to an option.
std::string process_help_string(char const *help) const
Change the % flags in help strings.
static string_list_t parse_option_map(std::string const &raw_key)
Parse a map following an option name.
std::map< std::string, pointer_t > map_by_name_t
std::shared_ptr< option_info > pointer_t
std::map< short_name_t, pointer_t > map_by_short_name_t
std::shared_ptr< variables > pointer_t
The advgetopt environment to parse command line options.
constexpr flag_t SYSTEM_OPTION_HELP
constexpr flag_t SYSTEM_OPTION_BUILD_DATE
constexpr flag_t SYSTEM_OPTION_OPTIONS_MASK
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_COMMANDS_MASK
constexpr flag_t SYSTEM_OPTION_LICENSE
constexpr flag_t SYSTEM_OPTION_CONFIGURATION_FILENAMES
constexpr flag_t SYSTEM_OPTION_CONFIG_DIR
static constexpr flag_t GETOPT_FLAG_SHOW_MOST
constexpr flag_t SYSTEM_OPTION_COPYRIGHT
constexpr flag_t SYSTEM_OPTION_ENVIRONMENT_VARIABLE_NAME
std::vector< std::string > string_list_t
constexpr char const CONFIGURATION_SECTIONS[]
constexpr flag_t SYSTEM_OPTION_SHOW_OPTION_SOURCES
Declaration of the option_info class used to record available options.
Definitions of the options class a initialization functions.
Structure representing an option.
Declaration of validators which can be used to verify the parameters.
Declaration of the variable class.