comparison libaudacious++/configdb.hh @ 2118:36d4043b3df2 trunk

[svn] - add the starting point of some audacious C++ bindings
author nenolod
date Wed, 13 Dec 2006 22:46:29 -0800
parents
children 6d7381072a45
comparison
equal deleted inserted replaced
2117:5dc1bfb0ac99 2118:36d4043b3df2
1 #ifndef CONFIGDB_HH
2 #define CONFIGDB_HH
3
4 #include <glib.h>
5
6 #include <string>
7
8 #ifdef _AUDACIOUS_CORE
9 # include "libaudacious/configdb.h"
10 #else
11 # include <audacious/configdb.h>
12 #endif
13
14 namespace Audacious
15 {
16
17 /*
18 * Usage example:
19 *
20 * {
21 * Audacious::ConfigDb foo;
22 * Audacious::ConfValue *bar;
23 *
24 * bar = foo.GetValue("bar", "filter");
25 * std::string filter = bar->asString();
26 * delete bar;
27 *
28 * foo.SetValue("bar", "filter", "none");
29 *
30 * foo.RemoveEntry("bar", "baz");
31 * }
32 */
33
34 class ConfValue
35 {
36 public:
37 gchar *strval;
38 gint intval;
39 bool boolval;
40 gfloat floatval;
41 gdouble dblval;
42
43 std::string asString(void);
44 gint asInt(void);
45 bool asBool(void);
46 gfloat asFloat(void);
47 gdouble asDouble(void);
48
49 ~ConfValue(void);
50 };
51
52 class ConfigDB
53 {
54 private:
55 ConfigDb *db;
56
57 public:
58 enum ValueType { String, Int, Bool, Float, Double };
59
60 ConfValue *GetValue(std::string &section, std::string &name, ConfigDB::ValueType type);
61
62 void SetValue(std::string &section, std::string &name, std::string &value);
63 void SetValue(std::string &section, std::string &name, gint value);
64 void SetValue(std::string &section, std::string &name, bool value);
65 void SetValue(std::string &section, std::string &name, gfloat value);
66 void SetValue(std::string &section, std::string &name, gdouble value);
67
68 void RemoveEntry(std::string &section, std::string &value);
69
70 ConfigDB(void);
71 ~ConfigDB(void);
72 };
73 };
74
75 #endif