27 #ifndef VARCONF_CONFIG_H 28 #define VARCONF_CONFIG_H 30 #include "varconf_defs.h" 31 #include "parse_error.h" 34 #include <sigc++/trackable.h> 35 #include <sigc++/signal.h> 43 typedef std::map< std::string, Variable > sec_map;
44 typedef std::map< std::string, sec_map> conf_map;
45 typedef std::map< char, std::pair<std::string, bool> > parameter_map;
47 class VARCONF_API
Config :
virtual protected sigc::trackable {
60 VARCONF_API
friend std::ostream & operator <<(std::ostream & out,
Config & conf);
61 VARCONF_API
friend std::istream & operator >>(std::istream & in,
Config & conf);
62 VARCONF_API
friend bool operator ==(
const Config & one,
const Config & two);
66 static void clean(std::string & str);
69 bool find(
const std::string & section,
const std::string & key =
"")
const;
73 bool erase(
const std::string & section,
const std::string & key =
"");
77 bool writeToStream(std::ostream & out, Scope scope_mask)
const;
80 int getCmdline(
int argc,
char** argv, Scope scope = INSTANCE);
85 void getEnv(
const std::string & prefix, Scope scope = INSTANCE);
88 bool writeToFile(
const std::string & filename,
89 Scope scopeMask = (Scope)(GLOBAL | USER | INSTANCE))
const;
93 bool readFromFile(
const std::string & filename, Scope scope = USER);
97 void parseStream(std::istream & in, Scope scope);
100 bool findSection(
const std::string & section)
const;
103 bool findItem(
const std::string & section,
const std::string & key)
const;
106 const sec_map & getSection(
const std::string & section);
109 Variable getItem(
const std::string & section,
const std::string & key)
const;
112 void setParameterLookup(
char s_name,
const std::string & l_name,
116 void setItem(
const std::string & section,
const std::string & key,
117 const Variable & item, Scope scope = INSTANCE);
120 const conf_map& getSections()
const;
122 sigc::signal<void> sig;
123 sigc::signal<void, const char*> sige;
124 sigc::signal<void, const std::string&, const std::string&> sigv;
125 sigc::signal<void, const std::string&, const std::string&, Config&> sigsv;
130 static Config* m_instance;
132 parameter_map m_par_lookup;
136 VARCONF_API std::ostream & operator <<(std::ostream & out,
Config & conf);
137 VARCONF_API std::istream & operator >>(std::istream & in,
Config & conf);
138 VARCONF_API
bool operator ==(
const Config & one,
const Config & two);
142 #endif // VARCONF_CONFIG_H