SST  6.0.0
StructuralSimulationToolkit
serialize_sizer.h
1 // Copyright 2009-2016 Sandia Corporation. Under the terms
2 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2016, Sandia Corporation
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 namespace SST {
16 namespace Core {
17 namespace Serialization {
18 namespace pvt {
19 
20 class ser_sizer
21 {
22  public:
23  ser_sizer() :
24  size_(0)
25  {
26  }
27 
28  template <class T>
29  void
30  size(T& t){
31  size_ += sizeof(T);
32  }
33 
34  void
35  size_string(std::string& str);
36 
37  void
38  add(size_t s) {
39  size_ += s;
40  }
41 
42  size_t
43  size() const {
44  return size_;
45  }
46 
47  void
48  reset() {
49  size_ = 0;
50  }
51 
52  protected:
53  size_t size_;
54 
55 };
56 
57 } }
58 }
59 }
60 
61 #endif // SERIALIZE_SIZER_H
Definition: action.cc:17
Definition: serialize_sizer.h:20