Added Option template class.
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Tue, 21 Apr 2015 23:27:44 +0000 (01:27 +0200)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Tue, 21 Apr 2015 23:27:44 +0000 (01:27 +0200)
include/argument.h
include/option.h [new file with mode: 0644]

index 6a292b4f6b63135945f8d8a9619b427c4b5de450..743f0c23e26ddda4fdbdc29563e6d32e7b8db197 100644 (file)
@@ -8,7 +8,7 @@
 namespace command {
     /**
      * Class responsible for handling commandline arguments.
-     * Arguments are required non-named parameters for program.
+     * Arguments are required,x non-named parameters of program.
      *
      * Example:
      *  ./myprog ARGUMENT
diff --git a/include/option.h b/include/option.h
new file mode 100644 (file)
index 0000000..241754d
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef __COMMAND_OPTION_H
+#define __COMMAND_OPTION_H
+
+namespace command {
+    /**
+     * Class responsible for handling commandline options.
+     * Options are non-required, named parameters of program.
+     *
+     * Example:
+     *  ./myprog OptionName OptionValue
+     */
+    template<typename OptionType>
+    class Option
+        : Argument<OptionType> {
+    protected:
+        /**
+         * Option name
+         */
+        std::string name;
+
+    public:
+        /**
+         * Default constructor.
+         *
+         * @param name Name of the current Option
+         * @param description Description of current Option
+         * @param function Function used to handle current Option.
+         */
+        Argument(std::string name, std::string description, FunctionType function)
+            : name(name), Argument<OptionType>(description, function) {
+        }
+    };
+}
+
+#endif /* __COMMAND_OPTION_H */