MySQL 8.0.37
Source Code Documentation
base.h
Go to the documentation of this file.
1/* Copyright (c) 2019, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef CODECS_BASE_INCLUDED
25#define CODECS_BASE_INCLUDED
26
27#include <utility>
29
30namespace binary_log {
31namespace codecs {
32
33/**
34 This is the abstract and base class for binary log codecs.
35
36 It defines the codec API. Implementations of this class must
37 be stateless.
38 */
39class Codec {
40 public:
41 /**
42 Member function that shall decode the contents of the given buffer into a
43 binary log event.
44
45 @param from the buffer containing the encoded event.
46 @param size the length of the data in the buffer.
47 @param to the binary log event to populate.
48
49 @return a pair containing the amount of bytes decoded from the buffer and a
50 boolean stating whether there was an error or not. False if no
51 error, true otherwise.
52 */
53 virtual std::pair<std::size_t, bool> decode(const unsigned char *from,
54 std::size_t size,
55 Binary_log_event &to) const = 0;
56
57 /**
58 Member function that shall encode the contents of the given binary log event
59 into an in memory buffer.
60
61 @param from the binary log event to encode.
62 @param to the buffer where the encoded event should be saved into.
63 @param size the size of the buffer.
64
65 @return a pair containing the amount of bytes encoded and whether there was
66 an error or not. False if no error, true otherwise.
67 */
68 virtual std::pair<std::size_t, bool> encode(const Binary_log_event &from,
69 unsigned char *to,
70 std::size_t size) const = 0;
71 virtual ~Codec() = default;
72};
73
74} // namespace codecs
75} // namespace binary_log
76
77#endif
This is the abstract base class for binary log events.
Definition: binlog_event.h:812
This is the abstract and base class for binary log codecs.
Definition: base.h:39
virtual ~Codec()=default
virtual std::pair< std::size_t, bool > decode(const unsigned char *from, std::size_t size, Binary_log_event &to) const =0
Member function that shall decode the contents of the given buffer into a binary log event.
virtual std::pair< std::size_t, bool > encode(const Binary_log_event &from, unsigned char *to, std::size_t size) const =0
Member function that shall encode the contents of the given binary log event into an in memory buffer...
The namespace contains classes representing events that can occur in a replication stream.