MySQL  8.0.18
Source Code Documentation
mysql_string_service.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
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 MYSQL_SERVER_STRING_SERVICE_H
24 #define MYSQL_SERVER_STRING_SERVICE_H
25 
28 
29 #include "sql_string.h"
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 
37 /**
38  mysql_string_itrerator structure to provide service to components
39 */
42  const char *iterator_ptr;
43  int ctype;
44 };
45 
47 
48 /**
49  The string functions as a service to the mysql_server component.
50  So, that by default this service is available to all the components
51  register to the server.
52  successful invocations of the underlying String Service Implementation
53  methods.
54 */
56  public: /* service implementations */
57  /**
58  Creates a new instance of string object
59 
60  @param out_string holds pointer to newly created string object.
61  @return Status of performed operation
62  @retval false success
63  @retval true failure
64  */
66 
67  /**
68  Destroys specified string object and data contained by it.
69 
70  @param string String object handle to release.
71  @return Status of performed operation
72  @retval false success
73  @retval true failure
74  */
75  static DEFINE_METHOD(void, destroy, (my_h_string string));
76 
77  /**
78  Convert a String pointed by handle to lower case. Conversion depends on the
79  client character set info
80 
81  @param out_string Holds the converted lower case string object.
82  @param in_string Pointer to string object to be converted.
83  @return Status of performed operation
84  @retval false success
85  @retval true failure
86  */
89 
90  /**
91  Convert a String pointed by handle to upper case. Conversion depends on the
92  client character set info
93 
94  @param out_string Holds the converted upper case string object.
95  @param in_string Pointer to string object to be converted.
96  @return Status of performed operation
97  @retval false success
98  @retval true failure
99  */
102 
103  /**
104  alocates a string object and converts the character buffer to string
105  of specified charset_name.
106  please call destroy() api to free the allocated string after this api.
107 
108  @param [out] out_string Pointer to string object handle to set new string
109  to.
110  @param in_buffer Pointer to the buffer with data to be interpreted as
111  string.
112  @param length Length of the buffer to copy into string, in bytes, not in
113  character count.
114  @param charset_name charset that is used for convertion.
115  @return Status of performed operation
116  @retval false success
117  @retval true failure
118  */
120  (my_h_string * out_string, const char *in_buffer,
121  uint64 length, const char *charset_name));
122 
123  /**
124  converts the mysql_string to the character set specified by
125  charset_name parameter.
126 
127  @param in_string Pointer to string object handle to set new string
128  to.
129  @param [out] out_buffer Pointer to the buffer with data to be interpreted
130  as characters.
131  @param length Length of the buffer to hold out put in characters.
132  @param charset_name charset that is used for convertion.
133  @return Status of performed operation
134  @retval false success
135  @retval true failure
136  */
138  (my_h_string in_string, char *out_buffer,
139  uint64 length, const char *charset_name));
140 
141  /**
142  Gets character code of character on specified index position in
143  string to a specified buffer.
144 
145  @param string String object handle to get character from.
146  @param index Index, position of character to query.
147  @param [out] out_char Pointer to unsinged long value to store character to.
148  @return Status of performed operation
149  @retval false success
150  @retval true failure
151  */
153  (my_h_string string, uint index, ulong *out_char));
154 
155  /**
156  Gets length of specified string expressed as number of characters.
157 
158  @param string String object handle to get length of.
159  @param [out] out_length Pointer to 64bit value to store length of string to.
160  @return Status of performed operation
161  @retval false success
162  @retval true failure
163  */
165  (my_h_string string, uint *out_length));
166 
167  /**
168  Gets byte code of string at specified index position to a
169  specified 32-bit buffer.
170 
171  @param string String object handle to get character from.
172  @param index Index, position of character to query.
173  @param [out] out_char Pointer to 32bit value to store byte to.
174  @return Status of performed operation
175  @retval false success
176  @retval true failure
177  */
179  (my_h_string string, uint index, uint *out_char));
180 
181  /**
182  Gets length of specified string expressed as number of bytes.
183 
184  @param string String object handle to get length of.
185  @param [out] out_length Pointer to 32bit value to store length of string to.
186  @return Status of performed operation
187  @retval false success
188  @retval true failure
189  */
191  (my_h_string string, uint *out_length));
192 
193  /**
194  Creates an iterator for a specified string to allow iteration through all
195  characters in the string.
196 
197  @param string String object handle to get iterator to.
198  @param [out] out_iterator Pointer to string iterator handle to store result
199  object to.
200  @return Status of performed operation
201  @retval false success
202  @retval true failure
203  */
205  (my_h_string string,
206  my_h_string_iterator *out_iterator));
207 
208  /**
209  Retrieves character code at current iterator position and advances the
210  iterator.
211 
212  @param iter String iterator object handle to advance.
213  @param [out] out_char Pointer to 64bit value to store character to. May be
214  NULL to omit retrieval of character and just advance the iterator.
215  @return Status of performed operation
216  @retval false success
217  @retval true failure
218  */
220  (my_h_string_iterator iter, int *out_char));
221 
222  /**
223  Releases the string iterator object specified.
224 
225  @param iter String iterator object handle te release.
226  @return Status of performed operation
227  @retval false success
228  @retval true failure
229  */
231 
232  /**
233  Checks if character on current position the iterator points to is an upper
234  case.
235 
236  @param iter String iterator object handle to advance.
237  @param [out] out Pointer to bool value to store if character is an upper
238  case.
239  @return Status of performed operation
240  @retval false success
241  @retval true failure
242  */
243  static DEFINE_BOOL_METHOD(is_upper, (my_h_string_iterator iter, bool *out));
244 
245  /**
246  Checks if character on current position the iterator points to is a lower
247  case.
248 
249  @param iter String iterator object handle to advance.
250  @param [out] out Pointer to bool value to store if character is a lower
251  case.
252  @return Status of performed operation
253  @retval false success
254  @retval true failure
255  */
256  static DEFINE_BOOL_METHOD(is_lower, (my_h_string_iterator iter, bool *out));
257 
258  /**
259  Checks if character on current position the iterator points to is a digit.
260 
261  @param iter String iterator object handle to advance.
262  @param [out] out Pointer to bool value to store if character is a digit.
263  @return Status of performed operation
264  @retval false success
265  @retval true failure
266  */
267  static DEFINE_BOOL_METHOD(is_digit, (my_h_string_iterator iter, bool *out));
268 };
269 #endif /* MYSQL_SERVER_STRING_SERVICE_H */
Our own string classes, used pervasively throughout the executor.
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:434
#define DEFINE_BOOL_METHOD(name, args)
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:324
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:122
int ctype
Definition: mysql_string_service.h:43
Definition: item_cmpfunc.h:1469
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:161
#define DEFINE_METHOD(retval, name, args)
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:348
mysql_string_itrerator structure to provide service to components
Definition: mysql_string_service.h:40
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:87
static void iterator_destroy(my_h_string_iterator iter) noexcept
Releases the string iterator object specified.
Definition: mysql_string_service.cc:413
static mysql_service_status_t create(my_h_string *out_string) noexcept
Creates a new instance of string object.
Definition: mysql_string_service.cc:65
char * index(const char *, int c)
Definition: mysql.cc:2862
static void out_string(conn *c, const char *str)
Definition: memcached.c:1042
static mysql_service_status_t convert_from_buffer(my_h_string *out_string, const char *in_buffer, uint64 length, const char *charset_name) noexcept
alocates a string object and converts the character buffer to string of specified charset_name...
Definition: mysql_string_service.cc:163
const char * iterator_ptr
Definition: mysql_string_service.h:42
The string functions as a service to the mysql_server component.
Definition: mysql_string_service.h:55
unsigned int uint
Definition: uca-dump.cc:29
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:275
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:197
Definition: mysql_string_service.cc:55
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:458
String * iterator_str
Definition: mysql_string_service.h:41
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:480
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:299
static void destroy(my_h_string string) noexcept
Destroys specified string object and data contained by it.
Definition: mysql_string_service.cc:223
Specifies macros to define Service Implementations.
unsigned long ulong
Definition: my_inttypes.h:48
void mysql_string_services_init()
The string functions as a service to the mysql_server component.
Definition: mysql_string_service.cc:51
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
uint64_t uint64
Definition: my_inttypes.h:68
Definition: mysql_string_service.cc:53
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:378
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:246