Types.h 1.16 KB
Newer Older
/jdi/'s avatar
basics  
/jdi/ committed
1
2
3
4
5
6
7
8
9
10
/*
 * Types.h
 *
 *  Created on: 11.09.2015
 *      Author: jdi
 */

#ifndef TYPES_H_
#define TYPES_H_

/jdi/'s avatar
/jdi/ committed
11
#include <functional>
/jdi/'s avatar
basics  
/jdi/ committed
12
#include <vector>
/jdi/'s avatar
/jdi/ committed
13
#include <array>
/jdi/'s avatar
/jdi/ committed
14
#include <map>
/jdi/'s avatar
basics  
/jdi/ committed
15

/jdi/'s avatar
/jdi/ committed
16
17
18
19
20
21
22
template<typename T>
std::vector<T> operator+(const std::vector<T> &A, const std::vector<T> &B) {
	std::vector<T> AB;
	AB.reserve(A.size() + B.size());                // preallocate memory
	AB.insert(AB.end(), A.begin(), A.end());        // add A;
	AB.insert(AB.end(), B.begin(), B.end());        // add B;
	return AB;
/jdi/'s avatar
basics  
/jdi/ committed
23
24
}

/jdi/'s avatar
/jdi/ committed
25
26
27
28
29
template<typename T>
std::vector<T> &operator+=(std::vector<T> &A, const std::vector<T> &B) {
	A.reserve(A.size() + B.size());
	A.insert(A.end(), B.begin(), B.end());
	return A;
/jdi/'s avatar
basics  
/jdi/ committed
30
31
}

/jdi/'s avatar
/jdi/ committed
32
33
template<size_t N>
using byteArray = std::array<unsigned char, N>;
/jdi/'s avatar
basics  
/jdi/ committed
34
35
36
typedef std::vector<unsigned char> bytes;
typedef unsigned char byte;

/jdi/'s avatar
/jdi/ committed
37
38
39
40
struct dataset {
	short type;
	short len;
	bytes value;
/jdi/'s avatar
basics  
/jdi/ committed
41
42
};

/jdi/'s avatar
/jdi/ committed
43
//typedef std::vector<dataset> datasets;
/jdi/'s avatar
/jdi/ committed
44
45
46
47
typedef std::map<short, dataset> datasets;

//std::function<int()>;
//typedef int receiveCallback;
/jdi/'s avatar
/jdi/ committed
48
49
50
51
52
struct Options {
	unsigned flags = 0x00;
	std::string user;
	std::string password;
	std::string interface;
/jdi/'s avatar
/jdi/ committed
53
54
	std::string file;
	long timeout;
/jdi/'s avatar
/jdi/ committed
55
};
/jdi/'s avatar
basics  
/jdi/ committed
56
57

#endif /* TYPES_H_ */