SST  12.0.1
StructuralSimulationToolkit
serialize_sizer.h
1 // Copyright 2009-2022 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-2022, 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_SERIALIZE_SIZER_H
13 #define SST_CORE_SERIALIZATION_SERIALIZE_SIZER_H
14 
15 #include "sst/core/warnmacros.h"
16 
17 namespace SST {
18 namespace Core {
19 namespace Serialization {
20 namespace pvt {
21 
22 class ser_sizer
23 {
24 public:
25  ser_sizer() : size_(0) {}
26 
27  template <class T>
28  void size(T& UNUSED(t))
29  {
30  size_ += sizeof(T);
31  }
32 
33  void size_string(std::string& str);
34 
35  void add(size_t s) { size_ += s; }
36 
37  size_t size() const { return size_; }
38 
39  void reset() { size_ = 0; }
40 
41 protected:
42  size_t size_;
43 };
44 
45 } // namespace pvt
46 } // namespace Serialization
47 } // namespace Core
48 } // namespace SST
49 
50 #endif // SST_CORE_SERIALIZATION_SERIALIZE_SIZER_H
Definition: serialize_sizer.h:22