Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | Related Pages

conf.hh

00001 #ifndef CONF_HH
00002 #define CONF_HH
00003 
00004 #include <vector>
00005 #include <string>
00006 #include <map>
00007 
00017 namespace conf {
00018   
00020   struct Option {
00021     Option() : short_name(0), required(false), needs_argument(false), 
00022                specified(false) { }
00023     unsigned char short_name; 
00024     std::string long_name; 
00025     std::string value; 
00026     bool required; 
00027     bool needs_argument; 
00028     bool specified; 
00029     std::string help; 
00030   };
00031 
00035   struct Config {
00036     
00038     Config();
00039 
00049     Config& operator()(unsigned char short_name,
00050                        std::string long_name,
00051                        std::string type = "",
00052                        std::string default_value = "",
00053                        std::string help = "");
00054 
00056     void parse(int argc, char *argv[]);
00057 
00061     void read(FILE *file);
00062     
00064     void check_required() const;
00065 
00067     std::string help_string() const;
00068 
00070     const Option& operator[](unsigned char short_name) const;
00071 
00073     const Option& operator[](std::string long_name) const;
00074 
00076     typedef std::map<unsigned char, int> ShortMap;
00077 
00079     typedef std::map<std::string, int> LongMap;
00080 
00081     std::vector<Option> options; 
00082     ShortMap short_map; 
00083     LongMap long_map; 
00084     std::vector<std::string> arguments; 
00085     int longest_name_length; 
00086   };
00087 
00088 };
00089 
00090 #endif /* CONF_HH */

Generated on Sat Feb 26 22:54:39 2005 for GoCam by doxygen 1.3.4