summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlocke <cgloeckner@freenet.de>2017-04-22 19:15:26 (GMT)
committerGitHub <noreply@github.com>2017-04-22 19:15:26 (GMT)
commit7f6d128b02da93762ec473dccd045b8942fca637 (patch)
tree57aa777ae0d4c7cc0f1f39735fb45a56d156a4b9
parent1932989e4f277fc6d513c697c2041d7be033844b (diff)
Updated documentation
-rw-r--r--getoptpp.hpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/getoptpp.hpp b/getoptpp.hpp
index cd7469b..960bdd4 100644
--- a/getoptpp.hpp
+++ b/getoptpp.hpp
@@ -13,7 +13,17 @@ class Options {
public:
Options();
+ /// @param name name of the option
+ /// @param has_arg kind of arguments that are used (no_argument, required_argument, optional_argument)
+ /// @param val identifies the option (see getopt documentation)
+ /// @param handle lambda that is invoked when the option occures
void add(std::string const & name, int has_arg, int val, Handle handle);
+
+ /// @param name name of the option
+ /// @param has_arg kind of arguments that are used (no_argument, required_argument, optional_argument)
+ /// @param flag optional pointer that is set after the option occured
+ /// @param val value for the flag to be set
+ /// @param handle lambda that is invoked when the option occures
void add(std::string const & name, int has_arg, int* flag, int val, Handle handle);
void process(int argc, char* argv[]);
@@ -35,6 +45,7 @@ void Options::add(std::string const & name, int has_arg, int val, Handle handle)
}
void Options::add(std::string const & name, int has_arg, int* flag, int val, Handle handle) {
+ // create a new option from the args
options.emplace_back();
auto& option = options.back();
option.name = name.c_str();
@@ -42,10 +53,13 @@ void Options::add(std::string const & name, int has_arg, int* flag, int val, Han
option.flag = flag;
option.val = val;
- int index = val;
+ int index = val; // let val be the option's unique identifier
if (flag != nullptr) {
+ // flag is not null, so the val is not used as identifier
+ // so pick another one
index = num_flags++;
}
+ // store the handle
handles[index] = handle;
}