MySQL Connector/C++
MySQL connector library for C and C++ applications
row.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, 2024, Oracle and/or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0, as
6 * published by the Free Software Foundation.
7 *
8 * This program is designed to work with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms, as
10 * designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have either included with
14 * the program or referenced in the documentation.
15 *
16 * Without limiting anything contained in the foregoing, this file,
17 * which is part of Connector/C++, is also subject to the
18 * Universal FOSS Exception, version 1.0, a copy of which can be found at
19 * https://oss.oracle.com/licenses/universal-foss-exception.
20 *
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24 * See the GNU General Public License, version 2.0, for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#ifndef MYSQLX_DETAIL_ROW_H
32#define MYSQLX_DETAIL_ROW_H
33
40#include "../common.h"
41#include "../document.h"
42
43#include <memory>
44
45
46namespace mysqlx {
47MYSQLX_ABI_BEGIN(2,0)
48
49class Columns;
50
51namespace internal {
52
53template <class COLS> class Row_result_detail;
54struct Table_insert_detail;
55
56
57class PUBLIC_API Row_detail
58{
59protected:
60
61 class INTERNAL Impl;
62 DLL_WARNINGS_PUSH
63 std::shared_ptr<Impl> m_impl;
64 DLL_WARNINGS_POP
65
66 Row_detail() = default;
67
68 Row_detail(std::shared_ptr<Impl> &&impl)
69 {
70 m_impl = std::move(impl);
71 }
72
73 col_count_t col_count() const;
74 bytes get_bytes(col_count_t) const;
75 Value& get_val(col_count_t);
76
77 void clear()
78 {
79 m_impl.reset();
80 }
81
82 Impl& get_impl();
83
84 const Impl& get_impl() const
85 {
86 return const_cast<Row_detail*>(this)->get_impl();
87 }
88
89 void ensure_impl();
90
91 using Args_prc = Args_processor<Row_detail, std::pair<Impl*, col_count_t>*>;
92
93 template<typename... Types>
94 void set_values(col_count_t pos, Types... args)
95 {
96 ensure_impl();
97 assert(m_impl);
98 std::pair<Impl*, col_count_t> data{ m_impl.get(), pos };
99 Args_prc::process_args(&data, args...);
100 }
101
102 static void process_one(std::pair<Impl*, col_count_t>*, const Value &val);
103
104 friend Table_insert_detail;
105 friend Row_result_detail<Columns>;
106 friend Args_prc;
107};
108
109
110} // internal namespace
111MYSQLX_ABI_END(2,0)
112} // mysqlx
113
114#endif