summaryrefslogtreecommitdiffhomepage
path: root/programopts.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-10-26 15:38:54 +0100
committerRoland Reichwein <mail@reichwein.it>2020-10-26 15:38:54 +0100
commitce77838c4f32b9dc237f0c4b17d1f1e1741254d4 (patch)
treef8b987e81bd94bff0a4035ddfe75d344664ece10 /programopts.h
parentaddbdf3cf71c6d332bdf86a101a7df544fe5a9a2 (diff)
Added ProgramOpts
Diffstat (limited to 'programopts.h')
-rw-r--r--programopts.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/programopts.h b/programopts.h
new file mode 100644
index 0000000..af706f7
--- /dev/null
+++ b/programopts.h
@@ -0,0 +1,24 @@
+// Parse command line options of program
+
+#pragma once
+
+#include <functional>
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+class ProgramOpts
+{
+public:
+ // Processing of options in lambdas: each do return true iff parameter was consumed
+ ProgramOpts(int argc, char* argv[], std::map<std::string, std::function<bool(const std::string&)>>& option_prefixes);
+ ~ProgramOpts();
+ void process(); // must be called to run functions per option, given to ctor
+ std::string programName();
+ std::vector<std::string> nonOptionArguments();
+private:
+ struct impl;
+ std::unique_ptr<impl> m_pimpl;
+};
+