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, std::function<void(ParameterType)> function)
36 : Parameter(description), Callable<ParameterType>(function) {
42 virtual ~Argument() { }
47 virtual void handle() {
53 * Method used for checking if Argument understands user value.
54 * If so current Argument is flagged as used and no more checks against
55 * it will be done in future.
57 * \attention If conversion from passed value to ParameterType is
58 * impossible, it is ignored. It means that it is not understanded by
61 * @param argv command line value against which test will be made.
63 * @return If passed argv is succesfully converted to ParameterType,
64 * returns true and Argument is set as used one. If there was an error
65 * during conversion, method returns false and can be used to check
68 virtual bool understand(const std::string & argv) {
71 ss << std::fixed << argv;
84 virtual unsigned int valuePosition(const std::string & ) {
90 #endif /* __COMMAND_ARGUMENT_H */