The ArgOption class for ArgParser. More...
#include <zupply.hpp>
Public Member Functions | |
ArgOption (char shortKey, std::string longKey) | |
ArgOption constructor with short key and long key. More... | |
ArgOption (char shortKey) | |
ArgOption constructor with short key only. More... | |
ArgOption (std::string longKey) | |
ArgOption constructor with long key only. More... | |
ArgOption & | call (std::function< void()> todo) |
Set callback function when this option is triggered. One can use lambda function as callback. More... | |
ArgOption & | call (std::function< void()> todo, std::function< void()> otherwise) |
Set callback functions. Both TODO function and Default function required. If ArgParser detect this option, the TODO function will be called. Otherwise, the default callback function will be executed. More... | |
ArgOption & | set_help (std::string helpInfo) |
Set help info for this option. Use this to add description for this option. More... | |
ArgOption & | require (bool require=true) |
Set this option to required or not. After parsing arguments, if this set to required but not found, ArgParser will generate an error information. More... | |
ArgOption & | set_once (bool onlyOnce=true) |
Set this option to allow option be called only once. This is set to disable accidentally set a variable multiply times. More... | |
ArgOption & | set_type (std::string type) |
Set option variable type. Optional. Let user know what type this option take, INT, FLOAT, STRING... More... | |
ArgOption & | set_min (int minCount) |
Set minimum number of argument this option take. If minimum number not satisfied, ArgParser will generate an error. More... | |
ArgOption & | set_max (int maxCount) |
Set maximum number of argument this option take. If maximum number not satisfied, ArgParser will generate an error. More... | |
Value | get_value () |
Return the stored value. More... | |
int | get_count () |
Return the count. More... | |
Friends | |
class | ArgParser |
Detailed Description
Constructor & Destructor Documentation
zz::cfg::ArgOption::ArgOption | ( | char | shortKey, |
std::string | longKey | ||
) |
ArgOption constructor with short key and long key.
- Parameters
-
shortKey A char, use 'a' longKey A std::string "long"
zz::cfg::ArgOption::ArgOption | ( | char | shortKey | ) |
ArgOption constructor with short key only.
- Parameters
-
shortKey A char, use 'a'
zz::cfg::ArgOption::ArgOption | ( | std::string | longKey | ) |
ArgOption constructor with long key only.
- Parameters
-
longKey A std::string "long"
Member Function Documentation
ArgOption & zz::cfg::ArgOption::call | ( | std::function< void()> | todo | ) |
Set callback function when this option is triggered. One can use lambda function as callback.
- Parameters
-
todo Function callback
- Returns
- Reference to this option
ArgOption & zz::cfg::ArgOption::call | ( | std::function< void()> | todo, |
std::function< void()> | otherwise | ||
) |
Set callback functions. Both TODO function and Default function required. If ArgParser detect this option, the TODO function will be called. Otherwise, the default callback function will be executed.
- Parameters
-
todo Callback function when triggered otherwise Default function if this option not found
- Returns
- Reference to this option
int zz::cfg::ArgOption::get_count | ( | ) |
Return the count.
- Returns
- Reference count
Value zz::cfg::ArgOption::get_value | ( | ) |
Return the stored value.
- Returns
- Stored value
ArgOption & zz::cfg::ArgOption::require | ( | bool | require = true | ) |
Set this option to required or not. After parsing arguments, if this set to required but not found, ArgParser will generate an error information.
- Parameters
-
require Require this option if set to true
- Returns
- Reference to this option
ArgOption & zz::cfg::ArgOption::set_help | ( | std::string | helpInfo | ) |
Set help info for this option. Use this to add description for this option.
- Parameters
-
helpInfo
- Returns
- Reference to this option
ArgOption & zz::cfg::ArgOption::set_max | ( | int | maxCount | ) |
Set maximum number of argument this option take. If maximum number not satisfied, ArgParser will generate an error.
- Parameters
-
maxCount
- Returns
- Reference to this option
ArgOption & zz::cfg::ArgOption::set_min | ( | int | minCount | ) |
Set minimum number of argument this option take. If minimum number not satisfied, ArgParser will generate an error.
- Parameters
-
minCount
- Returns
- Reference to this option
ArgOption & zz::cfg::ArgOption::set_once | ( | bool | onlyOnce = true | ) |
Set this option to allow option be called only once. This is set to disable accidentally set a variable multiply times.
- Parameters
-
onlyOnce Allow this option be used only once
- Returns
- Reference to this option
ArgOption & zz::cfg::ArgOption::set_type | ( | std::string | type | ) |
Set option variable type. Optional. Let user know what type this option take, INT, FLOAT, STRING...
- Parameters
-
type Type name in string, just a reminder.
- Returns
- Reference to this option
The documentation for this class was generated from the following files:
- zupply.hpp
- zupply.cpp