MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
全部  文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
serializable.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by Longda on 2010
13//
14
15#pragma once
16
17#include "common/lang/string.h"
18#include "common/lang/iostream.h"
19namespace common {
20
24enum
25{
26 MESSAGE_BASIC = 100,
27 MESSAGE_BASIC_REQUEST = 1000,
28 MESSAGE_BASIC_RESPONSE = -1000
29};
30
32{
33public:
34 /*
35 * deserialize buffer to one object
36 * @param[in]buffer, buffer to store the object serialized bytes
37 * @return * object
38 */
39 virtual void *deserialize(const char *buffer, int bufLen) = 0;
40};
41
43{
44public:
45 /*
46 * serialize this object to bytes
47 * @param[in] buffer, buffer to store the object serialized bytes,
48 * please make sure the buffer is enough
49 * @param[in] bufferLen, buffer length
50 * @return, used buffer length -- success, -1 means failed
51 */
52 virtual int serialize(ostream &os) const = 0;
53
54 /*
55 * deserialize bytes to this object
56 * @param[in] buffer buffer to store the object serialized bytes
57 * @param[in] bufferLen buffer lenght
58 * @return used buffer length -- success , -1 --failed
59 */
60 virtual int deserialize(istream &is) = 0;
61
66 virtual int get_serial_size() const = 0;
67
71 virtual void to_string(string &output) const = 0;
72};
73
74} // namespace common
Definition: serializable.h:32
Definition: serializable.h:43
virtual int get_serial_size() const =0
virtual void to_string(string &output) const =0