1 |
torben |
26 |
#ifndef __UTIL_H__ |
2 |
|
|
#define __UTIL_H__ |
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include <string> |
6 |
|
|
#include <vector> |
7 |
|
|
#include <cctype> |
8 |
|
|
|
9 |
|
|
struct timeval; |
10 |
|
|
|
11 |
|
|
namespace Util |
12 |
|
|
{ |
13 |
|
|
std::vector<std::string> str_split(std::string input, std::string delimiter); |
14 |
|
|
void str_dump(const std::string& str); |
15 |
|
|
void str_clean(std::string* str, std::string search, std::string replace = ""); |
16 |
|
|
|
17 |
|
|
std::string readUrl(std::string url, std::string tempfile); |
18 |
|
|
|
19 |
|
|
std::string convertToUnicode(std::string); |
20 |
|
|
|
21 |
|
|
int uTimeDiff(const timeval& then, const timeval& now); |
22 |
|
|
int mTimeDiff(const timeval& then, const timeval& now); |
23 |
|
|
|
24 |
|
|
inline void Sleep(unsigned int msec) |
25 |
|
|
{ |
26 |
|
|
for (unsigned int i=0; i<msec; ++i) |
27 |
|
|
usleep(1000); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
inline std::string str_tolower(std::string str) |
31 |
|
|
{ |
32 |
|
|
for(unsigned int i=0; i<str.size();++i) |
33 |
|
|
str[i] = tolower(str[i]); |
34 |
|
|
return str; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
#endif // __UTIL_H__ |