Subversion Repositories heating

Rev

Rev 3 | Rev 5 | Go to most recent revision | 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>
22
#include <string>
23
#include <sstream>
24
 
25
#ifndef nullptr
26
const class							// this is a const object...
27
{
28
	public:
29
		template<class T>			// convertible to any type
30
		operator T*() const			// of null non-member
31
		{ return 0; }				// pointer...
32
 
33
		template<class C, class T>	// or any type of null
34
		operator T C::*() const		// member pointer...
35
		{ return 0; }
36
 
37
	private:
38
		void operator&() const;		// whose address can't be taken
39
} nullptr = {};
40
#endif
41
 
42
class helper
43
{
44
	public:
45
		helper();
46
 
47
		char *readLine(int fd, char *buf, int bufLen);
48
		char *trim(char *str);
49
		std::string trim(std::string str);
50
		int compare(char *str1, char *str2);
51
		int compcase(const char *str1, const char *str2);
52
		int compcase(std::string str1, std::string str2);
53
		char *findc(char *str, int len, char c);
54
		int findc(std::string str, char c);
55
		void setPName(char *name);
56
		std::string itostring(int i);
57
		char *assign(std::string str);
58
		void enableDebug(bool what) { dbg = what; };
59
		void debug(std::string msg);
4 andreas 60
		bool ToBool(char *str);
61
		bool ToBool(std::string s);
62
		bool ToBool(int i);
3 andreas 63
		bool isArm();
64
 
65
		template <typename T>
66
		inline std::string ToString(T value)
67
		{
68
			std::stringstream stream;
69
			stream << value;
70
			return stream.str();
71
		}
72
 
73
	private:
74
		char pname[48];
75
		bool dbg;
76
};
77
 
78
#endif