MySQL 9.1.0
Source Code Documentation
data_extension.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 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 Data_extension_INCLUDED
25#define Data_extension_INCLUDED
26
27#include "data.h" /* data::Data */
28
29namespace keyring_common::data {
30/**
31 Data wrapper to include backend specific extensions
32*/
33
34template <typename Extension>
35class Data_extension final : public Data {
36 public:
37 /** Constructor */
38 Data_extension(const data::Data data, const Extension ext)
39 : data::Data(data), ext_(ext) {}
40 Data_extension() : Data_extension(data::Data{}, Extension{}) {}
42 Data_extension(const Extension ext) : Data_extension(data::Data{}, ext) {}
43
44 /** Copy constructor */
46 : Data_extension(src.get_data(), src.ext_) {}
47
48 /** Assignment operator */
50 if (this != &src) {
51 Data::operator=(src);
52 ext_ = src.ext_;
53 }
54 return *this;
55 }
56
57 /* Get data */
58 data::Data get_data() const override { return Data::get_data(); }
59
60 /* Get Metadata extension details */
61 Extension get_extension() const { return ext_; }
62
63 /* Set data */
64 void set_data(const data::Data &data) override { Data::operator=(data); }
65 /* Set metadata extension */
66 void set_extension(const Extension ext) { ext_ = ext; }
67
68 private:
69 /** Backend specific extensions */
70 Extension ext_;
71};
72
73} // namespace keyring_common::data
74
75#endif // !Data_extension_INCLUDED
Data wrapper to include backend specific extensions.
Definition: data_extension.h:35
void set_extension(const Extension ext)
Definition: data_extension.h:66
Extension ext_
Backend specific extensions.
Definition: data_extension.h:70
Data_extension(const data::Data data, const Extension ext)
Constructor.
Definition: data_extension.h:38
Data_extension()
Definition: data_extension.h:40
Extension get_extension() const
Definition: data_extension.h:61
Data_extension(const data::Data data)
Definition: data_extension.h:41
data::Data get_data() const override
Return self.
Definition: data_extension.h:58
Data_extension(const Extension ext)
Definition: data_extension.h:42
void set_data(const data::Data &data) override
Set data.
Definition: data_extension.h:64
Data_extension(const Data_extension &src)
Copy constructor.
Definition: data_extension.h:45
Data_extension & operator=(const Data_extension &src)
Assignment operator.
Definition: data_extension.h:49
Sensitive data storage.
Definition: data.h:39
Sensitive_data data() const
Get data.
Definition: data.cc:68
virtual Data get_data() const
Return self.
Definition: data.cc:65
Data & operator=(const Data &src)
Definition: data.cc:28
Json_data_extension ext
Definition: backend.cc:50