*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / configuration_manager.hh
diff --git a/pc-tools/ldc2/src/configuration_manager.hh b/pc-tools/ldc2/src/configuration_manager.hh
new file mode 100644 (file)
index 0000000..d88d3dd
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef ARGUMENT_READER_H
+#define ARGUMENT_READER_H
+
+#include <vector>
+#include <string>
+
+using namespace std;
+
+/*!
+ *\brief Hachti's wonderful commandline parser.
+ *
+ * This class is designed to do all the work with the parameters passed to 
+ * the main() routine of a program.\n
+ * Usage:\n
+ *   - Create an instance.
+ *   - Add Parameters/switches with add_param().
+ *   - Add Arguments with add_argument().
+ *   - Call read_args() with your main routine's arguments.
+ *     The vector returned by read_args() contains all error
+ *     messages. When it's empty, everything is fine!
+ *   - Call get_help() if you want nice formatted help output.
+ *     (You want!!!)
+ * Sould be easy to use..... Enjoy.
+ */
+class argument_reader{
+  
+public:
+  argument_reader(string name);
+
+  void add_param (string  shortname, 
+                 string  longname, 
+                 string  description, 
+                 int    *status, 
+                 string *target=NULL, 
+                 string  placeholder=string("<string>")
+                 );
+  
+  vector<string> read_args(int argc, char ** args);
+  void get_help(vector<string> & target);
+  vector<string> get_help();
+
+  void add_argument(string placeholder, string description, int * status, string * target);
+
+private:
+  /*!
+   *\brief Container for one command line option.
+   */
+  class opt_t{
+  public:
+    opt_t (string shortname, string longname,string description, int * status, 
+              string * target=NULL, string placeholder=string("<string>"));
+    string shortname;
+    string longname;
+    int * status;
+    string * target;    
+    string description;
+    string placeholder;
+  };
+
+  /*!
+   *\brief Container for one command line argument.
+   */
+  class arg_t{
+  public:
+    arg_t (string placeholder,string description,
+                   int * status, string * target);
+    int * status;
+    string * target;    
+    string description;
+    string placeholder;
+  };
+  vector<opt_t>opt_v;
+  vector<arg_t>arg_v;
+  string app_name;
+
+}; // class argument_reader
+
+
+#endif