forked from DigiAsset-Core/DigiAsset_Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlob.h
More file actions
47 lines (36 loc) · 937 Bytes
/
Blob.h
File metadata and controls
47 lines (36 loc) · 937 Bytes
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
45
46
47
//
// Created by mctrivia on 07/04/23.
//
#ifndef DIGIBYTECORE_BLOB_H
#define DIGIBYTECORE_BLOB_H
#include <cstdint>
#include <cstring>
#include <string>
#include <vector>
class Blob {
public:
Blob(const void* data, int length);
explicit Blob(const std::vector<uint8_t>& data);
explicit Blob(const std::string& hex);
~Blob();
std::string toHex() const;
unsigned char* data() const;
std::vector<uint8_t> vector() const;
size_t length() const;
Blob(const Blob& other);
Blob& operator=(const Blob& other);
bool operator==(const Blob& b) const {
if (b._length != _length) return false;
if (_data != b._data) {
return memcmp(_data, b._data, _length) == 0;
}
return true;
}
bool operator!=(const Blob& b) const {
return !(*this == b);
}
private:
unsigned char* _data;
size_t _length;
};
#endif //DIGIBYTECORE_BLOB_H