From 121c2f8b8cbcae79a82093421282b0526ddd17c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Wed, 22 Apr 2015 01:27:44 +0200 Subject: [PATCH] Added Option template class. --- include/argument.h | 2 +- include/option.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 include/option.h diff --git a/include/argument.h b/include/argument.h index 6a292b4..743f0c2 100644 --- a/include/argument.h +++ b/include/argument.h @@ -8,7 +8,7 @@ namespace command { /** * Class responsible for handling commandline arguments. - * Arguments are required non-named parameters for program. + * Arguments are required,x non-named parameters of program. * * Example: * ./myprog ARGUMENT diff --git a/include/option.h b/include/option.h new file mode 100644 index 0000000..241754d --- /dev/null +++ b/include/option.h @@ -0,0 +1,35 @@ +#ifndef __COMMAND_OPTION_H +#define __COMMAND_OPTION_H + +namespace command { + /** + * Class responsible for handling commandline options. + * Options are non-required, named parameters of program. + * + * Example: + * ./myprog OptionName OptionValue + */ + template + class Option + : Argument { + protected: + /** + * Option name + */ + std::string name; + + public: + /** + * Default constructor. + * + * @param name Name of the current Option + * @param description Description of current Option + * @param function Function used to handle current Option. + */ + Argument(std::string name, std::string description, FunctionType function) + : name(name), Argument(description, function) { + } + }; +} + +#endif /* __COMMAND_OPTION_H */ -- 2.30.2