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