0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Serializable.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Hypertable_Common_Serializable_h
28 #define Hypertable_Common_Serializable_h
29 
30 namespace Hypertable {
31 
34 
65  class Serializable {
66 
67  public:
68 
73  virtual size_t encoded_length() const;
74 
81  virtual void encode(uint8_t **bufp) const;
82 
89  virtual void decode(const uint8_t **bufp, size_t *remainp);
90 
91  protected:
92 
95  virtual uint8_t encoding_version() const = 0;
96 
102  virtual size_t encoded_length_internal() const = 0;
103 
108  virtual void encode_internal(uint8_t **bufp) const = 0;
109 
117  virtual void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) = 0;
118 
119  };
120 
122 
123 }
124 
125 #endif // Hypertable_Common_Serializable_h
virtual void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp)=0
Reads serialized representation of object from a buffer.
virtual size_t encoded_length_internal() const =0
Returns internal serialized length.
virtual size_t encoded_length() const
Returns serialized object length.
Definition: Serializable.cc:37
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
Definition: Serializable.cc:64
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Definition: Serializable.cc:70
Hypertable definitions
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
virtual uint8_t encoding_version() const =0
Returns encoding version.
virtual void encode_internal(uint8_t **bufp) const =0
Writes serialized representation of object to a buffer.