12 #ifndef SST_CORE_SERIALIZATION_IMPL_PACKER_H 13 #define SST_CORE_SERIALIZATION_IMPL_PACKER_H 15 #ifndef SST_INCLUDING_SERIALIZER_H 17 "The header file sst/core/serialization/impl/packer.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serializer.h" 20 #include "sst/core/serialization/impl/get_array_size.h" 21 #include "sst/core/serialization/impl/ser_buffer_accessor.h" 22 #include "sst/core/serialization/impl/ser_shared_ptr_tracker.h" 28 #include <type_traits> 34 std::set<uintptr_t> pointer_set;
38 using ser_buffer_accessor::ser_buffer_accessor;
43 memcpy(buf_next(
sizeof(t)), &t,
sizeof(t));
46 template <
typename T,
typename SIZE_T>
47 void pack_buffer(
const T* buffer, SIZE_T size)
49 if ( buffer !=
nullptr )
50 get_array_size(size,
"Serialization Error: Size in SST::Core::Serialization:pvt::pack_buffer() cannot fit " 51 "inside size_t. size_t should be used for sizes.\n");
54 using ELEM_T = std::conditional_t<std::is_void_v<T>, char, T>;
56 memcpy(buf_next(size *
sizeof(ELEM_T)), buffer, size *
sizeof(ELEM_T));
59 void pack_string(
const std::string& str) { pack_buffer(str.data(), str.size()); }
60 bool check_pointer_pack(uintptr_t ptr) {
return !pointer_set.insert(ptr).second; }
65 #endif // SST_CORE_SERIALIZATION_IMPL_PACKER_H Definition: ser_shared_ptr_tracker.h:30
Definition: ser_buffer_accessor.h:25
Definition: baseComponent.cc:1107