Subversion Repositories HomeAutomation

Rev

Rev 1309 | Go to most recent revision | Blame | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  * Utils.h
  3.  *
  4.  *  Created on: Apr 26, 2009
  5.  *      Author: Mattias Runge
  6.  */
  7.  
  8. #ifndef UTILS_H_
  9. #define UTILS_H_
  10.  
  11. #include <string>
  12. #include <vector>
  13. #include <fstream>
  14. #include <sstream>
  15. #include <stdexcept>
  16. #include <iostream>
  17. #include <cmath>
  18. #include <sys/types.h>
  19. #include <dirent.h>
  20. #include "../types.h"
  21.  
  22. using namespace std;
  23.  
  24. namespace atom {
  25. namespace utils {
  26.  
  27. string bytes2string(byte_list bytes);
  28. string niceTime();
  29. unsigned int hex2uint(string hex);
  30. string hex2bin(string hex);
  31. string bin2hex(string bin);
  32. float bin2float(string bin);
  33. string float2bin(float num, unsigned int length);
  34. unsigned int bin2uint(string bin);
  35. string uint2bin(unsigned int num, unsigned int length);
  36. string uint2hex(unsigned int num, unsigned int length);
  37. vector<string> explode(string delimiter, string str);
  38. string strtoupper(string s);
  39. string strtolower(string s);
  40. string trim(string s);
  41. string trim(const string s, char c);
  42. bool stob(const string s);
  43. int stoi(const string s);
  44. string itos(int i);
  45. string utos(unsigned int i);
  46. unsigned int stou(const string s);
  47. float stof(const string s);
  48. string ftos(float f);
  49. string str_replace(string search, string replace, string str);
  50. string file_get_contents(string filename);
  51. bool file_exists(string filename);
  52. string escape(string in);
  53. string rpad(string in, unsigned int length, char c);
  54. string lpad(string in, unsigned int length, char c);
  55.  
  56. }
  57. }
  58.  
  59. #endif /* UTILS_H_ */
  60.