MySQL 8.4.2
Source Code Documentation
archive_text_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 if (is_good() == true) {
32 m_stream << arg.get();
33 if (m_stream.good() == false) {
35 __FILE__, __LINE__, "Unable to write data to the stream",
37 }
38 }
39 return *this;
40}
41
42template <typename Field_type>
44 if (is_good() == true) {
45 m_stream >> arg.get();
46 if (m_stream.good() == false) {
48 __FILE__, __LINE__, "Unable to read data from the stream",
50 }
51 }
52 return *this;
53}
54
55template <class Field_type>
57 auto pos = m_stream.tellg();
58 this->operator>>(std::forward<Field_type>(field));
59 m_stream.seekg(pos);
60}
61
62} // namespace mysql::serialization
Archive implementation based on stringstream.
Definition: archive_text.h:43
std::stringstream m_stream
Internal data stream.
Definition: archive_text.h:98
Archive_text & operator>>(Field_type &&arg)
Reads argument from this archive.
Definition: archive_text_impl.hpp:43
void peek(Field_type &&field)
Peeks selected field wrapper (reads data without updating read stream position)
Definition: archive_text_impl.hpp:56
Archive_text & operator<<(Field_type &&arg)
Ingests argument into this archive.
Definition: archive_text_impl.hpp:30
bool is_good() const
Definition: archive.h:190
Serialization_error m_error
Holds information about error.
Definition: archive.h:197
Error used internally in serialization framework.
Definition: serialization_error.h:46
Definition: archive.h:37
@ archive_write_error
Cannot write data to the stream.
@ archive_read_error
Cannot read data from the stream.
Definition: sql_resultset.h:36