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 |
|
|
|
16 |
torben |
38 |
std::string str_replace(std::string str, std::string search, std::string replace = ""); |
17 |
|
|
std::string str_striptags(std::string str); |
18 |
|
|
std::string str_trim(std::string str); |
19 |
|
|
|
20 |
|
|
std::string str_characters(std::string str); |
21 |
|
|
|
22 |
torben |
26 |
std::string readUrl(std::string url, std::string tempfile); |
23 |
|
|
|
24 |
|
|
std::string convertToUnicode(std::string); |
25 |
|
|
|
26 |
|
|
int uTimeDiff(const timeval& then, const timeval& now); |
27 |
|
|
int mTimeDiff(const timeval& then, const timeval& now); |
28 |
|
|
|
29 |
|
|
inline void Sleep(unsigned int msec) |
30 |
|
|
{ |
31 |
|
|
for (unsigned int i=0; i<msec; ++i) |
32 |
|
|
usleep(1000); |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
inline std::string str_tolower(std::string str) |
36 |
|
|
{ |
37 |
|
|
for(unsigned int i=0; i<str.size();++i) |
38 |
|
|
str[i] = tolower(str[i]); |
39 |
|
|
return str; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
#endif // __UTIL_H__ |