Utils.h 754 Bytes
Newer Older
/jdi/'s avatar
/jdi/ committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Utils.h
 *
 *  Created on: 24.09.2015
 *      Author: jdi
 */

#ifndef UTILS_H_
#define UTILS_H_

#include <string>
#include <cstring>
#include "Types.h"

namespace utils {

static void printHex(bytes d) {
	if (d.size() > 0)
		printf("%.2X", d[0]);
	for (unsigned i = 1; i < d.size(); i++) {
		printf(":%.2X", d[i]);
	}
}

/jdi/'s avatar
/jdi/ committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
static void print(byteArray<6> d) {
	printf("%.2X", d[0]);
	for (unsigned i = 1; i < 6; i++) {
		printf(":%.2X", d[i]);
	}
}

static void print(byteArray<4> d) {
	printf("%.1d", d[0]);
	for (unsigned i = 1; i < 4; i++) {
		printf(".%.1d", d[i]);
	}
}

/jdi/'s avatar
/jdi/ committed
39
40
41
42
43
44
45
46
47
48
static void printDec(bytes d) {
	if (d.size() > 0)
		printf("%.1d", d[0]);
	for (unsigned i = 1; i < d.size(); i++) {
		printf(".%.1d", d[i]);
	}
}

}
#endif /* UTILS_H_ */