MySQL 9.0.0
Source Code Documentation
data.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_INCLUDED
25#define DATA_INCLUDED
26
27#include <string>
28
29namespace keyring_common::data {
30
31/** Data types */
32using Type = std::string;
33using Sensitive_data = std::string;
34
35/**
36 Sensitive data storage
37*/
38
39class Data {
40 public:
42 Data();
43 explicit Data(Type type);
44 Data(const Data &src);
45 Data(Data &&src) noexcept;
46 Data &operator=(const Data &src);
47 Data &operator=(Data &&src) noexcept;
48
49 virtual ~Data();
50
51 virtual Data get_data() const;
52
53 Sensitive_data data() const;
54
55 Type type() const;
56
57 bool valid() const;
58
59 void set_data(const Sensitive_data &data);
60
61 virtual void set_data(const Data &src);
62
63 void set_type(Type type);
64
65 bool operator==(const Data &other) const;
66
67 protected:
68 void set_validity();
69 /** Sensitive data */
71 /** Data type */
73 /** Validity of Data object */
74 bool valid_{false};
75};
76
77} // namespace keyring_common::data
78
79#endif // !DATA_INCLUDED
Sensitive data storage.
Definition: data.h:39
bool operator==(const Data &other) const
Comparison.
Definition: data.cc:92
void set_data(const Sensitive_data &data)
Set data.
Definition: data.cc:77
void set_validity()
Set validity of the data object.
Definition: data.cc:97
Type type() const
Get data's type.
Definition: data.cc:71
Data()
Definition: data.cc:37
bool valid() const
Status of object's validity.
Definition: data.cc:74
Sensitive_data data() const
Get data.
Definition: data.cc:68
Type type_
Data type.
Definition: data.h:72
void set_type(Type type)
Set type.
Definition: data.cc:86
virtual ~Data()
Destructor.
Definition: data.cc:62
virtual Data get_data() const
Return self.
Definition: data.cc:65
Data & operator=(const Data &src)
Sensitive_data data_
Sensitive data.
Definition: data.h:70
bool valid_
Validity of Data object.
Definition: data.h:74
Definition: data.cc:28
std::string Type
Data types.
Definition: data.h:32
std::string Sensitive_data
Definition: data.h:33