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