aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
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/FbTk
parent041d586972db4da170123f5468d7b11d4eda8ae5 (diff)
downloadfluxbox_paul-603b36a2ccfb6f825dff7259c4d5397c896cc08e.zip
fluxbox_paul-603b36a2ccfb6f825dff7259c4d5397c896cc08e.tar.bz2
use FbTk::API to reduce code duplication
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/StringUtil.cc22
-rw-r--r--src/FbTk/StringUtil.hh6
2 files changed, 25 insertions, 3 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc
index 182233b..0a7ebd3 100644
--- a/src/FbTk/StringUtil.cc
+++ b/src/FbTk/StringUtil.cc
@@ -123,9 +123,27 @@ int extractNumber(const std::string& in, unsigned int& out) {
123 return ::extractUnsignedNumber<unsigned int>(in, out); 123 return ::extractUnsignedNumber<unsigned int>(in, out);
124} 124}
125 125
126std::string number2String(int num) { 126int extractNumber(const std::string& in, long& out) {
127 return ::extractSignedNumber<long>(in, out);
128}
129
130int extractNumber(const std::string& in, unsigned long& out) {
131 return ::extractUnsignedNumber<unsigned long>(in, out);
132}
133
134int extractNumber(const std::string& in, long long& out) {
135 return ::extractSignedNumber<long long>(in, out);
136}
137
138int extractNumber(const std::string& in, unsigned long long& out) {
139 return ::extractUnsignedNumber<unsigned long long>(in, out);
140}
141
142
143
144std::string number2String(long long num) {
127 char s[128]; 145 char s[128];
128 sprintf(s, "%d", num); 146 sprintf(s, "%lld", num);
129 return std::string(s); 147 return std::string(s);
130} 148}
131 149
diff --git a/src/FbTk/StringUtil.hh b/src/FbTk/StringUtil.hh
index a16e709..9e45460 100644
--- a/src/FbTk/StringUtil.hh
+++ b/src/FbTk/StringUtil.hh
@@ -36,10 +36,14 @@ namespace StringUtil {
36/// @return 1 - ok, result stored in 'out' 36/// @return 1 - ok, result stored in 'out'
37int extractNumber(const std::string& in, unsigned int& out); 37int extractNumber(const std::string& in, unsigned int& out);
38int extractNumber(const std::string& in, int& out); 38int extractNumber(const std::string& in, int& out);
39int extractNumber(const std::string& in, unsigned long& out);
40int extractNumber(const std::string& in, long& out);
41int extractNumber(const std::string& in, long long& out);
42int extractNumber(const std::string& in, unsigned long& out);
39/// \@} 43/// \@}
40 44
41/// creates a number to a string 45/// creates a number to a string
42std::string number2String(int num); 46std::string number2String(long long num);
43 47
44/// Similar to `strstr' but this function ignores the case of both strings 48/// Similar to `strstr' but this function ignores the case of both strings
45const char *strcasestr(const char *str, const char *ptn); 49const char *strcasestr(const char *str, const char *ptn);