advgetopt 2.0.47
Parse complex command line arguments and configuration files in C++.
Todo List
{advgetopt.cpp} Member advgetopt::anonymous_namespace{advgetopt.cpp}::g_system_options []
Add a --config option to allow the user to name one specific configuration file to use with an executable.
Member advgetopt::conf_file::get_conf_file (conf_file_setup const &setup)
With the communicator, we will at some point implement a class used to detect that a file changed, allowing us to get a signal and reload the file as required. This get_conf_file() function will greatly benefit from such since that way we can automatically reload the configuration file. In other words, process A could make a change, then process B reloads and sees the change that process A made. Such an implementation will require a proper locking mechanism of the configuration files while modifications are being performed. [Now that we have fluid settings, this is probably not required at all]
Member advgetopt::conf_file::read_configuration ()

Add support for quotes in configuration files as parameters are otherwise saved as a separated list of parameters losing the number of spaces between each entry.

Add support for reading a backup file if the main file is not found.

Member advgetopt::conf_file::save_configuration (std::string backup_extension=std::string(".bak"), bool replace_backup=false, bool prepend_warning=true, std::string output_filename=std::string())
Fix the canonicalization of the filename on a first save. Right now, the original filename was used but the path could change when saving (see the realpath() call in the constructor; this needs to be fixed).
Member advgetopt::conf_file::set_parameter (std::string section, std::string name, std::string const &value, assignment_t op=assignment_t::ASSIGNMENT_NONE, std::string const &comment=std::string())
The section/name combo should be dealt with inside this function instead of outside, especially if we are to support all the namespace operators.
Member advgetopt::conf_file_setup::get_config_url () const
We should look into have a set_config_url() or have a constructor which accepts a URL.
Member advgetopt::getopt::get_double (std::string const &name, int idx=0, double min=std::numeric_limits< double >::min(), double max=std::numeric_limits< double >::max()) const
Fix example with a parameter which makes sense (i.e. accepts doubles).
Member advgetopt::getopt::parse_options_from_file (std::string const &filename, int min_sections, int max_sections, bool ignore_duplicates=false)
Test that options get 100% updated on a reload.
Member advgetopt::getopt::process_configuration_file (std::string const &filename)
Extend the support by having the various flags that the conf_file class supports appear in the list of configuration filenames.
Member advgetopt::handle_user_directory (std::string const &filename)
Add support for "~<user name>/..." so that way a service could use its own home folder even when run from a different user (a.k.a. root). This requires that we load the user database and get the home folder from that data.
Member advgetopt::option_info::get_validator () const
Add a template function that does the cast for the caller.
Member advgetopt::option_info::set_multiple_separators (string_list_t const &separators)
See the other set_multiple_separators() function about the issue of the separators not being used in all cases.
Member advgetopt::option_info::set_multiple_separators (char const *const *separators)
At the moment, this is only applied when the parameter is specified with the long option and an equal sign, as in: --tags=a,b,c,d. I thinks that it should also work without the equal sign.
Member advgetopt::split_string (std::string const &str, string_list_t &result, string_list_t const &separators)
See to fix the fact that a"b"c becomes {"a", "b", "c"} when there are not separators between a, "b", and c. To the minimum we may want to generate an error when such is found (i.e. when a quote is found and start < pos is true.
Member advgetopt::unquote (std::string const &s, std::string const &pairs)
Add support for UTF-8 quotes. Right now only quotes of 1 byte will work.
Member advgetopt::validator_double::convert_string (std::string const &number, double &result)
This function calls std::strtod() which interprets the decimal separator depending on the current locale. We really want to only accept periods.
Member advgetopt::validator_duration::convert_string (std::string const &duration, flag_t flags, double &result)
The last multiplication doesn't verify that no overflow or underflow happens.
Member advgetopt::validator_integer::validate (std::string const &value) const override
Add support for binary, octal, hexadecimal.
Member advgetopt::validator_size::convert_string (std::string const &size, flag_t flags, __int128 &result)
We may want to support full names instead of just the minimal abbreviated suffixes (i.e. "3 bytes" fails). Also we could support bits but that is complicated because the only difference is whether you use upper or lower case characters (i.e. kB is kilo bytes, kb is kilo bits).
Member advgetopt::variables::process_value (std::string const &value) const
Consider having a cache, although for variables that would return system information, it could change at any time.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.