diff options
Diffstat (limited to 'src/Resources.cc')
-rw-r--r-- | src/Resources.cc | 28 |
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 { | |||
51 | template<> | 51 | template<> |
52 | string FbTk::Resource<int>:: | 52 | string FbTk::Resource<int>:: |
53 | getString() const { | 53 | getString() const { |
54 | char strval[256]; | 54 | return FbTk::StringUtil::number2String(**this); |
55 | sprintf(strval, "%d", **this); | ||
56 | return string(strval); | ||
57 | } | 55 | } |
58 | 56 | ||
59 | template<> | 57 | template<> |
60 | void FbTk::Resource<int>:: | 58 | void FbTk::Resource<int>:: |
61 | setFromString(const char* strval) { | 59 | setFromString(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 | ||
67 | template<> | 63 | template<> |
@@ -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) { | |||
170 | template<> | 166 | template<> |
171 | string FbTk::Resource<unsigned int>:: | 167 | string FbTk::Resource<unsigned int>:: |
172 | getString() const { | 168 | getString() 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 | ||
178 | template<> | 172 | template<> |
179 | void FbTk::Resource<unsigned int>:: | 173 | void FbTk::Resource<unsigned int>:: |
180 | setFromString(const char *strval) { | 174 | setFromString(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) { | |||
186 | template<> | 180 | template<> |
187 | string FbTk::Resource<long long>:: | 181 | string FbTk::Resource<long long>:: |
188 | getString() const { | 182 | getString() 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 | ||
194 | template<> | 186 | template<> |
195 | void FbTk::Resource<long long>:: | 187 | void FbTk::Resource<long long>:: |
196 | setFromString(const char *strval) { | 188 | setFromString(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) { | |||
219 | template<> | 211 | template<> |
220 | string FbTk::Resource<long>:: | 212 | string FbTk::Resource<long>:: |
221 | getString() const { | 213 | getString() 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 | ||
227 | template<> | 217 | template<> |
228 | void FbTk::Resource<long>:: | 218 | void FbTk::Resource<long>:: |
229 | setFromString(const char *strval) { | 219 | setFromString(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 | ||