00001 #ifndef N2NCCONFIGURATION_H 00002 #define N2NCCONFIGURATION_H 00003 00004 #include "nixsys.h" 00005 00006 namespace n2nc { 00007 00012 class ConfigurationOpt{ 00013 public: 00019 ConfigurationOpt(std::string first, std::string second); 00021 ConfigurationOpt(const ConfigurationOpt& opt); 00022 ~ConfigurationOpt(); 00023 std::string toString(); 00024 std::string value(); 00026 void setValue(std::string value); 00031 void operator=(std::string value); 00032 00033 private: 00034 std::string m_first ; 00035 std::string m_second ; 00036 }; 00037 00043 class ConfigurationCtx{ 00044 public: 00045 ConfigurationCtx(std::string name); 00046 ~ConfigurationCtx(); 00048 std::string toString(); 00050 bool addOption(const ConfigurationOpt &opt); 00052 bool delOption(ConfigurationOpt &opt); 00054 ConfigurationOpt& getOpt(std::string optname); 00056 ConfigurationOpt& operator[](std::string optname); 00057 00058 00059 private: 00060 std::list<ConfigurationOpt> m_options ; 00061 std::string m_name ; 00062 }; 00063 00069 class Configuration{ 00070 public: 00071 Configuration(); 00072 ~Configuration(); 00074 std::string toString(); 00076 bool fromString(std::string &str); 00078 bool addContext(const ConfigurationCtx &ctx); 00080 bool delContext(ConfigurationCtx &ctx); 00082 ConfigurationCtx& getCtx(std::string ctxname); 00084 ConfigurationCtx& operator[](std::string ctxname); 00085 00086 private: 00087 std::list<ConfigurationCtx> m_contexts ; 00088 typedef std::pair<std::string,ConfigurationCtx> m_context2_t ; 00089 std::map<std::string,ConfigurationCtx> m_contexts2 ; 00090 00096 }; 00097 00098 } //ns 00099 #endif