MySQL 8.0.30
Source Code Documentation
mysql_string_service_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2022, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is also distributed with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have included with MySQL.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License, version 2.0, for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef MYSQL_SERVER_STRING_SERVICE_H
24#define MYSQL_SERVER_STRING_SERVICE_H
25
29
30/*
31 This header file is used in mysql_server component, which is not
32 server-enabled, and can't have following declaration acquired by including
33 mysql headers.
34*/
35
36class String;
37
38/**
39 mysql_string_itrerator structure to provide service to components
40*/
43 const char *iterator_ptr;
44 int ctype;
45};
46
47/**
48 The string functions as a service to the mysql_server component.
49 So, that by default this service is available to all the components
50 register to the server.
51 successful invocations of the underlying String Service Implementation
52 methods.
53*/
55 public: /* service implementations */
56 /* mysql_charset service. */
57
59
61
62 /**
63 Creates a new instance of string object
64
65 @param out_string holds pointer to newly created string object.
66 @return Status of performed operation
67 @retval false success
68 @retval true failure
69 */
70 static DEFINE_BOOL_METHOD(create, (my_h_string * out_string));
71
72 /**
73 Destroys specified string object and data contained by it.
74
75 @param string String object handle to release.
76 */
77 static DEFINE_METHOD(void, destroy, (my_h_string string));
78
79 /**
80 Convert a String pointed by handle to lower case. Conversion depends on the
81 client character set info
82
83 @param out_string Holds the converted lower case string object.
84 @param in_string Pointer to string object to be converted.
85 @return Status of performed operation
86 @retval false success
87 @retval true failure
88 */
90 (my_h_string * out_string, my_h_string in_string));
91
92 /**
93 Convert a String pointed by handle to upper case. Conversion depends on the
94 client character set info
95
96 @param out_string Holds the converted upper case string object.
97 @param in_string Pointer to string object to be converted.
98 @return Status of performed operation
99 @retval false success
100 @retval true failure
101 */
103 (my_h_string * out_string, my_h_string in_string));
104
105 /* mysql_string_converter service. */
106
107 /**
108 Allocates a string object and converts the character buffer to string
109 and just sets the specified charset_name in the string object. It does
110 not performs the conversion of buffer into the specified character set.
111 Caller must free the allocated string by calling destroy() api.
112
113 @param [out] out_string Pointer to string object handle to set new string
114 to.
115 @param in_buffer Pointer to the buffer with data to be interpreted as
116 string.
117 @param length Length of the buffer to copy into string, in bytes, not in
118 character count.
119 @param charset_name charset that is used for conversion.
120 @return Status of performed operation
121 @retval false success
122 @retval true failure
123 */
125 (my_h_string * out_string, const char *in_buffer,
126 uint64 length, const char *charset_name));
127
128 /**
129 Converts the mysql_string to the character set specified by
130 charset_name parameter.
131
132 @param in_string Pointer to string object handle to set new string
133 to.
134 @param [out] out_buffer Pointer to the buffer with data to be interpreted
135 as characters.
136 @param length Length of the buffer to hold out put in characters.
137 @param charset_name charset that is used for conversion.
138 @return Status of performed operation
139 @retval false success
140 @retval true failure
141 */
143 (my_h_string in_string, char *out_buffer,
144 uint64 length, const char *charset_name));
145
146 /* mysql_string_converter_v2 service. */
147
149 (my_h_string dest_string, const char *src_buffer,
150 uint64 src_length, CHARSET_INFO_h src_charset));
151
153 (my_h_string src_string, char *dest_buffer,
154 uint64 dest_length, CHARSET_INFO_h dest_charset));
155
156 /**
157 Gets character code of character on specified index position in
158 string to a specified buffer.
159
160 @param string String object handle to get character from.
161 @param index Index, position of character to query.
162 @param [out] out_char Pointer to unsigned long value to store character to.
163 @return Status of performed operation
164 @retval false success
165 @retval true failure
166 */
168 (my_h_string string, uint index, ulong *out_char));
169
170 /**
171 Gets length of specified string expressed as number of characters.
172
173 @param string String object handle to get length of.
174 @param [out] out_length Pointer to 64bit value to store length of string to.
175 @return Status of performed operation
176 @retval false success
177 @retval true failure
178 */
180 (my_h_string string, uint *out_length));
181
182 /**
183 Gets byte code of string at specified index position to a
184 specified 32-bit buffer.
185
186 @param string String object handle to get character from.
187 @param index Index, position of character to query.
188 @param [out] out_char Pointer to 32bit value to store byte to.
189 @return Status of performed operation
190 @retval false success
191 @retval true failure
192 */
194 (my_h_string string, uint index, uint *out_char));
195
196 /**
197 Gets length of specified string expressed as number of bytes.
198
199 @param string String object handle to get length of.
200 @param [out] out_length Pointer to 32bit value to store length of string to.
201 @return Status of performed operation
202 @retval false success
203 @retval true failure
204 */
206 (my_h_string string, uint *out_length));
207
208 /**
209 Creates an iterator for a specified string to allow iteration through all
210 characters in the string.
211
212 @param string String object handle to get iterator to.
213 @param [out] out_iterator Pointer to string iterator handle to store result
214 object to.
215 @return Status of performed operation
216 @retval false success
217 @retval true failure
218 */
220 (my_h_string string,
221 my_h_string_iterator *out_iterator));
222
223 /**
224 Retrieves character code at current iterator position and advances the
225 iterator.
226
227 @param iter String iterator object handle to advance.
228 @param [out] out_char Pointer to 64bit value to store character to. May be
229 NULL to omit retrieval of character and just advance the iterator.
230 @return Status of performed operation
231 @retval false success
232 @retval true failure
233 */
235 (my_h_string_iterator iter, int *out_char));
236
237 /**
238 Releases the string iterator object specified.
239
240 @param iter String iterator object handle to release.
241 */
243
244 /**
245 Checks if character on current position the iterator points to is an upper
246 case.
247
248 @param iter String iterator object handle to advance.
249 @param [out] out Pointer to bool value to store if character is an upper
250 case.
251 @return Status of performed operation
252 @retval false success
253 @retval true failure
254 */
255 static DEFINE_BOOL_METHOD(is_upper, (my_h_string_iterator iter, bool *out));
256
257 /**
258 Checks if character on current position the iterator points to is a lower
259 case.
260
261 @param iter String iterator object handle to advance.
262 @param [out] out Pointer to bool value to store if character is a lower
263 case.
264 @return Status of performed operation
265 @retval false success
266 @retval true failure
267 */
268 static DEFINE_BOOL_METHOD(is_lower, (my_h_string_iterator iter, bool *out));
269
270 /**
271 Checks if character on current position the iterator points to is a digit.
272
273 @param iter String iterator object handle to advance.
274 @param [out] out Pointer to bool value to store if character is a digit.
275 @return Status of performed operation
276 @retval false success
277 @retval true failure
278 */
279 static DEFINE_BOOL_METHOD(is_digit, (my_h_string_iterator iter, bool *out));
280
282
284
286 (my_h_string s1, my_h_string s2, int *cmp));
287
289 (my_h_string s, const char **buffer_pointer,
290 size_t *buffer_length,
291 CHARSET_INFO_h *buffer_charset));
292};
293#endif /* MYSQL_SERVER_STRING_SERVICE_H */
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
Definition: item_cmpfunc.h:1624
The string functions as a service to the mysql_server component.
Definition: mysql_string_service_imp.h:54
static mysql_service_status_t convert_to_buffer_v2(my_h_string src_string, char *dest_buffer, uint64 dest_length, CHARSET_INFO_h dest_charset) noexcept
Definition: mysql_string_service.cc:197
static mysql_service_status_t get_byte_length(my_h_string string, uint *out_length) noexcept
Gets length of specified string expressed as number of bytes.
Definition: mysql_string_service.cc:279
static mysql_service_status_t convert_from_buffer_v2(my_h_string dest_string, const char *src_buffer, uint64 src_length, CHARSET_INFO_h src_charset) noexcept
Definition: mysql_string_service.cc:178
static void destroy(my_h_string string) noexcept
Destroys specified string object and data contained by it.
Definition: mysql_string_service.cc:218
static mysql_service_status_t create(my_h_string *out_string) noexcept
Creates a new instance of string object.
Definition: mysql_string_service.cc:71
static mysql_service_status_t is_lower(my_h_string_iterator iter, bool *out) noexcept
Checks if character on current position the iterator points to is a lower case.
Definition: mysql_string_service.cc:361
static CHARSET_INFO_h get_charset_utf8mb4() noexcept
Definition: mysql_string_service.cc:61
static mysql_service_status_t tolower(my_h_string *out_string, my_h_string in_string) noexcept
Convert a String pointed by handle to lower case.
Definition: mysql_string_service.cc:83
static mysql_service_status_t is_digit(my_h_string_iterator iter, bool *out) noexcept
Checks if character on current position the iterator points to is a digit.
Definition: mysql_string_service.cc:374
static mysql_service_status_t convert_from_buffer(my_h_string *out_string, const char *in_buffer, uint64 length, const char *charset_name) noexcept
Allocates a string object and converts the character buffer to string and just sets the specified cha...
Definition: mysql_string_service.cc:136
static mysql_service_status_t is_upper(my_h_string_iterator iter, bool *out) noexcept
Checks if character on current position the iterator points to is an upper case.
Definition: mysql_string_service.cc:348
static mysql_service_status_t get_data(my_h_string s, const char **buffer_pointer, size_t *buffer_length, CHARSET_INFO_h *buffer_charset) noexcept
Definition: mysql_string_service.cc:431
static mysql_service_status_t iterator_create(my_h_string string, my_h_string_iterator *out_iterator) noexcept
Creates an iterator for a specified string to allow iteration through all characters in the string.
Definition: mysql_string_service.cc:292
static mysql_service_status_t convert_to_buffer(my_h_string in_string, char *out_buffer, uint64 length, const char *charset_name) noexcept
Converts the mysql_string to the character set specified by charset_name parameter.
Definition: mysql_string_service.cc:156
static mysql_service_status_t iterator_get_next(my_h_string_iterator iter, int *out_char) noexcept
Retrieves character code at current iterator position and advances the iterator.
Definition: mysql_string_service.cc:311
static void iterator_destroy(my_h_string_iterator iter) noexcept
Releases the string iterator object specified.
Definition: mysql_string_service.cc:338
static mysql_service_status_t get_char(my_h_string string, uint index, ulong *out_char) noexcept
Gets character code of character on specified index position in string to a specified buffer.
Definition: mysql_string_service.cc:230
static mysql_service_status_t get_byte(my_h_string string, uint index, uint *out_char) noexcept
Gets byte code of string at specified index position to a specified 32-bit buffer.
Definition: mysql_string_service.cc:263
static mysql_service_status_t compare(my_h_string s1, my_h_string s2, int *cmp) noexcept
Definition: mysql_string_service.cc:413
static mysql_service_status_t get_char_length(my_h_string string, uint *out_length) noexcept
Gets length of specified string expressed as number of characters.
Definition: mysql_string_service.cc:250
static mysql_service_status_t reset(my_h_string s) noexcept
Definition: mysql_string_service.cc:386
static mysql_service_status_t toupper(my_h_string *out_string, my_h_string in_string) noexcept
Convert a String pointed by handle to upper case.
Definition: mysql_string_service.cc:108
static CHARSET_INFO_h get_charset_by_name(const char *name) noexcept
Definition: mysql_string_service.cc:66
static mysql_service_status_t append(my_h_string s1, my_h_string s2) noexcept
Definition: mysql_string_service.cc:398
Specifies macros to define Components.
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1064
uint64_t uint64
Definition: my_inttypes.h:68
struct CHARSET_INFO_h_imp * CHARSET_INFO_h
Definition: mysql_string.h:30
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:87
#define DEFINE_METHOD(retval, name, args)
A macro to ensure method implementation has required properties, that is it does not throw exceptions...
Definition: service_implementation.h:78
case opt name
Definition: sslopt-case.h:32
The string functions as a service to the mysql_server component.
Definition: mysql_string_service.cc:45
Definition: mysql_string_service.cc:47
mysql_string_itrerator structure to provide service to components
Definition: mysql_string_service_imp.h:41
const char * iterator_ptr
Definition: mysql_string_service_imp.h:43
String * iterator_str
Definition: mysql_string_service_imp.h:42
int ctype
Definition: mysql_string_service_imp.h:44
unsigned int uint
Definition: uca-dump.cc:29