12 #ifndef SPROCKIT_COMMON_MESSAGES_spkt_serializer_H_INCLUDED
13 #define SPROCKIT_COMMON_MESSAGES_spkt_serializer_H_INCLUDED
16 #include <sst/core/serialization/serialize_packer.h>
17 #include <sst/core/serialization/serialize_sizer.h>
18 #include <sst/core/serialization/serialize_unpacker.h>
29 namespace Serialization {
78 unpacker_.unpack<T>(t);
91 set_mode(SERIALIZE_MODE mode) {
118 template <
class T,
int N>
123 sizer_.add(
sizeof(T) * N);
127 char* charstr = packer_.next_str(N*
sizeof(T));
128 ::memcpy(charstr, arr, N*
sizeof(T));
132 char* charstr = unpacker_.next_str(N*
sizeof(T));
133 ::memcpy(arr, charstr, N*
sizeof(T));
139 template <
typename T,
typename Int>
141 binary(T*& buffer, Int& size){
144 sizer_.add(
sizeof(Int));
150 packer_.pack_buffer(buffer, size*
sizeof(T));
154 unpacker_.unpack(size);
155 unpacker_.unpack_buffer(&buffer, size*
sizeof(T));
163 template <
typename Int>
165 binary(
void*& buffer, Int& size){
168 sizer_.add(
sizeof(Int));
174 packer_.pack_buffer(buffer, size);
178 unpacker_.unpack(size);
179 unpacker_.unpack_buffer(&buffer, size);
186 string(std::string& str);
189 start_packing(
char* buffer,
size_t size){
190 packer_.init(buffer, size);
201 start_unpacking(
char* buffer,
size_t size){
202 unpacker_.init(buffer, size);
209 case SIZER:
return sizer_.size();
210 case PACK:
return packer_.size();
211 case UNPACK:
return unpacker_.size();
221 SERIALIZE_MODE mode_;
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Definition: serialize_packer.h:23
Definition: serialize_sizer.h:20
Definition: serialize_unpacker.h:22