diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2010-05-23 10:25:47 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-05-23 10:25:47 (GMT) |
commit | fbcdd34b223174a28ff712b7d03e56339fa2fe07 (patch) | |
tree | da036effaeeb5ba7788f4b0403151aa864e9d16d /src/Resources.cc | |
parent | ff9c68e247704bd1522ea7a2055b7fa4b2b0c568 (diff) | |
download | fluxbox_pavel-fbcdd34b223174a28ff712b7d03e56339fa2fe07.zip fluxbox_pavel-fbcdd34b223174a28ff712b7d03e56339fa2fe07.tar.bz2 |
mostly cosmetic fixes, mainly discovered by 'clang --analyze'
reordering of Resource-related stuff was because of
"error: explicit specialization of 'getString' after instantiation"
complaints.
Diffstat (limited to 'src/Resources.cc')
-rw-r--r-- | src/Resources.cc | 151 |
1 files changed, 76 insertions, 75 deletions
diff --git a/src/Resources.cc b/src/Resources.cc index 60c7461..734cd75 100644 --- a/src/Resources.cc +++ b/src/Resources.cc | |||
@@ -49,6 +49,14 @@ using namespace FbTk; | |||
49 | namespace FbTk { | 49 | namespace FbTk { |
50 | 50 | ||
51 | template<> | 51 | template<> |
52 | string FbTk::Resource<int>:: | ||
53 | getString() const { | ||
54 | char strval[256]; | ||
55 | sprintf(strval, "%d", **this); | ||
56 | return string(strval); | ||
57 | } | ||
58 | |||
59 | template<> | ||
52 | void FbTk::Resource<int>:: | 60 | void FbTk::Resource<int>:: |
53 | setFromString(const char* strval) { | 61 | setFromString(const char* strval) { |
54 | int val; | 62 | int val; |
@@ -57,70 +65,16 @@ setFromString(const char* strval) { | |||
57 | } | 65 | } |
58 | 66 | ||
59 | template<> | 67 | template<> |
60 | void FbTk::Resource<string>:: | 68 | string FbTk::Resource<string>:: |
61 | setFromString(const char *strval) { | 69 | getString() const { return **this; } |
62 | *this = strval; | ||
63 | } | ||
64 | |||
65 | template<> | ||
66 | void FbTk::Resource<bool>:: | ||
67 | setFromString(char const *strval) { | ||
68 | *this = (bool)!strcasecmp(strval, "true"); | ||
69 | } | ||
70 | |||
71 | template<> | ||
72 | void FbTk::Resource<vector<WinButton::Type> >:: | ||
73 | setFromString(char const *strval) { | ||
74 | vector<string> val; | ||
75 | StringUtil::stringtok(val, strval); | ||
76 | //clear old values | ||
77 | m_value.clear(); | ||
78 | |||
79 | std::string v; | ||
80 | for (size_t i = 0; i < val.size(); i++) { | ||
81 | v = FbTk::StringUtil::toLower(val[i]); | ||
82 | if (v == "maximize") | ||
83 | m_value.push_back(WinButton::MAXIMIZE); | ||
84 | else if (v == "minimize") | ||
85 | m_value.push_back(WinButton::MINIMIZE); | ||
86 | else if (v == "shade") | ||
87 | m_value.push_back(WinButton::SHADE); | ||
88 | else if (v == "stick") | ||
89 | m_value.push_back(WinButton::STICK); | ||
90 | else if (v == "menuIcon") | ||
91 | m_value.push_back(WinButton::MENUICON); | ||
92 | else if (v == "close") | ||
93 | m_value.push_back(WinButton::CLOSE); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | template<> | ||
98 | void FbTk::Resource<Fluxbox::TabsAttachArea>:: | ||
99 | setFromString(char const *strval) { | ||
100 | if (strcasecmp(strval, "Titlebar")==0) | ||
101 | m_value= Fluxbox::ATTACH_AREA_TITLEBAR; | ||
102 | else | ||
103 | m_value= Fluxbox::ATTACH_AREA_WINDOW; | ||
104 | } | ||
105 | |||
106 | template<> | ||
107 | void FbTk::Resource<unsigned int>:: | ||
108 | setFromString(const char *strval) { | ||
109 | if (sscanf(strval, "%ul", &m_value) != 1) | ||
110 | setDefaultValue(); | ||
111 | } | ||
112 | 70 | ||
113 | template<> | 71 | template<> |
114 | void FbTk::Resource<long long>:: | 72 | void FbTk::Resource<string>:: |
115 | setFromString(const char *strval) { | 73 | setFromString(const char *strval) { |
116 | if (sscanf(strval, "%lld", &m_value) != 1) | 74 | *this = strval; |
117 | setDefaultValue(); | ||
118 | } | 75 | } |
119 | 76 | ||
120 | 77 | ||
121 | //----------------------------------------------------------------- | ||
122 | //---- manipulators for int, bool, and some enums with Resource --- | ||
123 | //----------------------------------------------------------------- | ||
124 | template<> | 78 | template<> |
125 | string FbTk::Resource<bool>:: | 79 | string FbTk::Resource<bool>:: |
126 | getString() const { | 80 | getString() const { |
@@ -128,17 +82,11 @@ getString() const { | |||
128 | } | 82 | } |
129 | 83 | ||
130 | template<> | 84 | template<> |
131 | string FbTk::Resource<int>:: | 85 | void FbTk::Resource<bool>:: |
132 | getString() const { | 86 | setFromString(char const *strval) { |
133 | char strval[256]; | 87 | *this = (bool)!strcasecmp(strval, "true"); |
134 | sprintf(strval, "%d", **this); | ||
135 | return string(strval); | ||
136 | } | 88 | } |
137 | 89 | ||
138 | template<> | ||
139 | string FbTk::Resource<string>:: | ||
140 | getString() const { return **this; } | ||
141 | |||
142 | 90 | ||
143 | template<> | 91 | template<> |
144 | string FbTk::Resource<vector<WinButton::Type> >:: | 92 | string FbTk::Resource<vector<WinButton::Type> >:: |
@@ -173,6 +121,34 @@ getString() const { | |||
173 | return retval; | 121 | return retval; |
174 | } | 122 | } |
175 | 123 | ||
124 | |||
125 | |||
126 | template<> | ||
127 | void FbTk::Resource<vector<WinButton::Type> >:: | ||
128 | setFromString(char const *strval) { | ||
129 | vector<string> val; | ||
130 | StringUtil::stringtok(val, strval); | ||
131 | //clear old values | ||
132 | m_value.clear(); | ||
133 | |||
134 | std::string v; | ||
135 | for (size_t i = 0; i < val.size(); i++) { | ||
136 | v = FbTk::StringUtil::toLower(val[i]); | ||
137 | if (v == "maximize") | ||
138 | m_value.push_back(WinButton::MAXIMIZE); | ||
139 | else if (v == "minimize") | ||
140 | m_value.push_back(WinButton::MINIMIZE); | ||
141 | else if (v == "shade") | ||
142 | m_value.push_back(WinButton::SHADE); | ||
143 | else if (v == "stick") | ||
144 | m_value.push_back(WinButton::STICK); | ||
145 | else if (v == "menuIcon") | ||
146 | m_value.push_back(WinButton::MENUICON); | ||
147 | else if (v == "close") | ||
148 | m_value.push_back(WinButton::CLOSE); | ||
149 | } | ||
150 | } | ||
151 | |||
176 | template<> | 152 | template<> |
177 | string FbTk::Resource<Fluxbox::TabsAttachArea>:: | 153 | string FbTk::Resource<Fluxbox::TabsAttachArea>:: |
178 | getString() const { | 154 | getString() const { |
@@ -183,6 +159,15 @@ getString() const { | |||
183 | } | 159 | } |
184 | 160 | ||
185 | template<> | 161 | template<> |
162 | void FbTk::Resource<Fluxbox::TabsAttachArea>:: | ||
163 | setFromString(char const *strval) { | ||
164 | if (strcasecmp(strval, "Titlebar")==0) | ||
165 | m_value= Fluxbox::ATTACH_AREA_TITLEBAR; | ||
166 | else | ||
167 | m_value= Fluxbox::ATTACH_AREA_WINDOW; | ||
168 | } | ||
169 | |||
170 | template<> | ||
186 | string FbTk::Resource<unsigned int>:: | 171 | string FbTk::Resource<unsigned int>:: |
187 | getString() const { | 172 | getString() const { |
188 | char tmpstr[128]; | 173 | char tmpstr[128]; |
@@ -191,6 +176,14 @@ getString() const { | |||
191 | } | 176 | } |
192 | 177 | ||
193 | template<> | 178 | template<> |
179 | void FbTk::Resource<unsigned int>:: | ||
180 | setFromString(const char *strval) { | ||
181 | if (sscanf(strval, "%ul", &m_value) != 1) | ||
182 | setDefaultValue(); | ||
183 | } | ||
184 | |||
185 | |||
186 | template<> | ||
194 | string FbTk::Resource<long long>:: | 187 | string FbTk::Resource<long long>:: |
195 | getString() const { | 188 | getString() const { |
196 | char tmpstr[128]; | 189 | char tmpstr[128]; |
@@ -199,13 +192,9 @@ getString() const { | |||
199 | } | 192 | } |
200 | 193 | ||
201 | template<> | 194 | template<> |
202 | void FbTk::Resource<Layer>:: | 195 | void FbTk::Resource<long long>:: |
203 | setFromString(const char *strval) { | 196 | setFromString(const char *strval) { |
204 | string str(strval); | 197 | if (sscanf(strval, "%lld", &m_value) != 1) |
205 | int tempnum = ::Layer::getNumFromString(str); | ||
206 | if (tempnum >= 0 && tempnum < ::Layer::NUM_LAYERS) | ||
207 | m_value = tempnum; | ||
208 | else | ||
209 | setDefaultValue(); | 198 | setDefaultValue(); |
210 | } | 199 | } |
211 | 200 | ||
@@ -217,9 +206,13 @@ getString() const { | |||
217 | } | 206 | } |
218 | 207 | ||
219 | template<> | 208 | template<> |
220 | void FbTk::Resource<long>:: | 209 | void FbTk::Resource<Layer>:: |
221 | setFromString(const char *strval) { | 210 | setFromString(const char *strval) { |
222 | if (sscanf(strval, "%ld", &m_value) != 1) | 211 | string str(strval); |
212 | int tempnum = ::Layer::getNumFromString(str); | ||
213 | if (tempnum >= 0 && tempnum < ::Layer::NUM_LAYERS) | ||
214 | m_value = tempnum; | ||
215 | else | ||
223 | setDefaultValue(); | 216 | setDefaultValue(); |
224 | } | 217 | } |
225 | 218 | ||
@@ -230,4 +223,12 @@ getString() const { | |||
230 | sprintf(tmpstr, "%ld", m_value); | 223 | sprintf(tmpstr, "%ld", m_value); |
231 | return string(tmpstr); | 224 | return string(tmpstr); |
232 | } | 225 | } |
226 | |||
227 | template<> | ||
228 | void FbTk::Resource<long>:: | ||
229 | setFromString(const char *strval) { | ||
230 | if (sscanf(strval, "%ld", &m_value) != 1) | ||
231 | setDefaultValue(); | ||
232 | } | ||
233 | |||
233 | } // end namespace FbTk | 234 | } // end namespace FbTk |