aboutsummaryrefslogtreecommitdiff
path: root/src/Resources.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-17 12:46:01 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-17 12:46:01 (GMT)
commit603b36a2ccfb6f825dff7259c4d5397c896cc08e (patch)
tree2f720700b903f95cef1bda6fff45a4d35d563886 /src/Resources.cc
parent041d586972db4da170123f5468d7b11d4eda8ae5 (diff)
downloadfluxbox_pavel-603b36a2ccfb6f825dff7259c4d5397c896cc08e.zip
fluxbox_pavel-603b36a2ccfb6f825dff7259c4d5397c896cc08e.tar.bz2
use FbTk::API to reduce code duplication
Diffstat (limited to 'src/Resources.cc')
-rw-r--r--src/Resources.cc28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/Resources.cc b/src/Resources.cc
index 734cd75..0364477 100644
--- a/src/Resources.cc
+++ b/src/Resources.cc
@@ -51,17 +51,13 @@ namespace FbTk {
51template<> 51template<>
52string FbTk::Resource<int>:: 52string FbTk::Resource<int>::
53getString() const { 53getString() const {
54 char strval[256]; 54 return FbTk::StringUtil::number2String(**this);
55 sprintf(strval, "%d", **this);
56 return string(strval);
57} 55}
58 56
59template<> 57template<>
60void FbTk::Resource<int>:: 58void FbTk::Resource<int>::
61setFromString(const char* strval) { 59setFromString(const char* strval) {
62 int val; 60 FbTk::StringUtil::extractNumber(strval, get());
63 if (sscanf(strval, "%d", &val)==1)
64 *this = val;
65} 61}
66 62
67template<> 63template<>
@@ -142,7 +138,7 @@ setFromString(char const *strval) {
142 m_value.push_back(WinButton::SHADE); 138 m_value.push_back(WinButton::SHADE);
143 else if (v == "stick") 139 else if (v == "stick")
144 m_value.push_back(WinButton::STICK); 140 m_value.push_back(WinButton::STICK);
145 else if (v == "menuIcon") 141 else if (v == "menuicon")
146 m_value.push_back(WinButton::MENUICON); 142 m_value.push_back(WinButton::MENUICON);
147 else if (v == "close") 143 else if (v == "close")
148 m_value.push_back(WinButton::CLOSE); 144 m_value.push_back(WinButton::CLOSE);
@@ -170,15 +166,13 @@ setFromString(char const *strval) {
170template<> 166template<>
171string FbTk::Resource<unsigned int>:: 167string FbTk::Resource<unsigned int>::
172getString() const { 168getString() const {
173 char tmpstr[128]; 169 return FbTk::StringUtil::number2String(m_value);
174 sprintf(tmpstr, "%ul", m_value);
175 return string(tmpstr);
176} 170}
177 171
178template<> 172template<>
179void FbTk::Resource<unsigned int>:: 173void FbTk::Resource<unsigned int>::
180setFromString(const char *strval) { 174setFromString(const char *strval) {
181 if (sscanf(strval, "%ul", &m_value) != 1) 175 if (!FbTk::StringUtil::extractNumber(strval, m_value))
182 setDefaultValue(); 176 setDefaultValue();
183} 177}
184 178
@@ -186,15 +180,13 @@ setFromString(const char *strval) {
186template<> 180template<>
187string FbTk::Resource<long long>:: 181string FbTk::Resource<long long>::
188getString() const { 182getString() const {
189 char tmpstr[128]; 183 return FbTk::StringUtil::number2String(m_value);
190 sprintf(tmpstr, "%llu", (unsigned long long) m_value);
191 return string(tmpstr);
192} 184}
193 185
194template<> 186template<>
195void FbTk::Resource<long long>:: 187void FbTk::Resource<long long>::
196setFromString(const char *strval) { 188setFromString(const char *strval) {
197 if (sscanf(strval, "%lld", &m_value) != 1) 189 if (!FbTk::StringUtil::extractNumber(strval, m_value))
198 setDefaultValue(); 190 setDefaultValue();
199} 191}
200 192
@@ -219,15 +211,13 @@ setFromString(const char *strval) {
219template<> 211template<>
220string FbTk::Resource<long>:: 212string FbTk::Resource<long>::
221getString() const { 213getString() const {
222 char tmpstr[128]; 214 return FbTk::StringUtil::number2String(m_value);
223 sprintf(tmpstr, "%ld", m_value);
224 return string(tmpstr);
225} 215}
226 216
227template<> 217template<>
228void FbTk::Resource<long>:: 218void FbTk::Resource<long>::
229setFromString(const char *strval) { 219setFromString(const char *strval) {
230 if (sscanf(strval, "%ld", &m_value) != 1) 220 if (!FbTk::StringUtil::extractNumber(strval, m_value))
231 setDefaultValue(); 221 setDefaultValue();
232} 222}
233 223