12 #ifndef SST_CORE_SERIALIZATION_SERIALIZER_H
13 #define SST_CORE_SERIALIZATION_SERIALIZER_H
15 #include "sst/core/serialization/serialize_packer.h"
16 #include "sst/core/serialization/serialize_sizer.h"
17 #include "sst/core/serialization/serialize_unpacker.h"
28 namespace Serialization {
37 typedef enum { SIZER, PACK, UNPACK } SERIALIZE_MODE;
64 unpacker_.unpack<T>(t);
70 mode()
const {
return mode_; }
72 void set_mode(SERIALIZE_MODE mode) { mode_ = mode; }
97 template <
class T,
int N>
103 sizer_.add(
sizeof(T) * N);
108 char* charstr = packer_.next_str(N *
sizeof(T));
109 ::memcpy(charstr, arr, N *
sizeof(T));
114 char* charstr = unpacker_.next_str(N *
sizeof(T));
115 ::memcpy(arr, charstr, N *
sizeof(T));
121 template <
typename T,
typename Int>
122 void binary(T*& buffer, Int& size)
127 sizer_.add(
sizeof(Int));
139 packer_.pack(nullsize);
145 unpacker_.unpack(size);
146 if ( size != 0 ) { unpacker_.
unpack_buffer(&buffer, size *
sizeof(T)); }
157 template <
typename Int>
158 void binary(
void*& buffer, Int& size)
160 char* tmp = (
char*)buffer;
161 binary<char>(tmp, size);
165 void string(std::string& str);
167 void start_packing(
char* buffer,
size_t size)
169 packer_.init(buffer, size);
179 void start_unpacking(
char* buffer,
size_t size)
181 unpacker_.init(buffer, size);
189 return sizer_.size();
191 return packer_.size();
193 return unpacker_.size();
204 SERIALIZE_MODE mode_;
Definition: serialize_packer.h:25
void pack_buffer(void *buf, int size)
pack_buffer
Definition: serializer.cc:39
Definition: serialize_sizer.h:23
Definition: serialize_unpacker.h:23
void unpack_buffer(void *buf, int size)
unpack_buffer
Definition: serializer.cc:25
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35