13 #include <core/storage/serialization/iarchive.hpp> 14 #include <core/storage/serialization/oarchive.hpp> 15 #include <core/storage/serialization/vector.hpp> 16 #include <core/storage/serialization/map.hpp> 35 blob() : size_(0), data_(NULL) { }
39 size_(0), data_(NULL) {
44 blob(
size_t osize,
void* odata) : size_(0), data_(NULL) {
45 if (osize > 0) {
copy(osize, odata); }
50 if (b.size_ != 0 && b.data_ != NULL) {
60 assert(data_ != NULL);
61 assert(
sizeof(T) <= size_);
62 return *
reinterpret_cast<T*
>(data_);
68 assert(data_ != NULL);
69 assert(
sizeof(T) <= size_);
70 return *
reinterpret_cast<T*
>(data_);
76 assert(data_ != NULL);
77 assert(
sizeof(T) <= size_);
78 return reinterpret_cast<T*
>(data_);
84 assert(data_ != NULL);
85 assert(
sizeof(T) <= size_);
86 return reinterpret_cast<const T*
>(data_);
90 size_t size()
const {
return size_; }
93 void*
data() {
return data_; }
96 const void*
data()
const {
return data_; }
108 void copy(
size_t osize,
void* odata) {
111 memcpy(data_, odata, osize);
116 assert(other.size_ == 0 || other.data_ != NULL);
120 memcpy(data_, other.data_, size_);
132 }
else if(size_ == new_size ) {
134 assert(data_ != NULL);
137 assert(data_ == NULL && size_ == 0);
139 data_ = malloc(new_size);
140 assert(data_ != NULL);
159 size_t tmpsize = b.size_;
174 data_ = malloc(size_);
175 deserialize(arc, data_, size_);
182 serialize(arc, data_, size_);
blob(size_t osize, void *odata)
void resize(size_t new_size)
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
void copy(const blob &other)
const void * data() const
void copy(size_t osize, void *odata)
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.