SST 15.0
Structural Simulation Toolkit
packer.h
1// Copyright 2009-2025 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2025, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_SERIALIZATION_IMPL_PACKER_H
13#define SST_CORE_SERIALIZATION_IMPL_PACKER_H
14
15#ifndef SST_INCLUDING_SERIALIZER_H
16#warning \
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"
18#endif
19
20#include "sst/core/serialization/impl/ser_buffer_accessor.h"
21
22#include <cstddef>
23#include <string>
24
25namespace SST::Core::Serialization::pvt {
26
27class ser_packer : public ser_buffer_accessor
28{
29public:
30 template <class T>
31 void pack(T& t)
32 {
33 T* buf = ser_buffer_accessor::next<T>();
34 DISABLE_WARN_MAYBE_UNINITIALIZED
35 *buf = t;
36 REENABLE_WARNING
37 }
38
39 /**
40 * @brief pack_buffer
41 * @param buf Must be non-null
42 * @param size Must be non-zero
43 */
44 void pack_buffer(void* buf, size_t size);
45
46 void pack_string(std::string& str);
47};
48
49} // namespace SST::Core::Serialization::pvt
50
51#endif // SST_CORE_SERIALIZATION_IMPL_PACKER_H
void pack_buffer(void *buf, size_t size)
pack_buffer
Definition serializer.cc:37