MySQL 8.4.0
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 MYSQL_BINLOG_EVENT_CODECS_BASE_H
25#define MYSQL_BINLOG_EVENT_CODECS_BASE_H
26
27#include <utility>
29
31
32/**
33 This is the abstract and base class for binary log codecs.
34
35 It defines the codec API. Implementations of this class must
36 be stateless.
37 */
38class Codec {
39 public:
40 /**
41 Member function that shall decode the contents of the given buffer into a
42 binary log event.
43
44 @param from the buffer containing the encoded event.
45 @param size the length of the data in the buffer.
46 @param to the binary log event to populate.
47
48 @return a pair containing the amount of bytes decoded from the buffer and a
49 boolean stating whether there was an error or not. False if no
50 error, true otherwise.
51 */
52 virtual std::pair<std::size_t, bool> decode(const unsigned char *from,
53 std::size_t size,
54 Binary_log_event &to) const = 0;
55
56 /**
57 Member function that shall encode the contents of the given binary log event
58 into an in memory buffer.
59
60 @param from the binary log event to encode.
61 @param to the buffer where the encoded event should be saved into.
62 @param size the size of the buffer.
63
64 @return a pair containing the amount of bytes encoded and whether there was
65 an error or not. False if no error, true otherwise.
66 */
67 virtual std::pair<std::size_t, bool> encode(const Binary_log_event &from,
68 unsigned char *to,
69 std::size_t size) const = 0;
70 virtual ~Codec() = default;
71};
72
73} // namespace mysql::binlog::event::codecs
74
75namespace [[deprecated]] binary_log {
76namespace [[deprecated]] codecs {
77using namespace mysql::binlog::event::codecs;
78} // namespace codecs
79} // namespace binary_log
80
81#endif // MYSQL_BINLOG_EVENT_CODECS_BASE_H
This is the abstract base class for binary log events.
Definition: binlog_event.h:859
This is the abstract and base class for binary log codecs.
Definition: base.h:38
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...
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.
Definition: base.h:75
Definition: base.h:30
size_t size(const char *const c)
Definition: base64.h:46