From 5f0849ef45459647661fabd402c2642146eb4d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Mon, 8 May 2017 12:00:27 +0200 Subject: Parse arguments without options --- getoptpp.hpp | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'getoptpp.hpp') diff --git a/getoptpp.hpp b/getoptpp.hpp index ccefe9a..0eafe3f 100644 --- a/getoptpp.hpp +++ b/getoptpp.hpp @@ -1,8 +1,10 @@ #pragma once +#include #include #include #include #include +#include #include namespace dg { @@ -12,25 +14,27 @@ using Handle = std::function; 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 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[]); - + + bool process(int argc, char* argv[]); + const std::vector arguments() const { return args; } + private: std::size_t num_flags; std::vector