advgetopt 2.0.47
Parse complex command line arguments and configuration files in C++.
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
advgetopt Namespace Reference

The advgetopt environment to parse command line options. More...

Namespaces

namespace  anonymous_namespace{advgetopt.cpp}
 
namespace  anonymous_namespace{advgetopt_string.cpp}
 
namespace  anonymous_namespace{conf_file.cpp}
 Private conf_file data.
 
namespace  anonymous_namespace{option_info.cpp}
 
namespace  anonymous_namespace{utils.cpp}
 
namespace  anonymous_namespace{validator.cpp}
 
namespace  anonymous_namespace{validator_double.cpp}
 
namespace  anonymous_namespace{validator_duration.cpp}
 
 
namespace  anonymous_namespace{validator_integer.cpp}
 
namespace  anonymous_namespace{validator_keywords.cpp}
 
namespace  anonymous_namespace{validator_length.cpp}
 
namespace  anonymous_namespace{validator_list.cpp}
 
namespace  anonymous_namespace{validator_regex.cpp}
 
namespace  anonymous_namespace{validator_size.cpp}
 

Classes

class  Alias
 
class  conf_file
 
class  conf_file_setup
 
class  DefaultValue
 
class  EnvironmentVariableName
 
class  Flags
 
class  getopt
 Class used to parse command line options. More...
 
class  getopt_exit
 
struct  group_description
 
class  GroupDescription
 
class  GroupName
 
class  GroupNumber
 
class  GroupValue
 
class  Help
 
class  Name
 
struct  option
 Structure representing an option. More...
 
class  option_info
 
class  option_info_ref
 
struct  options_environment
 
class  OptionValue
 
class  parameter_value
 
class  Separators
 
class  ShortName
 
class  usage_flag_traits
 
class  usage_letter_traits
 
class  Validator
 
class  validator
 
class  validator_double
 
class  validator_duration
 
class  validator_email
 
class  validator_factory
 
class  validator_integer
 
class  validator_keywords
 
class  validator_length
 
class  validator_list
 
class  validator_regex
 
class  validator_size
 
class  variables
 

Typedefs

typedef std::uint_fast16_t assignment_operator_t
 
typedef std::uint_fast16_t comment_t
 
typedef std::uint32_t flag_t
 
typedef std::uint_fast16_t name_separator_t
 
typedef std::uint_fast16_t section_operator_t
 
typedef char32_t short_name_t
 
typedef std::vector< std::string > string_list_t
 
typedef std::set< std::string > string_set_t
 

Enumerations

enum class  assignment_t {
  ASSIGNMENT_NONE ,
  ASSIGNMENT_SET ,
  ASSIGNMENT_OPTIONAL ,
  ASSIGNMENT_APPEND ,
  ASSIGNMENT_NEW
}
 
enum class  callback_action_t {
  created ,
  updated ,
  erased
}
 
enum class  line_continuation_t {
  line_continuation_single_line ,
  line_continuation_rfc_822 ,
  line_continuation_msdos ,
  line_continuation_unix ,
  line_continuation_fortran ,
  line_continuation_semicolon
}
 
enum class  option_source_t {
  SOURCE_COMMAND_LINE ,
  SOURCE_CONFIGURATION ,
  SOURCE_DIRECT ,
  SOURCE_DYNAMIC ,
  SOURCE_ENVIRONMENT_VARIABLE ,
  SOURCE_UNDEFINED
}
 

Functions

template<flag_t ... args>
constexpr flag_t all_flags ()
 
template<flag_t ... args>
constexpr flag_t any_flags ()
 
std::string breakup_line (std::string line, size_t const option_width, size_t const line_width)
 Breakup a string on multiple lines.
 
std::string breakup_line (std::string line, std::size_t const option_width, std::size_t const line_width)
 
template<flag_t flag, flag_t ... args>
constexpr flag_t combine_option_flags ()
 
template<flag_t ... args>
constexpr flag_t command_flags ()
 
template<flag_t ... args>
constexpr flag_t config_flags ()
 
 DECLARE_EXCEPTION (getopt_exception, getopt_defined_twice)
 
 DECLARE_EXCEPTION (getopt_exception, getopt_initialization)
 
 DECLARE_EXCEPTION (getopt_exception, getopt_invalid)
 
 DECLARE_EXCEPTION (getopt_exception, getopt_invalid_default)
 
 DECLARE_EXCEPTION (getopt_exception, getopt_invalid_parameter)
 
 DECLARE_EXCEPTION (getopt_exception, getopt_root_filename)
 
 DECLARE_EXCEPTION (getopt_exception, getopt_undefined)
 
 DECLARE_LOGIC_ERROR (getopt_logic_error)
 
 DECLARE_MAIN_EXCEPTION (getopt_exception)
 
std::string default_group_name (std::string const &filename, char const *group_name, char const *project_name, int priority)
 Generate the default filename (the ".../50-...")
 
template<class ... ARGS>
constexpr group_description define_group (ARGS ...args)
 
template<class ... ARGS>
constexpr option define_option (ARGS ...args)
 
constexpr flag_t end_flags ()
 
constexpr group_description end_groups ()
 
constexpr option end_options ()
 
std::string escape_shell_argument (std::string const &arg)
 Escape special characters from a shell argument.
 
template<typename T , typename F , class ... ARGS>
constexpr std::enable_if< std::is_same< T, F >::value, typenameT::value_t >::type find_group (F first, ARGS ...args)
 
template<typename T , typename F , class ... ARGS>
constexpr std::enable_if<!std::is_same< T, F >::value, typenameT::value_t >::type find_group (F first, ARGS ...args)
 
template<typename T , typename F , class ... ARGS>
constexpr std::enable_if< std::is_same< T, F >::value, typenameT::value_t >::type find_option (F first, ARGS ...args)
 
template<typename T , typename F , class ... ARGS>
constexpr std::enable_if<!std::is_same< T, F >::value, typenameT::value_t >::type find_option (F first, ARGS ...args)
 
std::string format_usage_string (std::string const &argument, std::string const &help, size_t const option_width, size_t const line_width)
 Format a help string to make it fit on a given width.
 
std::string format_usage_string (std::string const &argument, std::string const &help, std::size_t const option_width, std::size_t const line_width)
 
cppthread::mutex & get_global_mutex ()
 Get a global mutex.
 
int get_major_version ()
 Get the major version of the library.
 
int get_patch_version ()
 Get the patch version of the library.
 
int get_release_version ()
 Get the release version of the library.
 
size_t get_screen_height ()
 Retrieve the height of your console.
 
size_t get_screen_width ()
 Retrieve the width of one line in your console.
 
char constget_version_string ()
 Get the full version of the library as a string.
 
std::string handle_user_directory (std::string const &filename)
 Replace a starting ~/... with the contents of the $HOME variable.
 
string_list_t insert_group_name (std::string const &filename, char const *group_name, char const *project_name, bool add_default_on_empty)
 Insert the group (or project) name in the filename.
 
bool is_false (std::string s)
 Check whether a value represents "false".
 
bool is_true (std::string s)
 Check whether a value represents "true".
 
bool iswspace (int c)
 Returns true if c is considered to be a whitespace.
 
void less (std::basic_ostream< char > &out, std::string const &data)
 Print out a string to the console or use less.
 
bool operator!= (char const *value, option_info_ref const &rhs)
 Compare value with the value of the right hand-side option.
 
bool operator!= (std::string const &value, option_info_ref const &rhs)
 Compare value with the value of the right hand-side option.
 
std::string operator+ (char const *value, option_info_ref const &rhs)
 Concatenate a string and an option reference value.
 
std::string operator+ (char value, option_info_ref const &rhs)
 Concatenate a character and an option reference value.
 
std::string operator+ (char32_t value, option_info_ref const &rhs)
 Concatenate a character and an option reference value.
 
std::string operator+ (std::string const &value, option_info_ref const &rhs)
 Concatenate a string 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< (std::string 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<= (std::string 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== (std::string 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> (std::string 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>= (std::string const &value, option_info_ref const &rhs)
 Compare value with the value of the right hand-side option.
 
template<flag_t ... args>
constexpr flag_t option_flags ()
 
template<class none = void>
constexpr flag_t option_flags_merge ()
 
template<flag_t flag, flag_t ... args>
constexpr flag_t option_flags_merge ()
 
std::string option_with_dashes (std::string const &s)
 Convert the _ found in a string to - instead.
 
std::string option_with_underscores (std::string const &s)
 Converts an option back to using underscores.
 
std::string quote (std::string const &s, char open, char close)
 The converse of unquote.
 
std::string sanitizer_details ()
 Generate a string describing whether we're using the sanitizer.
 
std::string short_name_to_string (short_name_t short_name)
 Convert a short name to a UTF-8 string.
 
void split_string (std::string const &str, string_list_t &result, string_list_t const &separators)
 Split a string in sub-strings separated by separators.
 
template<flag_t ... args>
constexpr flag_t standalone_all_flags ()
 
template<flag_t ... args>
constexpr flag_t standalone_command_flags ()
 
short_name_t string_to_short_name (std::string const &name)
 Transform a string to a short name.
 
std::string unquote (std::string const &s, std::string const &pairs)
 Remove single (') or double (") quotes from a string.
 
template<flag_t ... args>
constexpr flag_t var_flags ()
 

Variables

constexpr assignment_operator_t ASSIGNMENT_OPERATOR_COLON = 0x0002
 
constexpr assignment_operator_t ASSIGNMENT_OPERATOR_EQUAL = 0x0001
 
constexpr assignment_operator_t ASSIGNMENT_OPERATOR_EXTENDED = 0x0008
 
constexpr assignment_operator_t ASSIGNMENT_OPERATOR_MASK = 0x000F
 
constexpr assignment_operator_t ASSIGNMENT_OPERATOR_SPACE = 0x0004
 
constexpr comment_t COMMENT_CPP = 0x0004
 
constexpr comment_t COMMENT_INI = 0x0001
 
constexpr comment_t COMMENT_MASK = 0x0007
 
constexpr comment_t COMMENT_NONE = 0x0000
 
constexpr comment_t COMMENT_SAVE = 0x8000
 
constexpr comment_t COMMENT_SHELL = 0x0002
 
constexpr int const CONFIGURATION_EXIT_CODE = 9
 
constexpr char const CONFIGURATION_SECTIONS [] = "configuration_sections"
 
constexpr int const DEFAULT_PRIORITY = 50
 
char constg_license_gpl_v2
 The GPL License v2.
 
constexpr flag_t GETOPT_ENVIRONMENT_FLAG_AUTO_DONE = 0x0010
 
constexpr flag_t GETOPT_ENVIRONMENT_FLAG_DEBUG_SOURCE = 0x0008
 
constexpr flag_t GETOPT_ENVIRONMENT_FLAG_DYNAMIC_PARAMETERS = 0x0001
 
constexpr flag_t GETOPT_ENVIRONMENT_FLAG_PROCESS_SYSTEM_PARAMETERS = 0x0004
 
constexpr flag_t GETOPT_ENVIRONMENT_FLAG_SYSTEM_PARAMETERS = 0x0002
 
static constexpr flag_t GETOPT_FLAG_ALIAS = static_cast<flag_t>(0x00000010)
 
static constexpr flag_t GETOPT_FLAG_ARRAY = static_cast<flag_t>(0x00000800)
 
static constexpr flag_t GETOPT_FLAG_COMMAND_LINE = static_cast<flag_t>(0x00000001)
 
static constexpr flag_t GETOPT_FLAG_CONFIGURATION_FILE = static_cast<flag_t>(0x00000004)
 
static constexpr flag_t GETOPT_FLAG_DEFAULT_OPTION = static_cast<flag_t>(0x00000100)
 
static constexpr flag_t GETOPT_FLAG_DYNAMIC = static_cast<flag_t>(0x20000000)
 
static constexpr flag_t GETOPT_FLAG_DYNAMIC_CONFIGURATION = static_cast<flag_t>(0x00000008)
 
static constexpr flag_t GETOPT_FLAG_END = static_cast<flag_t>(0x80000000)
 
static constexpr flag_t GETOPT_FLAG_ENVIRONMENT_VARIABLE = static_cast<flag_t>(0x00000002)
 
static constexpr flag_t GETOPT_FLAG_FLAG = static_cast<flag_t>(0x00000020)
 
static constexpr flag_t GETOPT_FLAG_GROUP_COMMANDS = static_cast<flag_t>(0x00100000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_FIVE = static_cast<flag_t>(0x00500000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_FOUR = static_cast<flag_t>(0x00400000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_MASK = static_cast<flag_t>(0x00700000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_MAXIMUM = static_cast<flag_t>(7)
 
static constexpr flag_t GETOPT_FLAG_GROUP_MINIMUM = static_cast<flag_t>(0)
 
static constexpr flag_t GETOPT_FLAG_GROUP_NONE = static_cast<flag_t>(0x00000000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_OPTIONS = static_cast<flag_t>(0x00200000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_SEVEN = static_cast<flag_t>(0x00700000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_SHIFT = static_cast<flag_t>(20)
 
static constexpr flag_t GETOPT_FLAG_GROUP_SIX = static_cast<flag_t>(0x00600000)
 
static constexpr flag_t GETOPT_FLAG_GROUP_THREE = static_cast<flag_t>(0x00300000)
 
static constexpr flag_t GETOPT_FLAG_HAS_DEFAULT = static_cast<flag_t>(0x00000200)
 
static constexpr flag_t GETOPT_FLAG_LOCK = static_cast<flag_t>(0x40000000)
 
static constexpr flag_t GETOPT_FLAG_MULTIPLE = static_cast<flag_t>(0x00000080)
 
static constexpr flag_t GETOPT_FLAG_NONE = static_cast<flag_t>(0x00000000)
 
static constexpr flag_t GETOPT_FLAG_PROCESS_VARIABLES = static_cast<flag_t>(0x00000400)
 
static constexpr flag_t GETOPT_FLAG_REQUIRED = static_cast<flag_t>(0x00000040)
 
static constexpr flag_t GETOPT_FLAG_SHOW_ALL = static_cast<flag_t>(0x00002000)
 
static constexpr flag_t GETOPT_FLAG_SHOW_GROUP1 = static_cast<flag_t>(0x00004000)
 
static constexpr flag_t GETOPT_FLAG_SHOW_GROUP2 = static_cast<flag_t>(0x00008000)
 
static constexpr flag_t GETOPT_FLAG_SHOW_MOST = static_cast<flag_t>(0x00000000)
 
static constexpr flag_t GETOPT_FLAG_SHOW_SYSTEM = static_cast<flag_t>(0x00010000)
 
static constexpr flag_t GETOPT_FLAG_SHOW_USAGE_ON_ERROR = static_cast<flag_t>(0x00001000)
 
constexpr name_separator_t NAME_SEPARATOR_DASHES = 0x0002
 
constexpr name_separator_t NAME_SEPARATOR_UNDERSCORES = 0x0001
 
constexpr short_name_t NO_SHORT_NAME = U'\0'
 
constexpr section_operator_t SECTION_OPERATOR_BLOCK = 0x0004
 
constexpr section_operator_t SECTION_OPERATOR_C = 0x0001
 
constexpr section_operator_t SECTION_OPERATOR_CPP = 0x0002
 
constexpr section_operator_t SECTION_OPERATOR_INI_FILE = 0x0008
 
constexpr section_operator_t SECTION_OPERATOR_MASK = 0x000F
 
constexpr section_operator_t SECTION_OPERATOR_NONE = 0x0000
 
constexpr section_operator_t SECTION_OPERATOR_ONE_SECTION = 0x8000
 
constexpr flag_t SYSTEM_OPTION_BUILD_DATE = 0x0010
 
constexpr flag_t SYSTEM_OPTION_COMMANDS_MASK = 0x0FFF
 
constexpr flag_t SYSTEM_OPTION_CONFIG_DIR = 0x1000
 
constexpr flag_t SYSTEM_OPTION_CONFIGURATION_FILENAMES = 0x0040
 
constexpr flag_t SYSTEM_OPTION_COPYRIGHT = 0x0004
 
constexpr flag_t SYSTEM_OPTION_ENVIRONMENT_VARIABLE_NAME = 0x0020
 
constexpr flag_t SYSTEM_OPTION_HELP = 0x0001
 
constexpr flag_t SYSTEM_OPTION_LICENSE = 0x0008
 
constexpr flag_t SYSTEM_OPTION_NONE = 0x0000
 
constexpr flag_t SYSTEM_OPTION_OPTIONS_MASK = 0xF000
 
constexpr flag_t SYSTEM_OPTION_PATH_TO_OPTION_DEFINITIONS = 0x0080
 
constexpr flag_t SYSTEM_OPTION_SHOW_OPTION_SOURCES = 0x0100
 
constexpr flag_t SYSTEM_OPTION_SHOW_OPTION_VALUE = 0x0200
 
constexpr flag_t SYSTEM_OPTION_VERSION = 0x0002
 

Detailed Description

This namespace encompasses all the declarations and implementations of functions used to parse and access the command line options.

Typedef Documentation

◆ assignment_operator_t

Definition at line 69 of file conf_file.h.

◆ comment_t

typedef std::uint_fast16_t advgetopt::comment_t

Definition at line 79 of file conf_file.h.

◆ flag_t

typedef std::uint32_t advgetopt::flag_t

Definition at line 41 of file flags.h.

◆ name_separator_t

Definition at line 104 of file conf_file.h.

◆ section_operator_t

Definition at line 91 of file conf_file.h.

◆ short_name_t

Definition at line 49 of file option_info.h.

◆ string_list_t

typedef std::vector<std::string> advgetopt::string_list_t

Definition at line 41 of file utils.h.

◆ string_set_t

typedef std::set<std::string> advgetopt::string_set_t

Definition at line 42 of file utils.h.

Enumeration Type Documentation

◆ assignment_t

Enumerator
ASSIGNMENT_NONE 
ASSIGNMENT_SET 
ASSIGNMENT_OPTIONAL 
ASSIGNMENT_APPEND 
ASSIGNMENT_NEW 

Definition at line 47 of file variables.h.

◆ callback_action_t

Enumerator
created 
updated 
erased 

Definition at line 50 of file conf_file.h.

◆ line_continuation_t

Enumerator
line_continuation_single_line 
line_continuation_rfc_822 
line_continuation_msdos 
line_continuation_unix 
line_continuation_fortran 
line_continuation_semicolon 

Definition at line 58 of file conf_file.h.

◆ option_source_t

Enumerator
SOURCE_COMMAND_LINE 
SOURCE_CONFIGURATION 
SOURCE_DIRECT 
SOURCE_DYNAMIC 
SOURCE_ENVIRONMENT_VARIABLE 
SOURCE_UNDEFINED 

Definition at line 60 of file option_info.h.

Function Documentation

◆ all_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::all_flags ( )
constexpr

◆ any_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::any_flags ( )
constexpr

Definition at line 130 of file flags.h.

References GETOPT_FLAG_END, and option_flags_merge().

◆ breakup_line() [1/2]

std::string advgetopt::breakup_line ( std::string  line,
size_t const  option_width,
size_t const  line_width 
)

This function breaks up the specified line of text in one or more strings to fit your output.

The line_width represents the maximum number of characters that get printed in a row.

The option_width parameter is the number of characters in the left margin. When dealing with a very long argument, this width is 3 characters. When dealing with the help itself, it is expected to be around 30.

Note
This function always makes sure that the resulting string ends with a newline character unless the input line string is empty.
Parameters
[in]lineThe line to breakup.
[in]option_widthThe number of characters in the left margin.
[in]line_widthThe total number of characters in the output.
Returns
The broken up line as required.

Definition at line 791 of file utils.cpp.

References option_flags_merge().

Referenced by format_usage_string(), and advgetopt::getopt::usage().

◆ breakup_line() [2/2]

std::string advgetopt::breakup_line ( std::string  line,
std::size_t const  option_width,
std::size_t const  line_width 
)

◆ combine_option_flags()

template<flag_t flag, flag_t ... args>
constexpr flag_t advgetopt::combine_option_flags ( )
constexpr

◆ command_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::command_flags ( )
constexpr

◆ config_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::config_flags ( )
constexpr

◆ DECLARE_EXCEPTION() [1/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_defined_twice   
)

◆ DECLARE_EXCEPTION() [2/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_initialization   
)

◆ DECLARE_EXCEPTION() [3/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_invalid   
)

◆ DECLARE_EXCEPTION() [4/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_invalid_default   
)

◆ DECLARE_EXCEPTION() [5/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_invalid_parameter   
)

◆ DECLARE_EXCEPTION() [6/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_root_filename   
)

◆ DECLARE_EXCEPTION() [7/7]

advgetopt::DECLARE_EXCEPTION ( getopt_exception  ,
getopt_undefined   
)

◆ DECLARE_LOGIC_ERROR()

advgetopt::DECLARE_LOGIC_ERROR ( getopt_logic_error  )

◆ DECLARE_MAIN_EXCEPTION()

advgetopt::DECLARE_MAIN_EXCEPTION ( getopt_exception  )

◆ default_group_name()

std::string advgetopt::default_group_name ( std::string const filename,
char const group_name,
char const project_name,
int  priority 
)

This function generates the default filename as the insert_group_name() expects to find in the configuration sub-directory.

The name is formed as follow:

<path> / <directory> ".d" / <priority> "-" <basename>

Where <path> is the path found in filename. If no path is defined in filename, then the <path> / part is not prepended:

<directory> ".d" / <priority> "-" <basename>

Where <directory> is the group_name if defined, otherwise it uses the project_name. This is why if neither is defined, then the function immediately returns an empty string.

Where <priority> is a number from 0 to 99 inclusive. This is used to sort the files before processing them. File with lower priorities are loaded first. Parameters found in files with higher priorities overwrite the values of parameters found in files with lower priorities.

Where <basename> is the end of filename, the part after the last slash (/). If filename is not empty and it does not include a slash then the entire filename is taken as the <basename>. Note that filename is expected to include an extension such as .conf. The extension is not modified in any way.

Since the result is not viable when filename is empty, the function immediately returns an empty string in that situation.

Exceptions
getopt_root_filenameThe filename parameter cannot be a file in the root directory.
Parameters
[in]filenameThe filename where the project name gets injected.
[in]group_nameThe name of the group to inject in the filename.
[in]project_nameThe name of the project to inject in the filename.
[in]priorityThe priority of the new file (0 to 99).
Returns
The default filenames or an empty list if no group or project or file name were specified.

Definition at line 585 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::get_output_filename(), and insert_group_name().

◆ define_group()

template<class ... ARGS>
constexpr group_description advgetopt::define_group ( ARGS ...  args)
constexpr

Definition at line 403 of file options.h.

References advgetopt::group_description::f_group, and option_flags_merge().

Referenced by end_groups().

◆ define_option()

template<class ... ARGS>
constexpr option advgetopt::define_option ( ARGS ...  args)
constexpr

◆ end_flags()

constexpr flag_t advgetopt::end_flags ( )
constexpr

Definition at line 123 of file flags.h.

References option_flags_merge().

Referenced by end_options().

◆ end_groups()

constexpr group_description advgetopt::end_groups ( )
constexpr

Definition at line 419 of file options.h.

References define_group().

◆ end_options()

constexpr option advgetopt::end_options ( )
constexpr

Definition at line 294 of file options.h.

References define_option(), and end_flags().

◆ escape_shell_argument()

std::string advgetopt::escape_shell_argument ( std::string const arg)

This function goes through the supplied argument. If it includes one or more character other than [-+0-9A-Za-z_], then it gets escaped. This means we add single quotes at the start and end, and escape any single quote within the argument.

So the function may return the input string as is.

Parameters
[in]argThe argument to escape.
Returns
The escaped argument.

Definition at line 959 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::options_to_string().

◆ find_group() [1/2]

template<typename T , typename F , class ... ARGS>
constexpr std::enable_if< std::is_same< T, F >::value, typenameT::value_t >::type advgetopt::find_group ( F  first,
ARGS ...  args 
)
constexpr

Definition at line 386 of file options.h.

References option_flags_merge().

◆ find_group() [2/2]

template<typename T , typename F , class ... ARGS>
constexpr std::enable_if<!std::is_same< T, F >::value, typenameT::value_t >::type advgetopt::find_group ( F  first,
ARGS ...  args 
)
constexpr

Definition at line 394 of file options.h.

References option_flags_merge().

◆ find_option() [1/2]

template<typename T , typename F , class ... ARGS>
constexpr std::enable_if< std::is_same< T, F >::value, typenameT::value_t >::type advgetopt::find_option ( F  first,
ARGS ...  args 
)
constexpr

Definition at line 242 of file options.h.

References option_flags_merge().

◆ find_option() [2/2]

template<typename T , typename F , class ... ARGS>
constexpr std::enable_if<!std::is_same< T, F >::value, typenameT::value_t >::type advgetopt::find_option ( F  first,
ARGS ...  args 
)
constexpr

Definition at line 250 of file options.h.

References option_flags_merge().

◆ format_usage_string() [1/2]

std::string advgetopt::format_usage_string ( std::string const argument,
std::string const help,
size_t const  option_width,
size_t const  line_width 
)

This function properly wraps a set of help strings so they fit in your console. The width has to be given by you at the moment.

The function takes two strings, the argument with it's options and the actual help string for that argument. If the argument is short enough, it will appear on the first line with the first line of help. If not, then one whole line is reserved just for the argument and the help starts on the next line.

Parameters
[in]argumentThe option name with – and arguments.
[in]helpThe help string for this argument.
[in]option_widthNumber of characters reserved for the option.
[in]line_widthThe maximum number of characters to display in width.
Returns
A help string formatted for display.

Definition at line 899 of file utils.cpp.

References breakup_line(), and option_flags_merge().

Referenced by advgetopt::getopt::usage().

◆ format_usage_string() [2/2]

std::string advgetopt::format_usage_string ( std::string const argument,
std::string const help,
std::size_t const  option_width,
std::size_t const  line_width 
)

◆ get_global_mutex()

cppthread::mutex & advgetopt::get_global_mutex ( )

◆ get_major_version()

int advgetopt::get_major_version ( )

This function returns the version of the running library (the one you are linked against at runtime).

Returns
The major version.

Definition at line 54 of file version.cpp.

References LIBADVGETOPT_VERSION_MAJOR.

◆ get_patch_version()

int advgetopt::get_patch_version ( )

This function returns the patch version of the running library (the one you are linked against at runtime).

Returns
The patch version.

Definition at line 80 of file version.cpp.

References LIBADVGETOPT_VERSION_PATCH.

◆ get_release_version()

int advgetopt::get_release_version ( )

This function returns the release version of the running library (the one you are linked against at runtime).

Returns
The release version.

Definition at line 67 of file version.cpp.

References LIBADVGETOPT_VERSION_MINOR.

◆ get_screen_height()

std::size_t advgetopt::get_screen_height ( )

This function retrieves the height of the console in number of characters. This is also called the number of rows.

If the process is not connected to a TTY, then the function returns 25.

If the height is less than 2, the function returns 2.

Note
The get_screen_width() and get_screen_height() should be combined.
Returns
The width of the console screen.

Definition at line 1037 of file utils.cpp.

References option_flags_merge().

Referenced by less().

◆ get_screen_width()

std::size_t advgetopt::get_screen_width ( )

This function retrieves the width of the console in number of characters.

If the process is not connected to a TTY, then the function returns 80.

If the width is less than 40, the function returns 40.

Returns
The width of the console screen.

Definition at line 746 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::usage().

◆ get_version_string()

char const * advgetopt::get_version_string ( )

This function returns the major, release, and patch versions of the running library (the one you are linked against at runtime) in the form of a string.

The build version is not made available.

Returns
The library version.

Definition at line 96 of file version.cpp.

References LIBADVGETOPT_VERSION_STRING.

◆ handle_user_directory()

std::string advgetopt::handle_user_directory ( std::string const filename)

This function checks the beginning of filename. If it starts with ‘’~/' then it replaces the'~'` character with the contents of the $HOME environment variable.

If filename is just "~", then the function returns the contents of the $HOME environment variable by itself.

If somehow the $HOME environment variable is empty, the function does nothing.

Todo:
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.
Parameters
[in]filenameThe filename to check for a tilde (~).
Returns
The input as is unless the $HOME path can be prepended to replace the tilde (~) character.

Definition at line 676 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::get_direct_configuration_filenames(), and advgetopt::getopt::get_managed_configuration_filenames().

◆ insert_group_name()

string_list_t advgetopt::insert_group_name ( std::string const filename,
char const group_name,
char const project_name,
bool  add_default_on_empty 
)

This function inserts the name of the group in the specified full path filename. It gets added right before the basename. So for example you have a path such as:

/etc/snapwebsites/advgetopt.conf

and a group name such as:

adventure

The resulting path is:

/etc/snapwebsites/adventure.d/##-advgetopt.conf

where the '##' is a number from 00 to 99. If none of those files exists, the default (50) is used if add_default_on_empty is true.

Notice that the function adds a ".d" as well.

If the group name is empty or null, then the project name is used. If both are empty, then nothing happens (the function returns an empty list).

Exceptions
getopt_root_filenameThe filename parameter cannot be a file in the root directory.
Parameters
[in]filenameThe filename where the project name gets injected.
[in]group_nameThe name of the group to inject in the filename.
[in]project_nameThe name of the project to inject in the filename.
[in]add_default_on_emptyWhether the add the default if no files exist.
Returns
The list of filenames or an empty list if no group or project name or filename were specified.

Definition at line 466 of file utils.cpp.

References default_group_name(), get_global_mutex(), and option_flags_merge().

Referenced by advgetopt::getopt::get_direct_configuration_filenames(), and advgetopt::getopt::get_managed_configuration_filenames().

◆ is_false()

bool advgetopt::is_false ( std::string  s)

This function checks a string to see whether it is one of:

  • "false"
  • "off"
  • "no"
  • "0"

If so, then the function returns true.

Parameters
[in]sThe string to be checked.
Returns
true if the string represents "false".

Definition at line 730 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::add_option_from_string().

◆ is_true()

bool advgetopt::is_true ( std::string  s)

This function checks a string to see whether it is one of:

  • "true"
  • "on"
  • "yes"
  • "1"

If so, then the function returns true.

Parameters
[in]sThe string to be checked.
Returns
true if the string represents "true".

Definition at line 709 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::add_option_from_string().

◆ iswspace()

bool advgetopt::iswspace ( int  c)

Our iswspace() function is equivalent to the std::iswspace() function except that ‘’\r'and'\n'` are never viewed as white spaces.

Returns
true if c is considered to be a white space character.

Definition at line 2417 of file conf_file.cpp.

Referenced by advgetopt::conf_file::get_line(), and advgetopt::conf_file::read_configuration().

◆ less()

void advgetopt::less ( std::basic_ostream< char > &  out,
std::string const data 
)

If the data string to be output is too large for the screen (too many lines; we assume the width was already "fixed") then use less to show the data. If less is not available, use more. If neither is available, fall back to printing everything at once.

Parameters
[in,out]outThe output stream where the data has to be written.
[in]dataThe data to be written to stream.

Definition at line 1069 of file utils.cpp.

References get_screen_height(), and option_flags_merge().

Referenced by advgetopt::getopt::process_system_options().

◆ operator!=() [1/2]

bool advgetopt::operator!= ( char const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is not equal to rhs.

Definition at line 944 of file option_info_ref.cpp.

◆ operator!=() [2/2]

bool advgetopt::operator!= ( std::string const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is not equal to rhs.

Definition at line 964 of file option_info_ref.cpp.

◆ operator+() [1/4]

std::string advgetopt::operator+ ( char const value,
option_info_ref const rhs 
)

This operator concatenates the value string to the front of the rhs reference.

Parameters
[in]valueA character to add to the left of the referred value.
[in]rhsThe referred value.
Returns
The concatenated result.

Definition at line 565 of file option_info_ref.cpp.

◆ operator+() [2/4]

std::string advgetopt::operator+ ( char  value,
option_info_ref const rhs 
)

This operator concatenates the value ISO-8859-1 character to the front of the rhs reference.

Parameters
[in]valueA character to add to the left of the referred value.
[in]rhsThe referred value.
Returns
The concatenated result.

Definition at line 533 of file option_info_ref.cpp.

◆ operator+() [3/4]

std::string advgetopt::operator+ ( char32_t  value,
option_info_ref const rhs 
)

This operator concatenates the value Unicode character to the front of the rhs reference.

Parameters
[in]valueA character to add to the left of the referred value.
[in]rhsThe referred value.
Returns
The concatenated result.

Definition at line 549 of file option_info_ref.cpp.

◆ operator+() [4/4]

std::string advgetopt::operator+ ( std::string const value,
option_info_ref const rhs 
)

This operator concatenates the value string to the front of the rhs reference.

Parameters
[in]valueA character to add to the left of the referred value.
[in]rhsThe referred value.
Returns
The concatenated result.

Definition at line 585 of file option_info_ref.cpp.

◆ operator<() [1/2]

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered smaller than rhs.

Definition at line 980 of file option_info_ref.cpp.

◆ operator<() [2/2]

bool advgetopt::operator< ( std::string const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered smaller than rhs.

Definition at line 1000 of file option_info_ref.cpp.

◆ operator<=() [1/2]

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered smaller or equal to rhs.

Definition at line 1016 of file option_info_ref.cpp.

◆ operator<=() [2/2]

bool advgetopt::operator<= ( std::string const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered smaller or equal to rhs.

Definition at line 1036 of file option_info_ref.cpp.

◆ operator==() [1/2]

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is equal to rhs.

Definition at line 908 of file option_info_ref.cpp.

◆ operator==() [2/2]

bool advgetopt::operator== ( std::string const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is equal to rhs.

Definition at line 928 of file option_info_ref.cpp.

◆ operator>() [1/2]

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered larger than rhs.

Definition at line 1052 of file option_info_ref.cpp.

◆ operator>() [2/2]

bool advgetopt::operator> ( std::string const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered larger than rhs.

Definition at line 1072 of file option_info_ref.cpp.

◆ operator>=() [1/2]

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered larger or equal to rhs.

Definition at line 1088 of file option_info_ref.cpp.

◆ operator>=() [2/2]

bool advgetopt::operator>= ( std::string const value,
option_info_ref const rhs 
)

This operator compares the specified value with the value of the option specified as the rhs (right hand-side.)

Parameters
[in]valueA string to compare an option's value with.
[in]rhsThe option to compare against value.
Returns
true if value is considered larger or equal to rhs.

Definition at line 1108 of file option_info_ref.cpp.

◆ option_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::option_flags ( )
constexpr

Definition at line 142 of file flags.h.

References option_flags_merge().

◆ option_flags_merge() [1/2]

template<class none = void>
constexpr flag_t advgetopt::option_flags_merge ( )
constexpr

Definition at line 87 of file flags.h.

References GETOPT_FLAG_NONE.

Referenced by advgetopt::option_info::option_info(), advgetopt::validator_double::validator_double(), advgetopt::validator_duration::validator_duration(), advgetopt::validator_email::validator_email(), advgetopt::validator_integer::validator_integer(), advgetopt::validator_keywords::validator_keywords(), advgetopt::validator_length::validator_length(), advgetopt::validator_list::validator_list(), advgetopt::validator_regex::validator_regex(), advgetopt::validator_size::validator_size(), advgetopt::option_info::add_callback(), advgetopt::option_info::add_flag(), advgetopt::validator_list::add_validator(), advgetopt::option_info::add_value(), all_flags(), any_flags(), breakup_line(), advgetopt::variables::canonicalize_variable_name(), combine_option_flags(), command_flags(), config_flags(), advgetopt::validator_duration::convert_string(), advgetopt::validator_double::convert_string(), advgetopt::validator_integer::convert_string(), advgetopt::validator_size::convert_string(), advgetopt::validator::create(), advgetopt::validator::create(), default_group_name(), define_group(), define_option(), end_flags(), escape_shell_argument(), find_group(), find_option(), advgetopt::option_info::find_value_index_by_key(), format_usage_string(), advgetopt::option_info::get_basename(), advgetopt::option_info_ref::get_double(), advgetopt::option_info::get_double(), advgetopt::option_info::get_environment_variable_value(), advgetopt::option_info_ref::get_long(), advgetopt::option_info::get_long(), get_screen_height(), get_screen_width(), advgetopt::option_info::get_section_name(), advgetopt::option_info::get_section_name_list(), advgetopt::option_info::get_value(), advgetopt::variables::get_variable(), handle_user_directory(), advgetopt::option_info::has_flag(), advgetopt::option_info::has_value(), advgetopt::variables::has_variable(), insert_group_name(), is_false(), is_true(), less(), advgetopt::option_info::lock(), advgetopt::option_info_ref::operator+=(), advgetopt::option_info_ref::operator+=(), advgetopt::option_info_ref::operator+=(), advgetopt::option_info_ref::operator=(), advgetopt::option_info_ref::operator=(), option_flags(), option_flags_merge(), option_with_dashes(), option_with_underscores(), advgetopt::variables::process_value(), quote(), advgetopt::variables::recursive_process_value(), advgetopt::validator::register_validator(), advgetopt::option_info::remove_callback(), advgetopt::option_info::remove_flag(), sanitizer_details(), advgetopt::option_info::set_alias_destination(), advgetopt::option_info::set_configuration_filename(), advgetopt::option_info::set_default(), advgetopt::option_info::set_default(), advgetopt::option_info::set_flags(), advgetopt::option_info::set_help(), advgetopt::option_info::set_help(), advgetopt::option_info::set_multiple_separators(), advgetopt::option_info::set_multiple_separators(), advgetopt::option_info::set_multiple_values(), advgetopt::option_info::set_short_name(), advgetopt::option_info::set_trace_sources(), advgetopt::option_info::set_validator(), advgetopt::option_info::set_validator(), advgetopt::option_info::set_validator(), advgetopt::option_info::set_value(), advgetopt::variables::set_variable(), advgetopt::option_info::set_variables(), short_name_to_string(), split_string(), standalone_all_flags(), standalone_command_flags(), string_to_short_name(), advgetopt::option_info::trace_source(), unquote(), advgetopt::validator_double::validate(), advgetopt::validator_duration::validate(), advgetopt::validator_email::validate(), advgetopt::validator_integer::validate(), advgetopt::validator_length::validate(), advgetopt::validator_list::validate(), advgetopt::validator_regex::validate(), advgetopt::validator_size::validate(), advgetopt::option_info::validate_all_values(), advgetopt::option_info::validates(), advgetopt::option_info::value_changed(), and var_flags().

◆ option_flags_merge() [2/2]

template<flag_t flag, flag_t ... args>
constexpr flag_t advgetopt::option_flags_merge ( )
constexpr

Definition at line 94 of file flags.h.

References GETOPT_FLAG_GROUP_MASK, and option_flags_merge().

◆ option_with_dashes()

std::string advgetopt::option_with_dashes ( std::string const s)

Options are saved with - instead of _ so all the standard compare functions can be used to find options. This function converts a string so all of the _ charaters get transformed to - characters.

Why do we support both?

It is customary to use the - in long command line option names. For example --long-form uses a -. (One exception is ffmpeg which uses _ in their long command line option names).

However, the advgetopt library also reads Unix like configuration files and parameters in those files are generally expected to use underscores (_) in their names. For example email_address = contact@example.com.

To make it simpler, the advgetopt library accepts both characters and decides to view them as being equal. So you can use both forms in both situations. The following are equivalent:

my-command --long-form
constexpr flag_t option_flags_merge()
Definition flags.h:87

This function is used to convert a string to the advgetopt format which is to keep only - in the names. So if it finds a _, it gets transformed.

Parameters
[in]sThe string to transform.
Returns
A copy with all _ transformed to -.

Definition at line 259 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::get_option().

◆ option_with_underscores()

std::string advgetopt::option_with_underscores ( std::string const s)

When generating some error messages, we like to show underscores if the variable comes from a configuration file. In this case we use this function to convert the dashes back to underscores and print that in the message.

Parameters
[in]sThe string to be converted.
Returns
A copy of the string with - converted to _.

Definition at line 288 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::add_option_from_string(), and advgetopt::getopt::process_configuration_file().

◆ quote()

std::string advgetopt::quote ( std::string const s,
char  open,
char  close 
)

This function adds quotes around a string.

If you do not define the close quotation (i.e. it remains set to the NUL character '\0'), then the open quotation gets reused as the closing quotation.

Parameters
[in]sThe string to be quoted.
[in]openThe opening quote to quote this string.
[in]closeThe closing quote to quote this string.
Returns
The input string quoted with quote.

Definition at line 201 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::anonymous_namespace{validator.cpp}::lexer::next_token(), advgetopt::getopt::split_environment(), and split_string().

◆ sanitizer_details()

std::string advgetopt::sanitizer_details ( )

This function determines whether this library was compiled with the sanitizer extension. If so, then it will return detail about which feature was compiled in.

If no sanitizer options were compiled in, then it returns a message saying so.

Returns
A string with details about the sanitizer.

Definition at line 1005 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::process_system_options().

◆ short_name_to_string()

std::string advgetopt::short_name_to_string ( short_name_t  short_name)

This function is the opposite of the to_short_name() except that the input is expected to be a valid short name or NO_SHORT_NAME.

When the input is NO_SHORT_NAME, the function outputs an empty string.

Note
There are other short names that are not really considered valid such as control characters, the dash (-), and probably most other punctuation, character codes which are not currently assigned to any character in Unicode, etc. This function ignores all of those potential problems.
Parameters
[in]short_nameThe short name to convert to UTF-8.
Returns
The short name as a UTF-8 string or an empty string.

Definition at line 162 of file option_info.cpp.

References NO_SHORT_NAME, and option_flags_merge().

Referenced by advgetopt::getopt::add_option(), advgetopt::getopt::parse_arguments(), advgetopt::getopt::set_short_name(), and advgetopt::getopt::usage().

◆ split_string()

void advgetopt::split_string ( std::string const str,
string_list_t result,
string_list_t const separators 
)

This function searches for any of the separators in str and split at those locations.

For example, to split a comma separated list of strings, use the following:

option_info::split_string(string_to_split, result, {","});
std::vector< std::string > string_list_t
Definition utils.h:41

If string_to_split is set to "a, b, c", then the result vector will have three strings as a result: a, b, and c. Note that the function automatically trims all strings and it never keeps empty strings. So two separators one after another is accepted and no empty string results.

The trimming happens after the split occurs. This allows for the list of separators to include spaces as separators.

The function does not clear the result vector. This allows you to call this function multiple times with various strings and the results will be cumulated.

Note
This function is a static so it can be used from anywhere to split strings as required. You do not need to have an option_info instance.
Todo:
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.
Parameters
[in]strThe string to split.
[in]resultThe vector where the split strings are saved.
[in]separatorsThe vector of strings used as separators.

Definition at line 347 of file utils.cpp.

References option_flags_merge(), and quote().

Referenced by advgetopt::getopt::parse_option_map(), advgetopt::getopt::parse_options_from_file(), and advgetopt::option_info::set_multiple_values().

◆ standalone_all_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::standalone_all_flags ( )
constexpr

◆ standalone_command_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::standalone_command_flags ( )
constexpr

◆ string_to_short_name()

short_name_t advgetopt::string_to_short_name ( std::string const name)

This function transforms a string to a short name. The input string can represent a UTF-8 character that can be used as a short name.

An empty string is not considered to represent any name and thus this function returns NO_SHORT_NAME when the input is an empty string.

Parameters
[in]nameThe name to be checked.
Returns
The short name character or NO_SHORT_NAME if it's not a match.

Definition at line 128 of file option_info.cpp.

References NO_SHORT_NAME, and option_flags_merge().

Referenced by advgetopt::getopt::get_option(), and advgetopt::getopt::parse_options_info().

◆ unquote()

std::string advgetopt::unquote ( std::string const s,
std::string const pairs 
)

If a string starts and ends with the same quotation mark, then it gets removed.

If no quotes appear, then the function returns a copy of the input as is.

The pairs parameter must have an even size (or the last character gets ignored). By default, it is set to the double and single quotes:

"\"\"''"

To remove square, angle, curly brackets:

"[]<>{}"
Todo:
Add support for UTF-8 quotes. Right now only quotes of 1 byte will work.
Parameters
[in]sThe string to unquote.
[in]pairsA list of accepted quotes.
Returns
The unquoted string.

Definition at line 168 of file utils.cpp.

References option_flags_merge().

Referenced by advgetopt::getopt::parse_options_from_file(), advgetopt::conf_file::read_configuration(), and advgetopt::option_info::set_multiple_values().

◆ var_flags()

template<flag_t ... args>
constexpr flag_t advgetopt::var_flags ( )
constexpr

Variable Documentation

◆ ASSIGNMENT_OPERATOR_COLON

constexpr assignment_operator_t advgetopt::ASSIGNMENT_OPERATOR_COLON = 0x0002
constexpr

◆ ASSIGNMENT_OPERATOR_EQUAL

constexpr assignment_operator_t advgetopt::ASSIGNMENT_OPERATOR_EQUAL = 0x0001
constexpr

◆ ASSIGNMENT_OPERATOR_EXTENDED

constexpr assignment_operator_t advgetopt::ASSIGNMENT_OPERATOR_EXTENDED = 0x0008
constexpr

◆ ASSIGNMENT_OPERATOR_MASK

constexpr assignment_operator_t advgetopt::ASSIGNMENT_OPERATOR_MASK = 0x000F
constexpr

Definition at line 76 of file conf_file.h.

◆ ASSIGNMENT_OPERATOR_SPACE

constexpr assignment_operator_t advgetopt::ASSIGNMENT_OPERATOR_SPACE = 0x0004
constexpr

◆ COMMENT_CPP

constexpr comment_t advgetopt::COMMENT_CPP = 0x0004
constexpr

◆ COMMENT_INI

constexpr comment_t advgetopt::COMMENT_INI = 0x0001
constexpr

◆ COMMENT_MASK

constexpr comment_t advgetopt::COMMENT_MASK = 0x0007
constexpr

Definition at line 88 of file conf_file.h.

◆ COMMENT_NONE

constexpr comment_t advgetopt::COMMENT_NONE = 0x0000
constexpr

Definition at line 81 of file conf_file.h.

◆ COMMENT_SAVE

constexpr comment_t advgetopt::COMMENT_SAVE = 0x8000
constexpr

◆ COMMENT_SHELL

constexpr comment_t advgetopt::COMMENT_SHELL = 0x0002
constexpr

◆ CONFIGURATION_EXIT_CODE

constexpr int const advgetopt::CONFIGURATION_EXIT_CODE = 9
constexpr

Definition at line 63 of file exception.h.

◆ CONFIGURATION_SECTIONS

constexpr char const advgetopt::CONFIGURATION_SECTIONS[] = "configuration_sections"
constexpr

Definition at line 51 of file advgetopt.h.

Referenced by advgetopt::getopt::process_configuration_file().

◆ DEFAULT_PRIORITY

constexpr int const advgetopt::DEFAULT_PRIORITY = 50
constexpr

Definition at line 44 of file utils.h.

◆ g_license_gpl_v2

char const * advgetopt::g_license_gpl_v2

The GPL license version 2. This is a C string you can directly use in your options_environment. The –license command line option will then automatically print the license.

Definition at line 40 of file license_gpl2.cpp.

◆ GETOPT_ENVIRONMENT_FLAG_AUTO_DONE

constexpr flag_t advgetopt::GETOPT_ENVIRONMENT_FLAG_AUTO_DONE = 0x0010
constexpr

Definition at line 437 of file options.h.

Referenced by advgetopt::getopt::is_parsed().

◆ GETOPT_ENVIRONMENT_FLAG_DEBUG_SOURCE

constexpr flag_t advgetopt::GETOPT_ENVIRONMENT_FLAG_DEBUG_SOURCE = 0x0008
constexpr

Definition at line 436 of file options.h.

◆ GETOPT_ENVIRONMENT_FLAG_DYNAMIC_PARAMETERS

constexpr flag_t advgetopt::GETOPT_ENVIRONMENT_FLAG_DYNAMIC_PARAMETERS = 0x0001
constexpr

Definition at line 432 of file options.h.

Referenced by advgetopt::getopt::process_configuration_file().

◆ GETOPT_ENVIRONMENT_FLAG_PROCESS_SYSTEM_PARAMETERS

constexpr flag_t advgetopt::GETOPT_ENVIRONMENT_FLAG_PROCESS_SYSTEM_PARAMETERS = 0x0004
constexpr

◆ GETOPT_ENVIRONMENT_FLAG_SYSTEM_PARAMETERS

constexpr flag_t advgetopt::GETOPT_ENVIRONMENT_FLAG_SYSTEM_PARAMETERS = 0x0002
constexpr

◆ GETOPT_FLAG_ALIAS

constexpr flag_t advgetopt::GETOPT_FLAG_ALIAS = static_cast<flag_t>(0x00000010)
staticconstexpr

◆ GETOPT_FLAG_ARRAY

constexpr flag_t advgetopt::GETOPT_FLAG_ARRAY = static_cast<flag_t>(0x00000800)
staticconstexpr

◆ GETOPT_FLAG_COMMAND_LINE

constexpr flag_t advgetopt::GETOPT_FLAG_COMMAND_LINE = static_cast<flag_t>(0x00000001)
staticconstexpr

◆ GETOPT_FLAG_CONFIGURATION_FILE

constexpr flag_t advgetopt::GETOPT_FLAG_CONFIGURATION_FILE = static_cast<flag_t>(0x00000004)
staticconstexpr

◆ GETOPT_FLAG_DEFAULT_OPTION

constexpr flag_t advgetopt::GETOPT_FLAG_DEFAULT_OPTION = static_cast<flag_t>(0x00000100)
staticconstexpr

◆ GETOPT_FLAG_DYNAMIC

constexpr flag_t advgetopt::GETOPT_FLAG_DYNAMIC = static_cast<flag_t>(0x20000000)
staticconstexpr

Definition at line 79 of file flags.h.

Referenced by advgetopt::getopt::process_configuration_file().

◆ GETOPT_FLAG_DYNAMIC_CONFIGURATION

constexpr flag_t advgetopt::GETOPT_FLAG_DYNAMIC_CONFIGURATION = static_cast<flag_t>(0x00000008)
staticconstexpr

◆ GETOPT_FLAG_END

constexpr flag_t advgetopt::GETOPT_FLAG_END = static_cast<flag_t>(0x80000000)
staticconstexpr

Definition at line 82 of file flags.h.

Referenced by any_flags(), combine_option_flags(), and advgetopt::getopt::parse_options_info().

◆ GETOPT_FLAG_ENVIRONMENT_VARIABLE

constexpr flag_t advgetopt::GETOPT_FLAG_ENVIRONMENT_VARIABLE = static_cast<flag_t>(0x00000002)
staticconstexpr

◆ GETOPT_FLAG_FLAG

constexpr flag_t advgetopt::GETOPT_FLAG_FLAG = static_cast<flag_t>(0x00000020)
staticconstexpr

◆ GETOPT_FLAG_GROUP_COMMANDS

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_COMMANDS = static_cast<flag_t>(0x00100000)
staticconstexpr

◆ GETOPT_FLAG_GROUP_FIVE

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_FIVE = static_cast<flag_t>(0x00500000)
staticconstexpr

Definition at line 75 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file().

◆ GETOPT_FLAG_GROUP_FOUR

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_FOUR = static_cast<flag_t>(0x00400000)
staticconstexpr

Definition at line 74 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file().

◆ GETOPT_FLAG_GROUP_MASK

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_MASK = static_cast<flag_t>(0x00700000)
staticconstexpr

◆ GETOPT_FLAG_GROUP_MAXIMUM

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_MAXIMUM = static_cast<flag_t>(7)
staticconstexpr

Definition at line 68 of file flags.h.

Referenced by advgetopt::getopt::usage().

◆ GETOPT_FLAG_GROUP_MINIMUM

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_MINIMUM = static_cast<flag_t>(0)
staticconstexpr

Definition at line 67 of file flags.h.

Referenced by advgetopt::getopt::usage().

◆ GETOPT_FLAG_GROUP_NONE

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_NONE = static_cast<flag_t>(0x00000000)
staticconstexpr

◆ GETOPT_FLAG_GROUP_OPTIONS

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_OPTIONS = static_cast<flag_t>(0x00200000)
staticconstexpr

Definition at line 72 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file().

◆ GETOPT_FLAG_GROUP_SEVEN

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_SEVEN = static_cast<flag_t>(0x00700000)
staticconstexpr

Definition at line 77 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file().

◆ GETOPT_FLAG_GROUP_SHIFT

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_SHIFT = static_cast<flag_t>(20)
staticconstexpr

Definition at line 69 of file flags.h.

Referenced by advgetopt::getopt::usage().

◆ GETOPT_FLAG_GROUP_SIX

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_SIX = static_cast<flag_t>(0x00600000)
staticconstexpr

Definition at line 76 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file().

◆ GETOPT_FLAG_GROUP_THREE

constexpr flag_t advgetopt::GETOPT_FLAG_GROUP_THREE = static_cast<flag_t>(0x00300000)
staticconstexpr

Definition at line 73 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file().

◆ GETOPT_FLAG_HAS_DEFAULT

constexpr flag_t advgetopt::GETOPT_FLAG_HAS_DEFAULT = static_cast<flag_t>(0x00000200)
staticconstexpr

◆ GETOPT_FLAG_LOCK

constexpr flag_t advgetopt::GETOPT_FLAG_LOCK = static_cast<flag_t>(0x40000000)
staticconstexpr

◆ GETOPT_FLAG_MULTIPLE

constexpr flag_t advgetopt::GETOPT_FLAG_MULTIPLE = static_cast<flag_t>(0x00000080)
staticconstexpr

◆ GETOPT_FLAG_NONE

constexpr flag_t advgetopt::GETOPT_FLAG_NONE = static_cast<flag_t>(0x00000000)
staticconstexpr

Definition at line 43 of file flags.h.

Referenced by define_option(), and option_flags_merge().

◆ GETOPT_FLAG_PROCESS_VARIABLES

constexpr flag_t advgetopt::GETOPT_FLAG_PROCESS_VARIABLES = static_cast<flag_t>(0x00000400)
staticconstexpr

Definition at line 56 of file flags.h.

Referenced by advgetopt::option_info::get_value().

◆ GETOPT_FLAG_REQUIRED

constexpr flag_t advgetopt::GETOPT_FLAG_REQUIRED = static_cast<flag_t>(0x00000040)
staticconstexpr

◆ GETOPT_FLAG_SHOW_ALL

constexpr flag_t advgetopt::GETOPT_FLAG_SHOW_ALL = static_cast<flag_t>(0x00002000)
staticconstexpr

Definition at line 61 of file flags.h.

Referenced by advgetopt::getopt::process_system_options(), and advgetopt::getopt::usage().

◆ GETOPT_FLAG_SHOW_GROUP1

constexpr flag_t advgetopt::GETOPT_FLAG_SHOW_GROUP1 = static_cast<flag_t>(0x00004000)
staticconstexpr

◆ GETOPT_FLAG_SHOW_GROUP2

constexpr flag_t advgetopt::GETOPT_FLAG_SHOW_GROUP2 = static_cast<flag_t>(0x00008000)
staticconstexpr

◆ GETOPT_FLAG_SHOW_MOST

constexpr flag_t advgetopt::GETOPT_FLAG_SHOW_MOST = static_cast<flag_t>(0x00000000)
staticconstexpr

Definition at line 59 of file flags.h.

◆ GETOPT_FLAG_SHOW_SYSTEM

constexpr flag_t advgetopt::GETOPT_FLAG_SHOW_SYSTEM = static_cast<flag_t>(0x00010000)
staticconstexpr

◆ GETOPT_FLAG_SHOW_USAGE_ON_ERROR

constexpr flag_t advgetopt::GETOPT_FLAG_SHOW_USAGE_ON_ERROR = static_cast<flag_t>(0x00001000)
staticconstexpr

Definition at line 60 of file flags.h.

Referenced by advgetopt::getopt::parse_options_from_file(), and advgetopt::getopt::usage().

◆ NAME_SEPARATOR_DASHES

constexpr name_separator_t advgetopt::NAME_SEPARATOR_DASHES = 0x0002
constexpr

Definition at line 107 of file conf_file.h.

Referenced by advgetopt::conf_file::save_configuration().

◆ NAME_SEPARATOR_UNDERSCORES

constexpr name_separator_t advgetopt::NAME_SEPARATOR_UNDERSCORES = 0x0001
constexpr

Definition at line 106 of file conf_file.h.

◆ NO_SHORT_NAME

constexpr short_name_t advgetopt::NO_SHORT_NAME = U'\0'
constexpr

◆ SECTION_OPERATOR_BLOCK

constexpr section_operator_t advgetopt::SECTION_OPERATOR_BLOCK = 0x0004
constexpr

◆ SECTION_OPERATOR_C

constexpr section_operator_t advgetopt::SECTION_OPERATOR_C = 0x0001
constexpr

◆ SECTION_OPERATOR_CPP

constexpr section_operator_t advgetopt::SECTION_OPERATOR_CPP = 0x0002
constexpr

◆ SECTION_OPERATOR_INI_FILE

constexpr section_operator_t advgetopt::SECTION_OPERATOR_INI_FILE = 0x0008
constexpr

◆ SECTION_OPERATOR_MASK

constexpr section_operator_t advgetopt::SECTION_OPERATOR_MASK = 0x000F
constexpr

Definition at line 101 of file conf_file.h.

◆ SECTION_OPERATOR_NONE

constexpr section_operator_t advgetopt::SECTION_OPERATOR_NONE = 0x0000
constexpr

Definition at line 93 of file conf_file.h.

Referenced by advgetopt::conf_file::set_parameter().

◆ SECTION_OPERATOR_ONE_SECTION

constexpr section_operator_t advgetopt::SECTION_OPERATOR_ONE_SECTION = 0x8000
constexpr

◆ SYSTEM_OPTION_BUILD_DATE

constexpr flag_t advgetopt::SYSTEM_OPTION_BUILD_DATE = 0x0010
constexpr

Definition at line 61 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_COMMANDS_MASK

constexpr flag_t advgetopt::SYSTEM_OPTION_COMMANDS_MASK = 0x0FFF
constexpr

Definition at line 71 of file advgetopt.h.

Referenced by advgetopt::getopt::finish_parsing().

◆ SYSTEM_OPTION_CONFIG_DIR

constexpr flag_t advgetopt::SYSTEM_OPTION_CONFIG_DIR = 0x1000
constexpr

Definition at line 69 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_CONFIGURATION_FILENAMES

constexpr flag_t advgetopt::SYSTEM_OPTION_CONFIGURATION_FILENAMES = 0x0040
constexpr

Definition at line 63 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_COPYRIGHT

constexpr flag_t advgetopt::SYSTEM_OPTION_COPYRIGHT = 0x0004
constexpr

Definition at line 59 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_ENVIRONMENT_VARIABLE_NAME

constexpr flag_t advgetopt::SYSTEM_OPTION_ENVIRONMENT_VARIABLE_NAME = 0x0020
constexpr

Definition at line 62 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_HELP

constexpr flag_t advgetopt::SYSTEM_OPTION_HELP = 0x0001
constexpr

Definition at line 57 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_LICENSE

constexpr flag_t advgetopt::SYSTEM_OPTION_LICENSE = 0x0008
constexpr

Definition at line 60 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_NONE

constexpr flag_t advgetopt::SYSTEM_OPTION_NONE = 0x0000
constexpr

Definition at line 54 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_OPTIONS_MASK

constexpr flag_t advgetopt::SYSTEM_OPTION_OPTIONS_MASK = 0xF000
constexpr

Definition at line 72 of file advgetopt.h.

◆ SYSTEM_OPTION_PATH_TO_OPTION_DEFINITIONS

constexpr flag_t advgetopt::SYSTEM_OPTION_PATH_TO_OPTION_DEFINITIONS = 0x0080
constexpr

Definition at line 64 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_SHOW_OPTION_SOURCES

constexpr flag_t advgetopt::SYSTEM_OPTION_SHOW_OPTION_SOURCES = 0x0100
constexpr

Definition at line 65 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_SHOW_OPTION_VALUE

constexpr flag_t advgetopt::SYSTEM_OPTION_SHOW_OPTION_VALUE = 0x0200
constexpr

Definition at line 66 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

◆ SYSTEM_OPTION_VERSION

constexpr flag_t advgetopt::SYSTEM_OPTION_VERSION = 0x0002
constexpr

Definition at line 58 of file advgetopt.h.

Referenced by advgetopt::getopt::process_system_options().

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.