SST  14.1.0
StructuralSimulationToolkit
sizer.h
1 // Copyright 2009-2024 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-2024, 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_SIZER_H
13 #define SST_CORE_SERIALIZATION_IMPL_SIZER_H
14 
15 #ifndef SST_INCLUDING_SERIALIZER_H
16 #warning \
17  "The header file sst/core/serialization/impl/sizer.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/warnmacros.h"
21 
22 namespace SST {
23 namespace Core {
24 namespace Serialization {
25 namespace pvt {
26 
27 class ser_sizer
28 {
29 public:
30  ser_sizer() : size_(0) {}
31 
32  template <class T>
33  void size(T& UNUSED(t))
34  {
35  size_ += sizeof(T);
36  }
37 
38  void size_string(std::string& str);
39 
40  void add(size_t s) { size_ += s; }
41 
42  size_t size() const { return size_; }
43 
44  void reset() { size_ = 0; }
45 
46 protected:
47  size_t size_;
48 };
49 
50 } // namespace pvt
51 } // namespace Serialization
52 } // namespace Core
53 } // namespace SST
54 
55 #endif // SST_CORE_SERIALIZATION_IMPL_SIZER_H
Definition: action.cc:18