#include <CmdLineParser.h>


Public Member Functions | |
| OptionsCHAR (const Parser &parser) | |
| Option< char > & | Add (const std::string &, const std::string &="", char= '\0', const char *=0, bool=false) |
| bool | Match (int &, char **, int) |
Private Attributes | |
| std::map< std::string, std::pair< const char *, bool > > | m_ranges |
| CmdLine::OptionsCHAR::OptionsCHAR | ( | const Parser & | parser | ) | [inline] |
| Option< char > & OptionsCHAR::Add | ( | const std::string & | name, | |
| const std::string & | alias = "", |
|||
| char | def = '\0', |
|||
| const char * | range = 0, |
|||
| bool | include_null_char = false | |||
| ) |
This function allows a certain range of chars (null terminated string) to be specified. If the found value doesn't match one of these chars, then the default value is used.
| [in] | name | The option's label |
| [in] | alias | The option's alias |
| [in] | def | The option's default value |
| [in] | range | An array of characters that defines the set of allowed chars |
| [in] | include_null_char | If the NULL char is one of the allowed values of the option, set this parameter to true |
Bool.Add("-c", "--char", 'a", "abc");
In this example the default char is 'a' and the allowed chars are 'a', 'b' and 'c'. If the user gives, for instance, '--char d', then Bool.Get("-c") will return 'a' rather than 'd'.
If you want to add the NULL char (\0) as a valid value, then calls Bool.Add as follows:
Bool.Add("-c", "--char", 'a", "abc", true);
References CmdLine::Parser::m_flags, CmdLine::OptionsType< char >::m_parser, and m_ranges.
| bool OptionsCHAR::Match | ( | int & | i, | |
| char ** | argv, | |||
| int | argc | |||
| ) |
Try to identify a char option in command-line and then add it (together its char argument) into m_opts.
Some input combinations are interpreted as special characters:
\0 = null byte
\a = bell character
\b = backspace
\f = formfeed
\n = newline
\r = carriage return
\t = horizontal tab
\v = vertical tab
\\ = backslash
References CmdLine::OptionsType< char >::CheckDuplicate(), CmdLine::OptionsType< char >::Find(), CmdLine::Option< T >::IsSet(), CmdLine::Option< T >::m_found, m_ranges, CmdLine::Option< T >::m_value, CmdLine::NO_VALUE, CmdLine::OUT_OF_RANGE, and CmdLine::SILENT.
Referenced by CmdLine::Parser::Process().
std::map<std::string, std::pair<const char*, bool> > CmdLine::OptionsCHAR::m_ranges [private] |