MySQL 8.4.0
Source Code Documentation
meta.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 META_INCLUDED
25#define META_INCLUDED
26
27#include <string>
28
29namespace keyring_common {
30namespace meta {
31
32/**
33 Common metadata.
34 Usually provided by:
35 - consumer of keyring APIs
36 - Keyring backend when data is fetched
37*/
38
39class Metadata final {
40 public:
41 Metadata(const std::string key_id, const std::string owner_id);
42 Metadata(const char *key_id, const char *owner_id);
43 Metadata();
44
45 Metadata(const Metadata &src);
46
47 Metadata(Metadata &&src) noexcept;
48
50
51 Metadata &operator=(Metadata &&src) noexcept;
52
53 /** Destructor */
54 ~Metadata();
55
56 /** Get key ID */
57 const std::string key_id() const;
58
59 /** Get owner info */
60 const std::string owner_id() const;
61
62 /** Validity of metadata object */
63 bool valid() const;
64
65 /* For unordered map */
66
67 const std::string hash_key() const { return hash_key_; }
68 bool operator==(const Metadata &other) const {
69 return key_id_ == other.key_id_ && owner_id_ == other.owner_id_;
70 }
71 struct Hash {
72 size_t operator()(const Metadata &metadata) const {
73 return std::hash<std::string>()(metadata.hash_key());
74 }
75 };
76
77 private:
78 void create_hash_key();
79
80 /** Consumer specific key id*/
81 std::string key_id_;
82 /** Owner information */
83 std::string owner_id_;
84 /** Hash key */
85 std::string hash_key_;
86 /** Validity of metadata */
87 bool valid_{false};
88};
89
90} // namespace meta
91} // namespace keyring_common
92
93#endif // !META_INCLUDED
Common metadata.
Definition: meta.h:39
void create_hash_key()
create hash key
Definition: meta.cc:79
Metadata()
Definition: meta.cc:40
Metadata & operator=(const Metadata &src)
Assignment operator.
std::string key_id_
Consumer specific key id.
Definition: meta.h:81
bool operator==(const Metadata &other) const
Definition: meta.h:68
const std::string owner_id() const
Get owner info.
Definition: meta.cc:73
std::string hash_key_
Hash key.
Definition: meta.h:85
bool valid() const
Validity of metadata object.
Definition: meta.cc:76
bool valid_
Validity of metadata.
Definition: meta.h:87
~Metadata()
Destructor.
Definition: meta.cc:67
const std::string key_id() const
Get key ID.
Definition: meta.cc:70
std::string owner_id_
Owner information.
Definition: meta.h:83
const std::string hash_key() const
Definition: meta.h:67
Definition: keyring_encryption_service_definition.h:32
size_t operator()(const Metadata &metadata) const
Definition: meta.h:72