summaryrefslogtreecommitdiffhomepage
path: root/programopts.h
diff options
context:
space:
mode:
Diffstat (limited to 'programopts.h')
-rw-r--r--programopts.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/programopts.h b/programopts.h
new file mode 100644
index 0000000..442d3b0
--- /dev/null
+++ b/programopts.h
@@ -0,0 +1,29 @@
+// Parse command line options of program
+
+#pragma once
+
+#include <functional>
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+#define EXPORT __attribute__((visibility("default")))
+
+namespace Reichwein {
+
+class EXPORT 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;
+};
+
+} // namespace