Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1309 runge 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>
1311 runge 20
#include "types.h"
1309 runge 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);
1311 runge 37
string_list explode(string delimiter, string str);
1309 runge 38
string strtoupper(string s);
39
string strtolower(string s);
1311 runge 40
 
41
//string trim(string s);
42
//string trim(const string s, char c);
43
 
1310 runge 44
bool stob(const string s);
1309 runge 45
int stoi(const string s);
46
string itos(int i);
47
string utos(unsigned int i);
48
unsigned int stou(const string s);
49
float stof(const string s);
50
string ftos(float f);
51
string str_replace(string search, string replace, string str);
52
string file_get_contents(string filename);
53
bool file_exists(string filename);
54
string escape(string in);
55
string rpad(string in, unsigned int length, char c);
56
string lpad(string in, unsigned int length, char c);
57
 
58
}
59
}
60
 
61
#endif /* UTILS_H_ */