MySQL 8.4.0
Source Code Documentation
mysql_string_service_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2024, 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 designed to work 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 either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_SERVER_STRING_SERVICE_H
25#define MYSQL_SERVER_STRING_SERVICE_H
26
30
31/*
32 This header file is used in mysql_server component, which is not
33 server-enabled, and can't have following declaration acquired by including
34 mysql headers.
35*/
36
37class String;
38
39/**
40 The string functions as a service to the mysql_server component.
41 So, that by default this service is available to all the components
42 register to the server.
43 successful invocations of the underlying String Service Implementation
44 methods.
45*/
47 public: /* service implementations */
48 /* mysql_charset service. */
49
51
53
54 /**
55 Creates a new instance of string object
56
57 @param out_string holds pointer to newly created string object.
58 @return Status of performed operation
59 @retval false success
60 @retval true failure
61 */
62 static DEFINE_BOOL_METHOD(create, (my_h_string * out_string));
63
64 /**
65 Destroys specified string object and data contained by it.
66
67 @param string String object handle to release.
68 */
69 static DEFINE_METHOD(void, destroy, (my_h_string string));
70
71 /**
72 Convert a String pointed by handle to lower case. Conversion depends on the
73 client character set info
74
75 @param out_string Holds the converted lower case string object.
76 @param in_string Pointer to string object to be converted.
77 @return Status of performed operation
78 @retval false success
79 @retval true failure
80 */
82 (my_h_string * out_string, my_h_string in_string));
83
84 /**
85 Convert a String pointed by handle to upper case. Conversion depends on the
86 client character set info
87
88 @param out_string Holds the converted upper case string object.
89 @param in_string Pointer to string object to be converted.
90 @return Status of performed operation
91 @retval false success
92 @retval true failure
93 */
95 (my_h_string * out_string, my_h_string in_string));
96
97 /* mysql_string_converter service. */
98
99 /**
100 Allocates a string object and converts the character buffer to string
101 and just sets the specified charset_name in the string object. It does
102 not performs the conversion of buffer into the specified character set.
103 Caller must free the allocated string by calling destroy() api.
104
105 @param [out] out_string Pointer to string object handle to set new string
106 to.
107 @param in_buffer Pointer to the buffer with data to be interpreted as
108 string.
109 @param length Length of the buffer to copy into string, in bytes, not in
110 character count.
111 @param charset_name charset that is used for conversion.
112 @return Status of performed operation
113 @retval false success
114 @retval true failure
115 */
117 (my_h_string * out_string, const char *in_buffer,
118 uint64 length, const char *charset_name));
119
120 /**
121 Converts the mysql_string to the character set specified by
122 charset_name parameter.
123
124 @param in_string Pointer to string object handle to set new string
125 to.
126 @param [out] out_buffer Pointer to the buffer with data to be interpreted
127 as characters.
128 @param length Length of the buffer to hold out put in characters.
129 @param charset_name charset that is used for conversion.
130 @return Status of performed operation
131 @retval false success
132 @retval true failure
133 */
135 (my_h_string in_string, char *out_buffer,
136 uint64 length, const char *charset_name));
137
138 /* mysql_string_converter_v2 service. */
139
141 (my_h_string dest_string, const char *src_buffer,
142 uint64 src_length, CHARSET_INFO_h src_charset));
143
145 (my_h_string src_string, char *dest_buffer,
146 uint64 dest_length, CHARSET_INFO_h dest_charset));
147
148 /**
149 Gets character code of character on specified index position in
150 string to a specified buffer.
151
152 @param string String object handle to get character from.
153 @param index Index, position of character to query.
154 @param [out] out_char Pointer to unsigned long value to store character to.
155 @return Status of performed operation
156 @retval false success
157 @retval true failure
158 */
160 (my_h_string string, uint index, ulong *out_char));
161
162 /**
163 Gets length of specified string expressed as number of characters.
164
165 @param string String object handle to get length of.
166 @param [out] out_length Pointer to 64bit value to store length of string to.
167 @return Status of performed operation
168 @retval false success
169 @retval true failure
170 */
172 (my_h_string string, uint *out_length));
173
174 /**
175 Gets byte code of string at specified index position to a
176 specified 32-bit buffer.
177
178 @param string String object handle to get character from.
179 @param index Index, position of character to query.
180 @param [out] out_char Pointer to 32bit value to store byte to.
181 @return Status of performed operation
182 @retval false success
183 @retval true failure
184 */
186 (my_h_string string, uint index, uint *out_char));
187
188 /**
189 Gets length of specified string expressed as number of bytes.
190
191 @param string String object handle to get length of.
192 @param [out] out_length Pointer to 32bit value to store length of string to.
193 @return Status of performed operation
194 @retval false success
195 @retval true failure
196 */
198 (my_h_string string, uint *out_length));
199
200 /**
201 Creates an iterator for a specified string to allow iteration through all
202 characters in the string.
203
204 @param string String object handle to get iterator to.
205 @param [out] out_iterator Pointer to string iterator handle to store result
206 object to.
207 @return Status of performed operation
208 @retval false success
209 @retval true failure
210 */
212 (my_h_string string,
213 my_h_string_iterator *out_iterator));
214
215 /**
216 Retrieves character code at current iterator position and advances the
217 iterator.
218
219 @param iter String iterator object handle to advance.
220 @param [out] out_char Pointer to 64bit value to store character to. May be
221 NULL to omit retrieval of character and just advance the iterator.
222 @return Status of performed operation
223 @retval false success
224 @retval true failure
225 */
227 (my_h_string_iterator iter, int *out_char));
228
229 /**
230 Releases the string iterator object specified.
231
232 @param iter String iterator object handle to release.
233 */
235
236 /**
237 Checks if character on current position the iterator points to is an upper
238 case.
239
240 @param iter String iterator object handle to advance.
241 @param [out] out Pointer to bool value to store if character is an upper
242 case.
243 @return Status of performed operation
244 @retval false success
245 @retval true failure
246 */
247 static DEFINE_BOOL_METHOD(is_upper, (my_h_string_iterator iter, bool *out));
248
249 /**
250 Checks if character on current position the iterator points to is a lower
251 case.
252
253 @param iter String iterator object handle to advance.
254 @param [out] out Pointer to bool value to store if character is a lower
255 case.
256 @return Status of performed operation
257 @retval false success
258 @retval true failure
259 */
260 static DEFINE_BOOL_METHOD(is_lower, (my_h_string_iterator iter, bool *out));
261
262 /**
263 Checks if character on current position the iterator points to is a digit.
264
265 @param iter String iterator object handle to advance.
266 @param [out] out Pointer to bool value to store if character is a digit.
267 @return Status of performed operation
268 @retval false success
269 @retval true failure
270 */
271 static DEFINE_BOOL_METHOD(is_digit, (my_h_string_iterator iter, bool *out));
272
273 /**
274 Retrieves character value at current iterator position
275
276 @param iter String iterator object handle
277 @param [out] out Pointer to long value to store character to
278
279 @return Status of performed operation
280 @retval false success
281 @retval true failure
282 */
283 static DEFINE_BOOL_METHOD(get, (my_h_string_iterator iter, ulong *out));
284
286
288
289 /**
290 Allocates a string object and sets it value as substring of the input
291 string. Caller must free the allocated string by calling destroy().
292
293 @param [in] in_string String handle to extract substring from.
294 @param [in] offset Character offset of the substring.
295 @param [in] count Number of characters of the substring.
296 @param [out] out_string Pointer to string handle holding the created result
297 string.
298 @return Status of performed operation
299 @retval false success
300 @retval true failure
301 */
302 static DEFINE_BOOL_METHOD(substr, (my_h_string in_string, uint offset,
303 uint count, my_h_string *out_string));
304
306 (my_h_string s1, my_h_string s2, int *cmp));
307
309 (my_h_string s, const char **buffer_pointer,
310 size_t *buffer_length,
311 CHARSET_INFO_h *buffer_charset));
312};
313#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:167
Definition: item_cmpfunc.h:1664
The string functions as a service to the mysql_server component.
Definition: mysql_string_service_imp.h:46
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:219
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:302
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:200
static void destroy(my_h_string string) noexcept
Destroys specified string object and data contained by it.
Definition: mysql_string_service.cc:241
static mysql_service_status_t create(my_h_string *out_string) noexcept
Creates a new instance of string object.
Definition: mysql_string_service.cc:86
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:390
static CHARSET_INFO_h get_charset_utf8mb4() noexcept
Definition: mysql_string_service.cc:76
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:98
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:403
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:151
static mysql_service_status_t get(my_h_string_iterator iter, ulong *out) noexcept
Retrieves character value at current iterator position.
Definition: mysql_string_service.cc:416
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:377
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:492
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:315
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:172
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:334
static void iterator_destroy(my_h_string_iterator iter) noexcept
Releases the string iterator object specified.
Definition: mysql_string_service.cc:367
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:253
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:286
static mysql_service_status_t compare(my_h_string s1, my_h_string s2, int *cmp) noexcept
Definition: mysql_string_service.cc:474
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:273
static mysql_service_status_t reset(my_h_string s) noexcept
Definition: mysql_string_service.cc:429
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:123
static CHARSET_INFO_h get_charset_by_name(const char *name) noexcept
Definition: mysql_string_service.cc:81
static mysql_service_status_t substr(my_h_string in_string, uint offset, uint count, my_h_string *out_string) noexcept
Allocates a string object and sets it value as substring of the input string.
Definition: mysql_string_service.cc:457
static mysql_service_status_t append(my_h_string s1, my_h_string s2) noexcept
Definition: mysql_string_service.cc:441
Specifies macros to define Components.
static int cmp(Bigint *a, Bigint *b)
Definition: dtoa.cc:1060
uint64_t uint64
Definition: my_inttypes.h:69
static int count
Definition: myisam_ftdump.cc:45
struct CHARSET_INFO_h_imp * CHARSET_INFO_h
Definition: mysql_string.h:41
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:76
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:88
#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:79
case opt name
Definition: sslopt-case.h:29
Definition: mysql_string_service.cc:60
Definition: mysql_string_service.cc:62