MySQL 8.0.39
Source Code Documentation
gcs_types.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 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 GCS_TYPES_INCLUDED
25#define GCS_TYPES_INCLUDED
26
27#include <map>
28#include <string>
29#include <vector>
30
31/* Helper definitions for types used in this interface */
32typedef unsigned char uchar;
33typedef unsigned int uint32;
34
35/**
36 @enum enum_gcs_error
37
38 This enumeration describes errors which can occur during group
39 communication operations.
40*/
42 /* Gcs operation was successfully completed. */
43 GCS_OK = 0,
44 /* Error occurred while message communication. */
46 /* Message was bigger then what gcs can successfully communicate/handle. */
48};
49
50/**
51 @class Gcs_interface_parameters
52
53 This class is to be used to provide parameters to bindings in a transparent
54 and generic way.
55
56 Each binding must document which parameters it needs and it is the
57 responsibility of the client to provide them at initialize() time.
58 */
60 public:
61 /**
62 Adds a parameter to the parameter catalog.
63 If the value already exists, it is overridden by the new one.
64
65 @param name the name of the parameter
66 @param value value of the parameter
67 */
68
69 void add_parameter(const std::string &name, const std::string &value);
70
71 /**
72 Retrieves a parameter from the object.
73
74 @return a pointer to a registered value. NULL if not present
75 */
76
77 const std::string *get_parameter(const std::string &name) const;
78
79 /**
80 Check whether any of the parameters were provided.
81
82 @param params list of parameters.
83 @return True if any of the parameters is stored.
84 */
85
86 bool check_parameters(const std::vector<std::string> &params) const;
87
88 /**
89 Check whether any of the parameters were provided.
90
91 @param params list of parameters.
92 @param size number of parameters.
93 @return True if any of the parameters is stored.
94 */
95
96 bool check_parameters(const char *params[], int size) const;
97
98 /**
99 Adds the parameters provided to the existing set of parameters.
100 @param p Parameters to add.
101 */
102
104 std::map<std::string, std::string>::const_iterator it;
105 for (it = p.parameters.begin(); it != p.parameters.end(); it++) {
106 std::string name = (*it).first;
107 std::string val = (*it).second;
108 add_parameter(name, val);
109 }
110 }
111
112 /**
113 Clears all parameters.
114 */
115 void clear() { parameters.clear(); }
116
118
119 virtual ~Gcs_interface_parameters() = default;
120
121 private:
122 std::map<std::string, std::string> parameters;
123};
124
125/**
126 The GCS protocol versions.
127 */
128enum class Gcs_protocol_version : unsigned short {
129 /* Unknown version that shall not be used. */
130 UNKNOWN = 0,
131 V1 = 1,
132 V2 = 2,
133 V3 = 3,
134 /* Define the highest known version. */
136 /* Currently used in test cases. */
137 V4 = 4,
138 V5 = 5,
139 /*
140 No valid version number can appear after this one. If a version number is to
141 be added, this value needs to be incremented and the lowest version number
142 available be assigned to the new version.
143
144 Remember also to set HIGHEST_KNOWN to the newly created version number.
145 */
146 MAXIMUM = 5
147};
148
149#endif /* GCS_TYPES_INCLUDED */
This class is to be used to provide parameters to bindings in a transparent and generic way.
Definition: gcs_types.h:59
virtual ~Gcs_interface_parameters()=default
bool check_parameters(const std::vector< std::string > &params) const
Check whether any of the parameters were provided.
Definition: gcs_types.cc:49
void clear()
Clears all parameters.
Definition: gcs_types.h:115
const std::string * get_parameter(const std::string &name) const
Retrieves a parameter from the object.
Definition: gcs_types.cc:59
void add_parameters_from(const Gcs_interface_parameters &p)
Adds the parameters provided to the existing set of parameters.
Definition: gcs_types.h:103
void add_parameter(const std::string &name, const std::string &value)
Adds a parameter to the parameter catalog.
Definition: gcs_types.cc:31
std::map< std::string, std::string > parameters
Definition: gcs_types.h:122
Gcs_interface_parameters()
Definition: gcs_types.h:117
const char * p
Definition: ctype-mb.cc:1237
unsigned int uint32
Definition: gcs_types.h:33
enum_gcs_error
This enumeration describes errors which can occur during group communication operations.
Definition: gcs_types.h:41
@ GCS_OK
Definition: gcs_types.h:43
@ GCS_NOK
Definition: gcs_types.h:45
@ GCS_MESSAGE_TOO_BIG
Definition: gcs_types.h:47
unsigned char uchar
Definition: gcs_types.h:32
Gcs_protocol_version
The GCS protocol versions.
Definition: gcs_types.h:128
case opt name
Definition: sslopt-case.h:33