aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Resource.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-27 06:57:43 (GMT)
committermathias <mathias>2006-10-27 06:57:43 (GMT)
commit10082d821d6691f42a8d8ad6fa2e42e5b3f44edd (patch)
tree99c94a6105cf35612307e307be343eda2aea8baf /src/FbTk/Resource.cc
parent34b7f7ddfc3e914238fd0d30ff50c4f37c2a6dd8 (diff)
downloadfluxbox-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.zip
fluxbox-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.tar.bz2
cosmetic patch from slava semushin, removes whitespaces and
uses only those things from "namespace std" what we really need.
Diffstat (limited to 'src/FbTk/Resource.cc')
-rw-r--r--src/FbTk/Resource.cc34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc
index d8e781d..5d2dc3b 100644
--- a/src/FbTk/Resource.cc
+++ b/src/FbTk/Resource.cc
@@ -32,7 +32,9 @@
32 #include <assert.h> 32 #include <assert.h>
33#endif 33#endif
34 34
35using namespace std; 35using std::cerr;
36using std::endl;
37using std::string;
36 38
37namespace FbTk { 39namespace FbTk {
38 40
@@ -55,7 +57,7 @@ ResourceManager::~ResourceManager() {
55bool ResourceManager::m_init = false; 57bool ResourceManager::m_init = false;
56 58
57/** 59/**
58 reloads all resources from resourcefile 60 reloads all resources from resourcefile
59 @return true on success else false 61 @return true on success else false
60*/ 62*/
61bool ResourceManager::load(const char *filename) { 63bool ResourceManager::load(const char *filename) {
@@ -72,18 +74,18 @@ bool ResourceManager::load(const char *filename) {
72 unlock(); 74 unlock();
73 return false; 75 return false;
74 } 76 }
75 77
76 XrmValue value; 78 XrmValue value;
77 char *value_type; 79 char *value_type;
78 80
79 //get list and go throu all the resources and load them 81 //get list and go throu all the resources and load them
80 ResourceList::iterator i = m_resourcelist.begin(); 82 ResourceList::iterator i = m_resourcelist.begin();
81 ResourceList::iterator i_end = m_resourcelist.end(); 83 ResourceList::iterator i_end = m_resourcelist.end();
82 for (; i != i_end; ++i) { 84 for (; i != i_end; ++i) {
83 85
84 Resource_base *resource = *i; 86 Resource_base *resource = *i;
85 if (XrmGetResource(**m_database, resource->name().c_str(), 87 if (XrmGetResource(**m_database, resource->name().c_str(),
86 resource->altName().c_str(), &value_type, &value)) 88 resource->altName().c_str(), &value_type, &value))
87 resource->setFromString(value.addr); 89 resource->setFromString(value.addr);
88 else { 90 else {
89 _FB_USES_NLS; 91 _FB_USES_NLS;
@@ -104,11 +106,11 @@ bool ResourceManager::load(const char *filename) {
104*/ 106*/
105bool ResourceManager::save(const char *filename, const char *mergefilename) { 107bool ResourceManager::save(const char *filename, const char *mergefilename) {
106 assert(filename); 108 assert(filename);
107 109
108 // empty database 110 // empty database
109 XrmDatabaseHelper database; 111 XrmDatabaseHelper database;
110 112
111 string rc_string; 113 string rc_string;
112 ResourceList::iterator i = m_resourcelist.begin(); 114 ResourceList::iterator i = m_resourcelist.begin();
113 ResourceList::iterator i_end = m_resourcelist.end(); 115 ResourceList::iterator i_end = m_resourcelist.end();
114 //write all resources to database 116 //write all resources to database
@@ -125,7 +127,7 @@ bool ResourceManager::save(const char *filename, const char *mergefilename) {
125 if (mergefilename) { 127 if (mergefilename) {
126 // force reload of file 128 // force reload of file
127 m_filename = mergefilename; 129 m_filename = mergefilename;
128 if (m_database) 130 if (m_database)
129 delete m_database; 131 delete m_database;
130 m_database = 0; 132 m_database = 0;
131 133
@@ -149,31 +151,31 @@ bool ResourceManager::save(const char *filename, const char *mergefilename) {
149 return true; 151 return true;
150} 152}
151 153
152Resource_base *ResourceManager::findResource(const std::string &resname) { 154Resource_base *ResourceManager::findResource(const string &resname) {
153 // find resource name 155 // find resource name
154 ResourceList::iterator i = m_resourcelist.begin(); 156 ResourceList::iterator i = m_resourcelist.begin();
155 ResourceList::iterator i_end = m_resourcelist.end(); 157 ResourceList::iterator i_end = m_resourcelist.end();
156 for (; i != i_end; ++i) { 158 for (; i != i_end; ++i) {
157 if ((*i)->name() == resname || 159 if ((*i)->name() == resname ||
158 (*i)->altName() == resname) 160 (*i)->altName() == resname)
159 return *i; 161 return *i;
160 } 162 }
161 return 0; 163 return 0;
162} 164}
163 165
164const Resource_base *ResourceManager::findResource(const std::string &resname) const { 166const Resource_base *ResourceManager::findResource(const string &resname) const {
165 // find resource name 167 // find resource name
166 ResourceList::const_iterator i = m_resourcelist.begin(); 168 ResourceList::const_iterator i = m_resourcelist.begin();
167 ResourceList::const_iterator i_end = m_resourcelist.end(); 169 ResourceList::const_iterator i_end = m_resourcelist.end();
168 for (; i != i_end; ++i) { 170 for (; i != i_end; ++i) {
169 if ((*i)->name() == resname || 171 if ((*i)->name() == resname ||
170 (*i)->altName() == resname) 172 (*i)->altName() == resname)
171 return *i; 173 return *i;
172 } 174 }
173 return 0; 175 return 0;
174} 176}
175 177
176string ResourceManager::resourceValue(const std::string &resname) const { 178string ResourceManager::resourceValue(const string &resname) const {
177 const Resource_base *res = findResource(resname); 179 const Resource_base *res = findResource(resname);
178 if (res != 0) 180 if (res != 0)
179 return res->getString(); 181 return res->getString();
@@ -181,7 +183,7 @@ string ResourceManager::resourceValue(const std::string &resname) const {
181 return ""; 183 return "";
182} 184}
183 185
184void ResourceManager::setResourceValue(const std::string &resname, const std::string &value) { 186void ResourceManager::setResourceValue(const string &resname, const string &value) {
185 Resource_base *res = findResource(resname); 187 Resource_base *res = findResource(resname);
186 if (res != 0) 188 if (res != 0)
187 res->setFromString(value.c_str()); 189 res->setFromString(value.c_str());