Mercurial > audlegacy
annotate libaudacious++/configdb.cxx @ 2270:50dea14e2fa3 trunk
[svn] Serbian language upadated
author | kustodian |
---|---|
date | Thu, 04 Jan 2007 14:55:34 -0800 |
parents | 36d4043b3df2 |
children |
rev | line source |
---|---|
2118
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
1 #include "configdb.hh" |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
2 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
3 using namespace Audacious; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
4 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
5 ConfValue::~ConfValue(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
6 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
7 // make sure we don't leak any string data |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
8 if (this->strval != NULL) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
9 g_free(this->strval); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
10 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
11 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
12 std::string ConfValue::asString(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
13 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
14 return this->strval; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
15 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
16 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
17 gint ConfValue::asInt(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
18 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
19 return this->intval; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
20 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
21 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
22 bool ConfValue::asBool(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
23 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
24 return this->boolval; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
25 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
26 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
27 gfloat ConfValue::asFloat(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
28 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
29 return this->floatval; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
30 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
31 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
32 gdouble ConfValue::asDouble(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
33 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
34 return this->dblval; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
35 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
36 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
37 // ************************************************************************* |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
38 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
39 ConfigDB::ConfigDB(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
40 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
41 this->db = bmp_cfg_db_open(); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
42 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
43 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
44 ConfigDB::~ConfigDB(void) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
45 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
46 bmp_cfg_db_close(this->db); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
47 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
48 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
49 ConfValue *ConfigDB::GetValue(std::string §ion, std::string &value, ConfigDB::ValueType type) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
50 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
51 ConfValue *val = new ConfValue; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
52 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
53 switch(type) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
54 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
55 case String: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
56 bmp_cfg_db_get_string(this->db, section.c_str(), value.c_str(), &val->strval); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
57 break; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
58 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
59 case Int: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
60 bmp_cfg_db_get_int(this->db, section.c_str(), value.c_str(), &val->intval); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
61 break; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
62 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
63 case Bool: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
64 gboolean tmp; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
65 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
66 bmp_cfg_db_get_bool(this->db, section.c_str(), value.c_str(), &tmp); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
67 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
68 if (tmp != 0) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
69 val->boolval = true; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
70 else |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
71 val->boolval = false; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
72 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
73 break; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
74 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
75 case Float: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
76 bmp_cfg_db_get_float(this->db, section.c_str(), value.c_str(), &val->floatval); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
77 break; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
78 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
79 case Double: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
80 bmp_cfg_db_get_double(this->db, section.c_str(), value.c_str(), &val->dblval); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
81 break; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
82 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
83 default: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
84 g_warning("Unknown value passed to Audacious::ConfigDB::GetValue!"); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
85 break; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
86 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
87 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
88 return val; |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
89 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
90 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
91 void ConfigDB::SetValue(std::string §ion, std::string &name, std::string &value) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
92 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
93 // XXX bmp_cfg_db_set_string should be const char |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
94 // because it's not, we have to do this: |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
95 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
96 gchar *foo = g_strdup(value.c_str()); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
97 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
98 bmp_cfg_db_set_string(this->db, section.c_str(), name.c_str(), foo); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
99 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
100 g_free(foo); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
101 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
102 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
103 void ConfigDB::SetValue(std::string §ion, std::string &name, gint value) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
104 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
105 bmp_cfg_db_set_int(this->db, section.c_str(), name.c_str(), value); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
106 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
107 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
108 void ConfigDB::SetValue(std::string §ion, std::string &name, bool value) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
109 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
110 bmp_cfg_db_set_bool(this->db, section.c_str(), name.c_str(), value); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
111 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
112 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
113 void ConfigDB::SetValue(std::string §ion, std::string &name, gfloat value) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
114 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
115 bmp_cfg_db_set_float(this->db, section.c_str(), name.c_str(), value); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
116 } |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
117 |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
118 void ConfigDB::SetValue(std::string §ion, std::string &name, gdouble value) |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
119 { |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
120 bmp_cfg_db_set_double(this->db, section.c_str(), name.c_str(), value); |
36d4043b3df2
[svn] - add the starting point of some audacious C++ bindings
nenolod
parents:
diff
changeset
|
121 } |