Subversion Repositories heating

Rev

Rev 5 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 andreas 1
/*
2
 * Copyright (C) 2015 by Andreas Theofilu. All rights reserved!
3
 *
4
 * All rights reserved. No warranty, explicit or implicit, provided.
5
 *
6
 * NOTICE:  All information contained herein is, and remains
7
 * the property of Andreas Theofilu and his suppliers, if any.
8
 * The intellectual and technical concepts contained
9
 * herein are proprietary to Andreas Theofilu and its suppliers and
10
 * may be covered by European and Foreign Patents, patents in process,
11
 * and are protected by trade secret or copyright law.
12
 * Dissemination of this information or reproduction of this material
13
 * is strictly forbidden unless prior written permission is obtained
14
 * from Andreas Theofilu.
15
 * 
16
 * Author: Andreas Theofilu <andreas@theosys.at>
17
 */
18
#ifndef __HELPER_H__
19
#define __HELPER_H__
20
 
21
#include <iostream>
5 andreas 22
#include <iomanip>
3 andreas 23
#include <string>
24
#include <sstream>
5 andreas 25
#include <vector>
3 andreas 26
 
27
class helper
28
{
29
	public:
30
		helper();
31
 
32
		char *readLine(int fd, char *buf, int bufLen);
33
		char *trim(char *str);
34
		std::string trim(std::string str);
35
		int compare(char *str1, char *str2);
36
		int compcase(const char *str1, const char *str2);
37
		int compcase(std::string str1, std::string str2);
38
		char *findc(char *str, int len, char c);
39
		int findc(std::string str, char c);
5 andreas 40
		std::vector<std::string> split(std::string str, char delimiter);
3 andreas 41
		void setPName(char *name);
42
		std::string itostring(int i);
43
		char *assign(std::string str);
44
		void enableDebug(bool what) { dbg = what; };
45
		void debug(std::string msg);
4 andreas 46
		bool ToBool(char *str);
47
		bool ToBool(std::string s);
48
		bool ToBool(int i);
3 andreas 49
		bool isArm();
50
 
51
		template <typename T>
52
		inline std::string ToString(T value)
53
		{
54
			std::stringstream stream;
55
			stream << value;
56
			return stream.str();
57
		}
58
 
5 andreas 59
		inline std::string doubleToString(double d, int prec)
60
		{
61
			std::stringstream stream;
26 andreas 62
			stream << std::fixed << std::setprecision(prec) << d;
5 andreas 63
			return stream.str();
64
		}
65
 
3 andreas 66
	private:
67
		char pname[48];
68
		bool dbg;
69
};
70
 
71
#endif