Documentation improvements.
[command.git] / include / argument.h
index 159f5eb3f258e284d45768dc657b0f54bcc9b299..5690e5dbf6ba2973147535ce32d66459ad23dd95 100644 (file)
 namespace command {
     /**
      * Class responsible for handling commandline arguments.
-     * Arguments are required, non-named parameters of program.
-     * Accepts
+     * Arguments are non-named parameters of program.
      *
      * Example:
-     *  ./myprog ARGUMENT
+     *  - ./myprog ARGUMENT
+     *  - ./myprog /path/to/file
+     *  - ./myprog "some argument"
      */
-    template<typename ArgumentType>
-    class Argument : public Parameter, public Callable<ArgumentType> {
+    template<typename ParameterType>
+    class Argument : public Parameter, public Callable<ParameterType> {
     protected:
-        /** Variable indicating if current Argument was already used or not */
-        bool used = false;
-
-        ArgumentType argument;
+        ParameterType value;
     public:
         typedef class Argument Type;
 
@@ -33,8 +31,8 @@ namespace command {
          * @param description Description of current Argument
          * @param function Function used to handle current Argument.
          */
-        Argument(const std::string & description, void (*function)(ArgumentType))
-            : Parameter(description), Callable<ArgumentType>(function) {
+        Argument(const std::string & description, void (*function)(ParameterType))
+            : Parameter(description), Callable<ParameterType>(function) {
         }
 
         /**
@@ -43,36 +41,37 @@ namespace command {
         virtual ~Argument() { }
 
         /**
-         *
+         * \inheritdoc
          */
         virtual void handle() {
-            this->call(argument);
+            this->call(value);
         }
 
         /**
          * Method used for checking if Argument understands user value.
-         * If so current Argument is flagged as used, and no more checks against
+         * If so current Argument is flagged as used and no more checks against
          * it will be done in future.
          *
-         * If conversion from passed value to ArgumentType is impossible, it is
-         * ignored.
+         * \attention If conversion from passed value to ParameterType is
+         * impossible, it is ignored. It means that it is not understanded by
+         * Argument.
          *
          * @param argv command line value against which test will be made.
          *
-         * @return If passed argv is succesfully converted to ArgumentType,
-         *  returns true, and Argument is set as used one. If there was an error
+         * @return If passed argv is succesfully converted to ParameterType,
+         *  returns true and Argument is set as used one. If there was an error
          *  during conversion, method returns false and can be used to check
          *  against next value.
          */
         virtual bool understand(const std::string & argv) {
-            if (!used) {
+            if (!isUsed()) {
                 std::stringstream ss;
 
                 ss << argv;
-                ss >> argument;
+                ss >> value;
 
                 if (!ss.fail()) {
-                    used = true;
+                    this->used = true;
                     return true;
                 }
             }