drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
charset.h
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20/*
21 Header File that defines all the charset declarations being used in Drizzle source code
22*/
23
24#pragma once
25
26#include <sys/types.h>
27#include <cstddef>
28
29#include <drizzled/visibility.h>
30#include <drizzled/common_fwd.h>
32
33namespace drizzled {
34
35#define MY_CS_NAME_SIZE 32
36#define MY_CS_CTYPE_TABLE_SIZE 257
37#define MY_CS_TO_LOWER_TABLE_SIZE 256
38#define MY_CS_TO_UPPER_TABLE_SIZE 256
39#define MY_CS_SORT_ORDER_TABLE_SIZE 256
40#define MY_CS_TO_UNI_TABLE_SIZE 256
41#define CHARSET_DIR "charsets/"
42#define my_wc_t unsigned long
43/* wm_wc and wc_mb return codes */
44#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */
45#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */
46#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */
47#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */
48#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */
49/* These following three are currently not really used */
50#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */
51#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */
52#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */
53#define MY_SEQ_INTTAIL 1
54#define MY_SEQ_SPACES 2
55#define MY_CS_COMPILED 1 /* compiled-in sets */
56#define MY_CS_CONFIG 2 /* sets that have a *.conf file */
57#define MY_CS_INDEX 4 /* sets listed in the Index file */
58#define MY_CS_LOADED 8 /* sets that are currently loaded */
59#define MY_CS_BINSORT 16 /* if binary sort order */
60#define MY_CS_PRIMARY 32 /* if primary collation */
61#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
62#define MY_CS_UNICODE 128 /* is a charset is full unicode */
63#define MY_CS_READY 256 /* if a charset is initialized */
64#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
65#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
66#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
67#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
68#define MY_CHARSET_UNDEFINED 0
69/* Flags for strxfrm */
70#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
71#define MY_STRXFRM_LEVEL2 0x00000002 /* for secondary weights */
72#define MY_STRXFRM_LEVEL3 0x00000004 /* for tertiary weights */
73#define MY_STRXFRM_LEVEL4 0x00000008 /* fourth level weights */
74#define MY_STRXFRM_LEVEL5 0x00000010 /* fifth level weights */
75#define MY_STRXFRM_LEVEL6 0x00000020 /* sixth level weights */
76#define MY_STRXFRM_LEVEL_ALL 0x0000003F /* Bit OR for the above six */
77#define MY_STRXFRM_NLEVELS 6 /* Number of possible levels*/
78#define MY_STRXFRM_PAD_WITH_SPACE 0x00000040 /* if pad result with spaces */
79#define MY_STRXFRM_UNUSED_00000080 0x00000080 /* for future extensions */
80#define MY_STRXFRM_DESC_LEVEL1 0x00000100 /* if desc order for level1 */
81#define MY_STRXFRM_DESC_LEVEL2 0x00000200 /* if desc order for level2 */
82#define MY_STRXFRM_DESC_LEVEL3 0x00000300 /* if desc order for level3 */
83#define MY_STRXFRM_DESC_LEVEL4 0x00000800 /* if desc order for level4 */
84#define MY_STRXFRM_DESC_LEVEL5 0x00001000 /* if desc order for level5 */
85#define MY_STRXFRM_DESC_LEVEL6 0x00002000 /* if desc order for level6 */
86#define MY_STRXFRM_DESC_SHIFT 8
87#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions */
88#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions */
89#define MY_STRXFRM_REVERSE_LEVEL1 0x00010000 /* if reverse order for level1 */
90#define MY_STRXFRM_REVERSE_LEVEL2 0x00020000 /* if reverse order for level2 */
91#define MY_STRXFRM_REVERSE_LEVEL3 0x00040000 /* if reverse order for level3 */
92#define MY_STRXFRM_REVERSE_LEVEL4 0x00080000 /* if reverse order for level4 */
93#define MY_STRXFRM_REVERSE_LEVEL5 0x00100000 /* if reverse order for level5 */
94#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
95#define MY_STRXFRM_REVERSE_SHIFT 16
96#define ILLEGAL_CHARSET_INFO_NUMBER (UINT32_MAX)
97#define MY_UTF8MB4 "utf8"
98#define my_charset_utf8_general_ci ::drizzled::my_charset_utf8mb4_general_ci
99#define my_charset_utf8_bin ::drizzled::my_charset_utf8mb4_bin
100#define _MY_U 01 /* Upper case */
101#define _MY_L 02 /* Lower case */
102#define _MY_NMR 04 /* Numeral (digit) */
103#define _MY_SPC 010 /* Spacing character */
104#define _MY_PNT 020 /* Punctuation */
105#define _MY_CTR 040 /* Control character */
106#define _MY_B 0100 /* Blank */
107#define _MY_X 0200 /* heXadecimal digit */
108
109/* Some typedef to make it easy for C++ to make function pointers */
110typedef int (*my_charset_conv_mb_wc)(const charset_info_st*, my_wc_t *, const unsigned char*, const unsigned char *);
111typedef int (*my_charset_conv_wc_mb)(const charset_info_st*, my_wc_t, unsigned char*, unsigned char *);
112typedef size_t (*my_charset_conv_case)(const charset_info_st*, char*, size_t, char*, size_t);
113
115{
116 uint16_t toupper;
117 uint16_t tolower;
118 uint16_t sort;
119};
120
122{
123 unsigned char pctype;
124 unsigned char* ctype;
125};
126
128{
129 uint16_t from;
130 uint16_t to;
131 unsigned char *tab;
132};
133
135{
136 uint32_t beg;
137 uint32_t end;
138 uint32_t mb_len;
139};
140
141enum my_lex_states
142{
143 MY_LEX_START, MY_LEX_CHAR, MY_LEX_IDENT,
144 MY_LEX_IDENT_SEP, MY_LEX_IDENT_START,
145 MY_LEX_REAL, MY_LEX_HEX_NUMBER, MY_LEX_BIN_NUMBER,
146 MY_LEX_CMP_OP, MY_LEX_LONG_CMP_OP, MY_LEX_STRING, MY_LEX_COMMENT, MY_LEX_END,
147 MY_LEX_OPERATOR_OR_IDENT, MY_LEX_NUMBER_IDENT, MY_LEX_INT_OR_REAL,
148 MY_LEX_REAL_OR_POINT, MY_LEX_BOOL, MY_LEX_EOL, MY_LEX_ESCAPE,
149 MY_LEX_LONG_COMMENT, MY_LEX_END_LONG_COMMENT, MY_LEX_SEMICOLON,
150 MY_LEX_SET_VAR, MY_LEX_USER_END, MY_LEX_HOSTNAME, MY_LEX_SKIP,
151 MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
152 MY_LEX_IDENT_OR_KEYWORD,
153 MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN,
154 MY_LEX_STRING_OR_DELIMITER
155};
156
157/* See strings/charset_info_st.txt for information about this structure */
159{
160 bool (*init)(charset_info_st&, unsigned char *(*alloc)(size_t));
161 /* Collation routines */
162 int (*strnncoll)(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool);
163 int (*strnncollsp)(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool diff_if_only_endspace_difference);
164 size_t (*strnxfrm)(const charset_info_st*, unsigned char *dst, size_t dstlen, uint32_t nweights, const unsigned char *src, size_t srclen, uint32_t flags);
165 size_t (*strnxfrmlen)(const charset_info_st*, size_t);
166 bool (*like_range)(const charset_info_st*, const char *s, size_t s_length, char escape, char w_one, char w_many,
167 size_t res_length, char *min_str, char *max_str, size_t *min_len, size_t *max_len);
168 int (*wildcmp)(const charset_info_st*, const char *str,const char *str_end, const char *wildstr, const char *wildend, int escape,int w_one, int w_many);
169
170 int (*strcasecmp)(const charset_info_st*, const char*, const char *);
171
172 uint32_t (*instr)(const charset_info_st*, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, uint32_t nmatch);
173
174 /* Hash calculation */
175 void (*hash_sort)(const charset_info_st*, const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
176 bool (*propagate)();
177};
178
179/* See strings/charset_info_st.txt about information on this structure */
181{
182 /* Multibyte routines */
183 uint32_t (*ismbchar)(const charset_info_st*, const char*, const char *);
184 uint32_t (*mbcharlen)(const charset_info_st*, uint32_t c);
185 size_t (*numchars)(const charset_info_st*, const char *b, const char *e);
186 size_t (*charpos)(const charset_info_st*, const char *b, const char *e, size_t pos);
187 size_t (*well_formed_len)(const charset_info_st&, str_ref, size_t nchars, int *error);
188 size_t (*lengthsp)(const charset_info_st*, const char *ptr, size_t length);
189 size_t (*numcells)(const charset_info_st*, const char *b, const char *e);
190
191 /* Unicode conversion */
192 my_charset_conv_mb_wc mb_wc;
193 my_charset_conv_wc_mb wc_mb;
194
195 /* CTYPE scanner */
196 int (*ctype)(const charset_info_st *cs, int *ctype, const unsigned char *s, const unsigned char *e);
197
198 /* Functions for case and sort conversion */
199 size_t (*caseup_str)(const charset_info_st*, char *);
200 size_t (*casedn_str)(const charset_info_st*, char *);
201
202 my_charset_conv_case caseup;
203 my_charset_conv_case casedn;
204
205 /* Charset dependant snprintf() */
206 size_t (*snprintf)(const charset_info_st*, char *to, size_t n, const char *fmt, ...)
207 __attribute__((format(printf, 4, 5)));
208 size_t (*long10_to_str)(const charset_info_st*, char *to, size_t n, int radix, long int val);
209 size_t (*int64_t10_to_str)(const charset_info_st*, char *to, size_t n, int radix, int64_t val);
210
211 void (*fill)(const charset_info_st*, char *to, size_t len, int fill);
212
213 /* String-to-number conversion routines */
214 long (*strntol)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
215 unsigned long (*strntoul)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
216 int64_t (*strntoll)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
217 uint64_t (*strntoull)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
218 double (*strntod)(const charset_info_st*, char *s, size_t l, char **e, int *err);
219 int64_t (*strtoll10)(const charset_info_st*, const char *nptr, char **endptr, int *error);
220 uint64_t (*strntoull10rnd)(const charset_info_st*, const char *str, size_t length, int unsigned_fl, char **endptr, int *error);
221 size_t (*scan)(const charset_info_st*, const char *b, const char *e, int sq);
222};
223
224/* See strings/charset_info_st.txt about information on this structure */
226{
227 uint32_t number;
228 uint32_t primary_number;
229 uint32_t binary_number;
230 uint32_t state;
231 const char *csname;
232 const char *name;
233 const char *comment;
234 const char *tailoring;
235 unsigned char *ctype;
236 unsigned char *to_lower;
237 unsigned char *to_upper;
238 unsigned char *sort_order;
239 uint16_t *contractions;
240 uint16_t **sort_order_big;
241 uint16_t *tab_to_uni;
242 MY_UNI_IDX *tab_from_uni;
243 MY_UNICASE_INFO **caseinfo;
244 unsigned char *state_map;
245 unsigned char *ident_map;
246 uint32_t strxfrm_multiply;
247 unsigned char caseup_multiply;
248 unsigned char casedn_multiply;
249 uint32_t mbminlen;
250 uint32_t mbmaxlen;
251 uint16_t min_sort_char;
252 uint16_t max_sort_char; /* For LIKE optimization */
253 unsigned char pad_char;
254 unsigned char levels_for_compare;
255 unsigned char levels_for_order;
256
257 MY_CHARSET_HANDLER *cset;
259
260 bool isalpha(unsigned char c) const
261 {
262 return ctype[c + 1] & (_MY_U | _MY_L);
263 }
264
265 bool isupper(unsigned char c) const
266 {
267 return ctype[c + 1] & _MY_U;
268 }
269
270 bool islower(unsigned char c) const
271 {
272 return ctype[c + 1] & _MY_L;
273 }
274
275 bool isdigit(unsigned char c) const
276 {
277 return ctype[c + 1] & _MY_NMR;
278 }
279
280 bool isxdigit(unsigned char c) const
281 {
282 return ctype[c + 1] & _MY_X;
283 }
284
285 bool isalnum(unsigned char c) const
286 {
287 return ctype[c + 1] & (_MY_U | _MY_L | _MY_NMR);
288 }
289
290 bool isspace(unsigned char c) const
291 {
292 return ctype[c + 1] & _MY_SPC;
293 }
294
295 bool ispunct(unsigned char c) const
296 {
297 return ctype[c + 1] & _MY_PNT;
298 }
299
300 bool isprint(unsigned char c) const
301 {
302 return ctype[c + 1] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B);
303 }
304
305 bool isgraph(unsigned char c) const
306 {
307 return ctype[c + 1] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR);
308 }
309
310 bool iscntrl(unsigned char c) const
311 {
312 return ctype[c + 1] & _MY_CTR;
313 }
314
315 bool isvar(char c) const
316 {
317 return isalnum(c) || (c) == '_';
318 }
319
320 char toupper(unsigned char c) const
321 {
322 return to_upper[c];
323 }
324
325 char tolower(unsigned char c) const
326 {
327 return to_lower[c];
328 }
329
330 bool binary_compare() const
331 {
332 return state & MY_CS_BINSORT;
333 }
334
335 bool use_strnxfrm() const
336 {
337 return state & MY_CS_STRNXFRM;
338 }
339
340 size_t strnxfrm(unsigned char *dst, const size_t dstlen, const unsigned char *src, const uint32_t srclen) const
341 {
342 return coll->strnxfrm(this, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE);
343 }
344
345 int strcasecmp(const char *s, const char *t) const
346 {
347 return coll->strcasecmp(this, s, t);
348 }
349
350 size_t caseup_str(char* src) const
351 {
352 return cset->caseup_str(this, src);
353 }
354
355 size_t casedn_str(char* src) const
356 {
357 return cset->casedn_str(this, src);
358 }
359};
360
361extern DRIZZLED_API charset_info_st *all_charsets[256];
362uint32_t get_charset_number(const char *cs_name, uint32_t cs_flags);
363uint32_t get_collation_number(const char *name);
364const char *get_charset_name(uint32_t cs_number);
365void free_charsets();
366bool my_charset_same(const charset_info_st*, const charset_info_st*);
367size_t escape_string_for_drizzle(const charset_info_st *charset_info, char *to, size_t to_length, const char *from, size_t length);
368size_t escape_quotes_for_drizzle(const charset_info_st *charset_info, char *to, size_t to_length, const char *from, size_t length);
369extern DRIZZLED_API const charset_info_st *default_charset_info;
370extern DRIZZLED_API const charset_info_st *system_charset_info;
371extern const charset_info_st *files_charset_info;
372extern const charset_info_st *table_alias_charset;
373extern MY_UNICASE_INFO *my_unicase_default[256];
374extern MY_UNICASE_INFO *my_unicase_turkish[256];
375extern MY_UNI_CTYPE my_uni_ctype[256];
376extern DRIZZLED_API charset_info_st my_charset_bin;
377extern DRIZZLED_API charset_info_st my_charset_utf8mb4_bin;
378extern DRIZZLED_API charset_info_st my_charset_utf8mb4_general_ci;
379extern DRIZZLED_API charset_info_st my_charset_utf8mb4_unicode_ci;
380size_t my_strnxfrmlen_simple(const charset_info_st*, size_t);
381int my_strnncollsp_simple(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool diff_if_only_endspace_difference);
382size_t my_lengthsp_8bit(const charset_info_st*, const char *ptr, size_t length);
383uint32_t my_instr_simple(const charset_info_st*, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, uint32_t nmatch);
384int my_strcasecmp_mb(const charset_info_st*, const char *s, const char *t);
385
386DRIZZLED_API const charset_info_st *get_charset(uint32_t cs_number);
387DRIZZLED_API const charset_info_st *get_charset_by_name(const char *cs_name);
388DRIZZLED_API const charset_info_st *get_charset_by_csname(const char *cs_name, uint32_t cs_flags);
389
390/* Functions for 8bit */
391int my_mb_ctype_8bit(const charset_info_st*, int*, const unsigned char*, const unsigned char *);
392int my_mb_ctype_mb(const charset_info_st*, int*, const unsigned char*, const unsigned char *);
393
394size_t my_scan_8bit(const charset_info_st*, const char *b, const char *e, int sq);
395size_t my_snprintf_8bit(const charset_info_st*, char *to, size_t n, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
396
397long my_strntol_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
398unsigned long my_strntoul_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
399int64_t my_strntoll_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
400uint64_t my_strntoull_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
401double my_strntod_8bit(const charset_info_st*, char *s, size_t l,char **e, int *err);
402size_t my_long10_to_str_8bit(const charset_info_st*, char *to, size_t l, int radix, long int val);
403size_t my_int64_t10_to_str_8bit(const charset_info_st*, char *to, size_t l, int radix, int64_t val);
404int64_t my_strtoll10_8bit(const charset_info_st*, const char *nptr, char **endptr, int *error);
405
406uint64_t my_strntoull10rnd_8bit(const charset_info_st*, const char *str, size_t length, int unsigned_fl, char **endptr, int *error);
407
408void my_fill_8bit(const charset_info_st*, char* to, size_t l, int fill);
409
410bool my_like_range_simple(const charset_info_st*,
411 const char *ptr, size_t ptr_length,
412 char escape, char w_one, char w_many,
413 size_t res_length,
414 char *min_str, char *max_str,
415 size_t *min_length, size_t *max_length);
416
417bool my_like_range_mb(const charset_info_st*,
418 const char *ptr, size_t ptr_length,
419 char escape, char w_one, char w_many,
420 size_t res_length,
421 char *min_str, char *max_str,
422 size_t *min_length, size_t *max_length);
423
424int my_wildcmp_8bit(const charset_info_st*,
425 const char *str,const char *str_end,
426 const char *wildstr,const char *wildend,
427 int escape, int w_one, int w_many);
428
429int my_wildcmp_bin(const charset_info_st*,
430 const char *str,const char *str_end,
431 const char *wildstr,const char *wildend,
432 int escape, int w_one, int w_many);
433
434size_t my_numchars_8bit(const charset_info_st*, const char *b, const char *e);
435size_t my_numcells_8bit(const charset_info_st*, const char *b, const char *e);
436size_t my_charpos_8bit(const charset_info_st*, const char *b, const char *e, size_t pos);
437size_t my_well_formed_len_8bit(const charset_info_st&, str_ref, size_t pos, int *error);
438typedef unsigned char *(*cs_alloc_func)(size_t);
439bool my_coll_init_simple(charset_info_st *cs, cs_alloc_func alloc);
440bool my_cset_init_8bit(charset_info_st *cs, cs_alloc_func alloc);
441uint32_t my_mbcharlen_8bit(const charset_info_st*, uint32_t c);
442
443/* Functions for multibyte charsets */
444int my_wildcmp_mb(const charset_info_st*,
445 const char *str,const char *str_end,
446 const char *wildstr,const char *wildend,
447 int escape, int w_one, int w_many);
448size_t my_numchars_mb(const charset_info_st*, const char *b, const char *e);
449size_t my_numcells_mb(const charset_info_st*, const char *b, const char *e);
450size_t my_charpos_mb(const charset_info_st*, const char *b, const char *e, size_t pos);
451size_t my_well_formed_len_mb(const charset_info_st&, str_ref, size_t pos, int *error);
452uint32_t my_instr_mb(const charset_info_st*,
453 const char *b, size_t b_length,
454 const char *s, size_t s_length,
455 my_match_t *match, uint32_t nmatch);
456
457int my_strnncoll_mb_bin(const charset_info_st* cs,
458 const unsigned char *s, size_t slen,
459 const unsigned char *t, size_t tlen,
460 bool t_is_prefix);
461
462int my_strnncollsp_mb_bin(const charset_info_st*,
463 const unsigned char *a, size_t a_length,
464 const unsigned char *b, size_t b_length,
465 bool diff_if_only_endspace_difference);
466
467int my_wildcmp_mb_bin(const charset_info_st*,
468 const char *str,const char *str_end,
469 const char *wildstr,const char *wildend,
470 int escape, int w_one, int w_many);
471
472int my_strcasecmp_mb_bin(const charset_info_st*, const char *s, const char *t);
473
474void my_hash_sort_mb_bin(const charset_info_st*,
475 const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
476
477size_t my_strnxfrm_mb(const charset_info_st*,
478 unsigned char *dst, size_t dstlen, uint32_t nweights,
479 const unsigned char *src, size_t srclen, uint32_t flags);
480
482 const char *str, const char *str_end,
483 const char *wildstr, const char *wildend,
484 int escape, int w_one, int w_many,
485 MY_UNICASE_INFO **weights);
486
487bool my_propagate_simple();
488bool my_propagate_complex();
489
490
491uint32_t my_strxfrm_flag_normalize(uint32_t flags, uint32_t nlevels);
492void my_strxfrm_desc_and_reverse(unsigned char *str, unsigned char *strend,
493 uint32_t flags, uint32_t level);
494size_t my_strxfrm_pad_desc_and_reverse(const charset_info_st*,
495 unsigned char *str, unsigned char *frmend, unsigned char *strend,
496 uint32_t nweights, uint32_t flags, uint32_t level);
497
498bool my_charset_is_ascii_compatible(const charset_info_st*);
499
500/*
501 Compare 0-terminated UTF8 strings.
502
503 SYNOPSIS
504 my_strcasecmp_utf8mb3()
505 cs character set handler
506 s First 0-terminated string to compare
507 t Second 0-terminated string to compare
508
509 IMPLEMENTATION
510
511 RETURN
512 - negative number if s < t
513 - positive number if s > t
514 - 0 is the strings are equal
515*/
516int my_wc_mb_filename(const charset_info_st*, my_wc_t wc, unsigned char *s, unsigned char *e);
517int my_mb_wc_filename(const charset_info_st*, my_wc_t *pwc, const unsigned char *s, const unsigned char *e);
518
519int my_strnncoll_8bit_bin(const charset_info_st*,
520 const unsigned char *s, size_t slen,
521 const unsigned char *t, size_t tlen,
522 bool t_is_prefix);
523int my_strnncollsp_8bit_bin(const charset_info_st*,
524 const unsigned char *a, size_t a_length,
525 const unsigned char *b, size_t b_length,
526 bool diff_if_only_endspace_difference);
527size_t my_case_str_bin(const charset_info_st*, char *);
528size_t my_case_bin(const charset_info_st*, char*,
529 size_t srclen, char*, size_t);
530int my_strcasecmp_bin(const charset_info_st*,
531 const char *s, const char *t);
532size_t my_strnxfrm_8bit_bin(const charset_info_st*,
533 unsigned char * dst, size_t dstlen, uint32_t nweights,
534 const unsigned char *src, size_t srclen, uint32_t flags);
535uint32_t my_instr_bin(const charset_info_st*,
536 const char *b, size_t b_length,
537 const char *s, size_t s_length,
538 my_match_t *match, uint32_t nmatch);
539size_t my_lengthsp_binary(const charset_info_st*,
540 const char*, size_t length);
541int my_mb_wc_bin(const charset_info_st*,
542 my_wc_t *wc, const unsigned char *str,
543 const unsigned char *end);
544int my_wc_mb_bin(const charset_info_st*, my_wc_t wc,
545 unsigned char *str, unsigned char *end);
546void my_hash_sort_8bit_bin(const charset_info_st*,
547 const unsigned char *key, size_t len,
548 uint32_t *nr1, uint32_t *nr2);
549bool my_coll_init_8bit_bin(charset_info_st *cs,
550 cs_alloc_func);
551int my_strnncoll_binary(const charset_info_st*,
552 const unsigned char *s, size_t slen,
553 const unsigned char *t, size_t tlen,
554 bool t_is_prefix);
555int my_strnncollsp_binary(const charset_info_st*,
556 const unsigned char *s, size_t slen,
557 const unsigned char *t, size_t tlen,
558 bool);
559
560inline static int my_strnncoll(const charset_info_st *cs,
561 const unsigned char *s,
562 const size_t slen,
563 const unsigned char *t,
564 const size_t tlen)
565{
566 return (cs->coll->strnncoll(cs, s, slen, t, tlen, 0));
567}
568
569inline static bool my_like_range(const charset_info_st *cs,
570 const char *ptr, const size_t ptrlen,
571 const char escape,
572 const char w_one,
573 const char w_many,
574 const size_t reslen,
575 char *minstr, char *maxstr,
576 size_t *minlen, size_t *maxlen)
577{
578 return (cs->coll->like_range(cs, ptr, ptrlen, escape, w_one, w_many, reslen,
579 minstr, maxstr, minlen, maxlen));
580}
581
582inline static int my_wildcmp(const charset_info_st *cs,
583 const char *str, const char *strend,
584 const char *w_str, const char *w_strend,
585 const int escape,
586 const int w_one, const int w_many)
587{
588 return (cs->coll->wildcmp(cs, str, strend, w_str, w_strend, escape, w_one, w_many));
589}
590
591template <typename CHAR_T>
592inline static size_t my_charpos(const charset_info_st *cs,
593 const CHAR_T *b, const CHAR_T* e, size_t num)
594{
595 return cs->cset->charpos(cs, reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(e), num);
596}
597
598inline static bool use_mb(const charset_info_st *cs)
599{
600 return cs->cset->ismbchar != NULL;
601}
602
603inline static unsigned int my_ismbchar(const charset_info_st *cs, const char *a, const char *b)
604{
605 return cs->cset->ismbchar(cs, a, b);
606}
607
608inline static unsigned int my_mbcharlen(const charset_info_st *cs, uint32_t c)
609{
610 return cs->cset->mbcharlen(cs, c);
611}
612
613
614inline static long my_strntol(const charset_info_st *cs,
615 const char* s, const size_t l, const int base, char **e, int *err)
616{
617 return (cs->cset->strntol(cs, s, l, base, e, err));
618}
619
620inline static unsigned long my_strntoul(const charset_info_st *cs,
621 const char* s, const size_t l, const int base,
622 char **e, int *err)
623{
624 return (cs->cset->strntoul(cs, s, l, base, e, err));
625}
626
627inline static int64_t my_strntoll(const charset_info_st *cs,
628 const char* s, const size_t l, const int base, char **e, int *err)
629{
630 return (cs->cset->strntoll(cs, s, l, base, e, err));
631}
632
633inline static int64_t my_strntoull(const charset_info_st *cs,
634 const char* s, const size_t l, const int base,
635 char **e, int *err)
636{
637 return (cs->cset->strntoull(cs, s, l, base, e, err));
638}
639
640
641inline static double my_strntod(const charset_info_st *cs,
642 char* s, const size_t l, char **e, int *err)
643{
644 return (cs->cset->strntod(cs, s, l, e, err));
645}
646
647int make_escape_code(const charset_info_st*, const char *escape);
648
649} /* namespace drizzled */
TODO: Rename this file - func.h is stupid.
int my_wildcmp_unicode(const charset_info_st *, const char *str, const char *str_end, const char *wildstr, const char *wildend, int escape, int w_one, int w_many, MY_UNICASE_INFO **weights)
Visibility Control Macros.
#define DRIZZLED_API
Definition visibility.h:38