X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=include%2Fparameter.h;h=87c1590ccc85fbcdbe9d6f69ce01f0d5fd2253a6;hb=9c5fcaa792ff23d80b282fc0ac036db920713382;hp=e55a2d1e248c2fe3541fb3395177a52691c33dee;hpb=56957154bf5f7dfc6005d689347df96276e4b51d;p=command.git diff --git a/include/parameter.h b/include/parameter.h index e55a2d1..87c1590 100644 --- a/include/parameter.h +++ b/include/parameter.h @@ -2,21 +2,23 @@ #define __COMMAND_PARAMETER_H #include +#include #include "descriptive.h" #include "callable.h" namespace command { /** - * Class responsible for handling commandline arguments. - * Arguments are required,x non-named parameters of program. + * Base class for all the Arguments and Options. * * Example: * ./myprog ARGUMENT */ class Parameter : public Descriptive { protected: - std:string userValue; + /** Variable indicating if current Parameter was already used or not */ + bool used = false; + public: typedef class Parameter Type; /** @@ -24,16 +26,55 @@ namespace command { * * @param description Description of current Argument */ - Parameter(std::string description) + Parameter(const std::string & description) : Descriptive(description) { } - virtual ~Parameter() {} + virtual ~Parameter() { } + + /** + * Method used for handling method calls linked with this Parameter + */ virtual void handle() = 0; - virtual void passUserValue(std::string argVal) { - userValue = argVal; + /** + * Method used for checking if the given user value understandable for + * parameter. + * + * @return true if passed value is understandable by current Parameter. + * False otherwise. + */ + virtual bool understand(const std::string & ) = 0; + + /** + * Indicates if current Parameter is required + * + * @return false, as all Parameters are non-required by default. If you + * want to make Parameter as required, wrap it using Required class + */ + virtual bool isRequired() { + return false; + }; + + /** + * Indicates if current Parameter has been already used + * + * @return true if current Parameter has been already used. False otherwise. + */ + virtual bool isUsed() { + return used; } + + /** + */ + virtual bool hungryForValue() { + return false; + } + + /** + * @return position where value starts in passed string + */ + virtual unsigned int valuePosition(const std::string & ) = 0; }; }