1 #ifndef __COMMAND_ARGUMENT_H
2 #define __COMMAND_ARGUMENT_H
14 * Class responsible for handling commandline arguments.
15 * Arguments are non-named parameters of program.
19 * - ./myprog /path/to/file
20 * - ./myprog "some argument"
22 template<typename ParameterType>
23 class Argument : public Parameter, public Callable<ParameterType> {
27 typedef class Argument Type;
30 * Default constructor.
32 * @param description Description of current Argument
33 * @param function Function used to handle current Argument.
35 Argument(const std::string & description, void (*function)(ParameterType))
36 : Parameter(description), Callable<ParameterType>(function) {
39 Argument(const std::string & description, std::function<void(ParameterType)> function)
40 : Parameter(description), Callable<ParameterType>(function) {
46 virtual ~Argument() { }
51 virtual void handle() {
57 * Method used for checking if Argument understands user value.
58 * If so current Argument is flagged as used and no more checks against
59 * it will be done in future.
61 * \attention If conversion from passed value to ParameterType is
62 * impossible, it is ignored. It means that it is not understanded by
65 * @param argv command line value against which test will be made.
67 * @return If passed argv is succesfully converted to ParameterType,
68 * returns true and Argument is set as used one. If there was an error
69 * during conversion, method returns false and can be used to check
72 virtual bool understand(const std::string & argv) {
75 ss << std::fixed << argv;
88 virtual unsigned int valuePosition(const std::string & ) {
94 #endif /* __COMMAND_ARGUMENT_H */