-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRawData.h
44 lines (32 loc) · 897 Bytes
/
RawData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef __MAGNETICS_RAW_DATA_H__
#define __MAGNETICS_RAW_DATA_H__
#include <cstdint>
#include <string>
#include <vector>
class RawData{
public:
RawData() : data() {}
RawData(uint8_t* data, uint8_t size) : data(data, data + size) {}
std::vector<uint8_t> to_vec(){
return data;
}
std::string to_string(){
std::string str(data.size(), '\0');
for( size_t i = 0; i < data.size(); ++i){
str[i] = (char)data[i];
}
return str;
}
bool empty(){
return data.empty();
}
inline bool operator==(const RawData& other){
return data == other.data;
}
inline bool operator!=(const RawData& other){
return data != other.data;
}
private:
std::vector<uint8_t> data;
};
#endif