X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=include%2Fargument.h;fp=include%2Fargument.h;h=6a292b4f6b63135945f8d8a9619b427c4b5de450;hb=638b210134daa5d4ecd207e003241a4edb7234dc;hp=0000000000000000000000000000000000000000;hpb=995039163b27983555d71ec9ad8cecf4e70fd229;p=command.git diff --git a/include/argument.h b/include/argument.h new file mode 100644 index 0000000..6a292b4 --- /dev/null +++ b/include/argument.h @@ -0,0 +1,49 @@ +#ifndef __COMMAND_ARGUMENT_H +#define __COMMAND_ARGUMENT_H + +#include + +#include + +namespace command { + /** + * Class responsible for handling commandline arguments. + * Arguments are required non-named parameters for program. + * + * Example: + * ./myprog ARGUMENT + */ + template + class Argument : public Descriptive { + public: + typedef void (*)(ArgumentType) FunctionType; + + protected: + /** + * Function handling user Arguments + */ + FunctionType function; + + public: + /** + * Default constructor. + * + * @param description Description of current Argument + * @param function Function used to handle current Argument. + */ + Argument(std::string description, FunctionType function) + : Descriptive(description), function(function) { + } + + /** + * Executes command binded with argument + * + * @param value Value passed to program argument + */ + void run(ArgumentType value) { + this->function(value); + } + }; +} + +#endif /* __COMMAND_ARGUMENT_H */