MySQL 9.1.0
Source Code Documentation
read_archive_binary_impl.hpp
Go to the documentation of this file.
1// Copyright (c) 2023, 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/// @file
25/// Experimental API header
26
27namespace mysql::serialization {
28
29template <typename Field_type>
31 static constexpr auto value_size = Field_type::value_size;
33 if (is_good() == true) {
34 auto bytes_read =
35 Primitive_type_codec<value_type>::template read_bytes<value_size>(
36 m_stream + read_pos, m_stream_size - read_pos, arg.get());
37 if (bytes_read == 0) {
39 __FILE__, __LINE__, "Unable to read data from the stream",
41 return *this;
42 }
43 read_pos += bytes_read;
44 }
45 return *this;
46}
47
48template <class Field_type>
50 auto read_pos_saved = read_pos;
51 this->operator>>(std::forward<Field_type>(field));
52 read_pos = read_pos_saved;
53}
54
55} // namespace mysql::serialization
bool is_good() const
Definition: archive.h:190
Serialization_error m_error
Holds information about error.
Definition: archive.h:197
Binary, read only archive implementation based on vector of bytes.
Definition: read_archive_binary.h:43
std::size_t read_pos
Read position.
Definition: read_archive_binary.h:92
Read_archive_binary & operator>>(Field_type &&arg)
Reads argument from this archive.
Definition: read_archive_binary_impl.hpp:30
std::size_t m_stream_size
Definition: read_archive_binary.h:93
void peek(Field_type &&field)
Peeks selected field wrapper (reads data without updating read stream position)
Definition: read_archive_binary_impl.hpp:49
const unsigned char * m_stream
Internal data stream.
Definition: read_archive_binary.h:91
Error used internally in serialization framework.
Definition: serialization_error.h:43
uint16_t value_type
Definition: vt100.h:184
Definition: archive.h:37
@ archive_read_error
Cannot read data from the stream.
Definition: sql_resultset.h:36
This class is to provide functionality to encode/decode the primitive types into/out of defined strea...
Definition: primitive_type_codec.h:113