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