Mercurial > audlegacy
annotate src/libaudacious++/configdb.cxx @ 2639:ed67025aeea5 trunk
[svn] - give focus to jump_to_track window before filling it with information; this way user can start typing while huge playlists are loaded
author | giacomo |
---|---|
date | Wed, 21 Mar 2007 13:47:48 -0700 |
parents | 0b98ad8c8b17 |
children |
rev | line source |
---|---|
2313 | 1 #include "configdb.hh" |
2 | |
3 using namespace Audacious; | |
4 | |
5 ConfValue::~ConfValue(void) | |
6 { | |
7 // make sure we don't leak any string data | |
8 if (this->strval != NULL) | |
9 g_free(this->strval); | |
10 } | |
11 | |
12 std::string ConfValue::asString(void) | |
13 { | |
14 return this->strval; | |
15 } | |
16 | |
17 gint ConfValue::asInt(void) | |
18 { | |
19 return this->intval; | |
20 } | |
21 | |
22 bool ConfValue::asBool(void) | |
23 { | |
24 return this->boolval; | |
25 } | |
26 | |
27 gfloat ConfValue::asFloat(void) | |
28 { | |
29 return this->floatval; | |
30 } | |
31 | |
32 gdouble ConfValue::asDouble(void) | |
33 { | |
34 return this->dblval; | |
35 } | |
36 | |
37 // ************************************************************************* | |
38 | |
39 ConfigDB::ConfigDB(void) | |
40 { | |
41 this->db = bmp_cfg_db_open(); | |
42 } | |
43 | |
44 ConfigDB::~ConfigDB(void) | |
45 { | |
46 bmp_cfg_db_close(this->db); | |
47 } | |
48 | |
49 ConfValue *ConfigDB::GetValue(std::string §ion, std::string &value, ConfigDB::ValueType type) | |
50 { | |
51 ConfValue *val = new ConfValue; | |
52 | |
53 switch(type) | |
54 { | |
55 case String: | |
56 bmp_cfg_db_get_string(this->db, section.c_str(), value.c_str(), &val->strval); | |
57 break; | |
58 | |
59 case Int: | |
60 bmp_cfg_db_get_int(this->db, section.c_str(), value.c_str(), &val->intval); | |
61 break; | |
62 | |
63 case Bool: | |
64 gboolean tmp; | |
65 | |
66 bmp_cfg_db_get_bool(this->db, section.c_str(), value.c_str(), &tmp); | |
67 | |
68 if (tmp != 0) | |
69 val->boolval = true; | |
70 else | |
71 val->boolval = false; | |
72 | |
73 break; | |
74 | |
75 case Float: | |
76 bmp_cfg_db_get_float(this->db, section.c_str(), value.c_str(), &val->floatval); | |
77 break; | |
78 | |
79 case Double: | |
80 bmp_cfg_db_get_double(this->db, section.c_str(), value.c_str(), &val->dblval); | |
81 break; | |
82 | |
83 default: | |
84 g_warning("Unknown value passed to Audacious::ConfigDB::GetValue!"); | |
85 break; | |
86 } | |
87 | |
88 return val; | |
89 } | |
90 | |
91 void ConfigDB::SetValue(std::string §ion, std::string &name, std::string &value) | |
92 { | |
2346
0b98ad8c8b17
[svn] removed xmms_create_dirbrowser, small config db fixes
mf0102
parents:
2313
diff
changeset
|
93 bmp_cfg_db_set_string(this->db, section.c_str(), name.c_str(), value.c_str()); |
2313 | 94 } |
95 | |
96 void ConfigDB::SetValue(std::string §ion, std::string &name, gint value) | |
97 { | |
98 bmp_cfg_db_set_int(this->db, section.c_str(), name.c_str(), value); | |
99 } | |
100 | |
101 void ConfigDB::SetValue(std::string §ion, std::string &name, bool value) | |
102 { | |
103 bmp_cfg_db_set_bool(this->db, section.c_str(), name.c_str(), value); | |
104 } | |
105 | |
106 void ConfigDB::SetValue(std::string §ion, std::string &name, gfloat value) | |
107 { | |
108 bmp_cfg_db_set_float(this->db, section.c_str(), name.c_str(), value); | |
109 } | |
110 | |
111 void ConfigDB::SetValue(std::string §ion, std::string &name, gdouble value) | |
112 { | |
113 bmp_cfg_db_set_double(this->db, section.c_str(), name.c_str(), value); | |
114 } |