forked from hep-cce2/root_serialization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerializer.h
More file actions
31 lines (25 loc) · 721 Bytes
/
Serializer.h
File metadata and controls
31 lines (25 loc) · 721 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
#if !defined(Serializer_h)
#define Serializer_h
#include <vector>
#include "TBufferFile.h"
#include "TClass.h"
namespace cce::tf {
class Serializer {
public:
Serializer() : bufferFile_{TBuffer::kWrite} {}
Serializer(Serializer&& ):
bufferFile_{TBuffer::kWrite} {}
Serializer(Serializer const&):
bufferFile_{TBuffer::kWrite} {}
std::vector<char> serialize(void const* address, TClass* tClass) {
bufferFile_.Reset();
tClass->WriteBuffer(bufferFile_, const_cast<void*>(address));
//The blob contains the serialized data product
std::vector<char> blob(bufferFile_.Buffer(), bufferFile_.Buffer()+bufferFile_.Length());
return blob;
}
private:
TBufferFile bufferFile_;
};
}
#endif