26 #include <config/sqlite.h> 35 main(
int argc,
char **argv)
40 cout <<
"Loading configuration..." << flush;
41 config->
load(
"qa.db",
"qa_defaults.db");
42 cout <<
"done" << endl;
44 cout <<
"failed" << endl;
50 cout <<
"[FLOAT] set f=" << of <<
"..." << flush;
52 cout <<
"done" << endl;
53 cout <<
"[FLOAT] get..." << flush;
54 float f = config->
get_float(
"/testing/float");
55 printf(
"done, f=%f\n", f);
57 cout <<
"failed" << endl;
63 cout <<
"[DEFAULT FLOAT] set f=" << of <<
"..." << flush;
65 cout <<
"done" << endl;
66 cout <<
"[DEFAULT_FLOAT] get..." << flush;
67 float f = config->
get_float(
"/testing/default_float");
68 if ( ! config->
is_default(
"/testing/default_float") ) {
71 printf(
"done, f=%f\n", f);
73 cout <<
"failed" << endl;
79 cout <<
"[UINT] set u=" << ou <<
"..." << flush;
80 config->
set_uint(
"/testing/uint", ou);
81 cout <<
"done" << endl;
82 cout <<
"[UINT] get..." << flush;
83 unsigned int u = config->
get_uint(
"/testing/uint");
84 printf(
"done, u=%u\n", u);
86 cout <<
"failed" << endl;
92 cout <<
"[INT] set i=" << oi <<
"..." << flush;
93 config->
set_int(
"/testing/int", oi);
94 cout <<
"done" << endl;
95 cout <<
"[INT] get..." << flush;
96 int i = config->
get_int(
"/testing/int");
97 printf(
"done, i=%i\n", i);
99 cout <<
"failed" << endl;
105 cout <<
"[BOOL] set b=" << ob <<
"..." << flush;
106 config->
set_bool(
"/testing/bool", ob);
107 cout <<
"done" << endl;
108 cout <<
"[BOOL] get..." << flush;
109 bool b = config->
get_bool(
"/testing/bool");
110 printf(
"done, b=%s\n", (b ?
"true" :
"false"));
112 cout <<
"failed" << endl;
117 string os =
"This ain't no paradoxon";
118 cout <<
"[STRING] set s='" << os <<
"'..." << flush;
120 cout <<
"done" << endl;
121 cout <<
"[STRING] get..." << flush;
122 string s = config->
get_string(
"/testing/string");
123 printf(
"done, s='%s'\n", s.c_str());
125 cout <<
"failed" << endl;
130 cout <<
"[EXIST] Checking if test string exists..." << flush;
131 if ( config->
exists(
"/testing/string") ) {
138 cout <<
"failed" << endl;
143 string os =
"This ain't no paradoxon";
144 cout <<
"[LONGSTRING] set s='" << os <<
"'..." << flush;
145 config->
set_string(
"/testing/veryveryveryverylongstring", os);
146 cout <<
"done" << endl;
147 cout <<
"[LONGSTRING] get..." << flush;
148 string s = config->
get_string(
"/testing/veryveryveryverylongstring");
149 printf(
"done, s='%s'\n", s.c_str());
151 cout <<
"failed" << endl;
165 cout <<
"Loading configuration for 2nd db..." << flush;
166 config2->load(
"qa2.db",
"qa2_defaults.db");
167 cout <<
"done" << endl;
169 cout <<
"failed" << endl;
174 cout <<
"Copying configuration..." << flush;
175 config2->copy(config);
176 cout <<
"done" << endl;
178 cout <<
"failed" << endl;
virtual std::string get_string(const char *path)
Get value from configuration which is of type string.
virtual bool is_default(const char *path)
Check if a value was read from the default config.
ValueIterator * iterator()
Iterator for all values.
virtual int get_int(const char *path)
Get value from configuration which is of type int.
virtual bool get_bool(const char *path)
Get value from configuration which is of type bool.
Configuration storage using SQLite.
Fawkes library namespace.
Thrown if config could not be opened.
virtual unsigned int get_uint(const char *path)
Get value from configuration which is of type unsigned int.
virtual bool next()=0
Check if there is another element and advance to this if possible.
virtual float get_float() const =0
Get float value.
virtual bool is_float() const =0
Check if current value is a float.
virtual void set_default_float(const char *path, float f)
Set new default value in configuration of type float.
virtual void load(const char *filename)
Load configuration.
virtual float get_float(const char *path)
Get value from configuration which is of type float.
virtual void set_float(const char *path, float f)
Set new value in configuration of type float.
virtual void set_int(const char *path, int i)
Set new value in configuration of type int.
virtual void set_bool(const char *path, bool b)
Set new value in configuration of type bool.
virtual bool exists(const char *path)
Check if a given value exists.
Generic configuration exception.
virtual const char * path() const =0
Path of value.
void print_trace()
Prints trace to stderr.
Iterator interface to iterate over config values.
virtual void set_uint(const char *path, unsigned int uint)
Set new value in configuration of type unsigned int.
virtual bool is_default() const =0
Check if current value was read from the default config.
virtual void set_string(const char *path, std::string &s)
Set new value in configuration of type string.