Rev 1310 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1310 | Rev 1311 | ||
|---|---|---|---|
| Line 248... | Line 248... | ||
| 248 | string uint2hex(unsigned int num, unsigned int length) |
248 | string uint2hex(unsigned int num, unsigned int length) |
| 249 | { |
249 | { |
| 250 | return bin2hex(uint2bin(num, length)); |
250 | return bin2hex(uint2bin(num, length)); |
| 251 | } |
251 | } |
| 252 | 252 | ||
| 253 |
|
253 | string_list explode(string delimiter, string str) |
| 254 | { |
254 | { |
| 255 |
|
255 | string_list parts; |
| 256 | string::size_type startPos = 0; |
256 | string::size_type startPos = 0; |
| 257 | string::size_type endPos = 0; |
257 | string::size_type endPos = 0; |
| 258 | 258 | ||
| 259 | while ((endPos = str.find(delimiter, startPos)) != string::npos) |
259 | while ((endPos = str.find(delimiter, startPos)) != string::npos) |
| 260 | { |
260 | { |
| Line 303... | Line 303... | ||
| 303 | for (unsigned int n = 0; n < s.size(); n++) |
303 | for (unsigned int n = 0; n < s.size(); n++) |
| 304 | s[n] = (char)tolower(s[n]); |
304 | s[n] = (char)tolower(s[n]); |
| 305 | 305 | ||
| 306 | return s; |
306 | return s; |
| 307 | } |
307 | } |
| 308 | 308 | /* |
|
| 309 | string trim(string s) |
309 | string trim(string s) |
| 310 | { |
310 | { |
| 311 | return trim(s, ' '); |
311 | return trim(s, ' '); |
| 312 | } |
312 | } |
| 313 | 313 | ||
| 314 | string trim(const string s, char c) |
314 | string trim(const string s, char c) |
| 315 | { |
315 | { |
| 316 | string result = s; |
316 | string result = s; |
| 317 | while (result[0] == c) |
317 | while (result[0] == c) |
| 318 | result.erase(0, 1); |
318 | result.erase(0, 1); |
| 319 | 319 | ||
| 320 | while (result[result.length() - 1] == c) |
320 | while (result[result.length() - 1] == c) |
| 321 | result.erase(result.length() - 1, 1); |
321 | result.erase(result.length() - 1, 1); |
| 322 | 322 | ||
| 323 | return result; |
323 | return result; |
| 324 | } |
324 | } |
| 325 | 325 | */ |
|
| 326 | bool stob(const string s) |
326 | bool stob(const string s) |
| 327 | { |
327 | { |
| 328 | return (s == "true" || s == "1" || s == "yes"); |
328 | return (s == "true" || s == "1" || s == "yes"); |
| 329 | } |
329 | } |
| 330 | 330 | ||