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