From 653d7383faeb5c3c92a64001ecfa00ba44825e3a Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sun, 25 Oct 2015 21:10:14 +0200 Subject: libkmstest: add Option & OptionSet --- libkmstest/opts.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libkmstest/opts.h (limited to 'libkmstest/opts.h') diff --git a/libkmstest/opts.h b/libkmstest/opts.h new file mode 100644 index 0000000..1b0fd22 --- /dev/null +++ b/libkmstest/opts.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +class Option +{ + friend class OptionSet; +public: + Option(const std::string& str, std::function func); + Option(const std::string& str, std::function func); + +private: + void parse(const std::string& str); + + char m_short; + std::string m_long; + int m_has_arg; + std::function m_void_func; + std::function m_func; +}; + +class OptionSet +{ +public: + OptionSet(std::initializer_list