/[projects]/smsdaemon/Util.h
ViewVC logotype

Diff of /smsdaemon/Util.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 26 by torben, Mon Jun 9 18:15:53 2008 UTC revision 185 by torben, Mon Dec 15 09:10:05 2008 UTC
# Line 4  Line 4 
4    
5  #include <string>  #include <string>
6  #include <vector>  #include <vector>
 #include <cctype>  
7    
8  struct timeval;  struct timeval;
9    
10  namespace Util  namespace Util
11  {  {
12            //use whitespace
13            std::vector<std::string> str_split(std::string input);
14    
15          std::vector<std::string> str_split(std::string input, std::string delimiter);          std::vector<std::string> str_split(std::string input, std::string delimiter);
16          void str_dump(const std::string& str);          void str_dump(const std::string& str);
17          void str_clean(std::string* str, std::string search, std::string replace = "");  
18            std::string str_replace(std::string str, std::string search, std::string replace = "");
19            std::string str_striptags(std::string str);
20            std::string str_trim(std::string str);
21    
22            std::string str_toupper(std::string str);
23            std::string str_tolower(std::string str);
24    
25            std::string str_formatint(int i);
26    
27            std::string str_replace_char(std::string str, char search, char replace);
28            std::string str_characters(std::string str);
29    
30            std::string str_gsm2latin(std::string str);
31            std::string str_latin2gsm(std::string str);
32    
33          std::string readUrl(std::string url, std::string tempfile);          std::string readUrl(std::string url, std::string tempfile);
34    
35            std::string iconv_wrapper(std::string _input, std::string to_format, std::string from_format);
36    
37          std::string convertToUnicode(std::string);          std::string convertToUnicode(std::string);
38            std::string convertFromUnicode(std::string);
39    
40          int uTimeDiff(const timeval& then, const timeval& now);          int uTimeDiff(const timeval& then, const timeval& now);
41          int mTimeDiff(const timeval& then, const timeval& now);          int mTimeDiff(const timeval& then, const timeval& now);
42    
43          inline void Sleep(unsigned int msec)          timeval GetTimeOfDay();
         {  
             for (unsigned int i=0; i<msec; ++i)  
                 usleep(1000);  
         }  
44    
45          inline std::string str_tolower(std::string str)          int my_system(const char* cmd, std::string* response = 0);
46    
47            std::string readfile(std::string filename);
48    
49            inline void Sleep(unsigned int msec)
50          {          {
51              for(unsigned int i=0; i<str.size();++i)                  if (msec < 1000)
52                  str[i] = tolower(str[i]);                  {
53              return str;                          usleep(1000*msec);
54                    }
55                    else
56                    {
57                    for (unsigned int i=0; i<msec; ++i)
58                            usleep(1000);
59                    }
60          }          }
61    
62  }  }

Legend:
Removed from v.26  
changed lines
  Added in v.185

  ViewVC Help
Powered by ViewVC 1.1.20