MySQL 8.4.4
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
my_char_traits.h
Go to the documentation of this file.
1/* Copyright (c) 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MY_CHAR_TRAITS_INCLUDED
25#define MY_CHAR_TRAITS_INCLUDED
26
27#include <cstring>
28
29template <class CharT>
31
32/*
33 This is a standards-compliant, drop-in replacement for
34 std::char_traits<unsigned char>
35 We need this because clang libc++ is removing support for it in clang 19.
36 It is not a complete implementation. Rather we implement just enough to
37 compile any usage of char_traits<uchar> we have in our codebase.
38 */
39template <>
40struct my_char_traits<unsigned char> {
41 using char_type = unsigned char;
42 using int_type = unsigned int;
43
44 static void assign(char_type &c1, const char_type &c2) { c1 = c2; }
45
46 static char_type *assign(char_type *s, std::size_t n, char_type a) {
47 return static_cast<char_type *>(memset(s, a, n));
48 }
49
50 static int compare(const char_type *s1, const char_type *s2, std::size_t n) {
51 return memcmp(s1, s2, n);
52 }
53
54 static char_type *move(char_type *s1, const char_type *s2, std::size_t n) {
55 if (n == 0) return s1;
56 return static_cast<char_type *>(memmove(s1, s2, n));
57 }
58
59 static char_type *copy(char_type *s1, const char_type *s2, std::size_t n) {
60 if (n == 0) return s1;
61 return static_cast<char_type *>(memcpy(s1, s2, n));
62 }
63};
64
65#endif // MY_CHAR_TRAITS_INCLUDED
static char_type * assign(char_type *s, std::size_t n, char_type a)
Definition: my_char_traits.h:46
static char_type * copy(char_type *s1, const char_type *s2, std::size_t n)
Definition: my_char_traits.h:59
static char_type * move(char_type *s1, const char_type *s2, std::size_t n)
Definition: my_char_traits.h:54
static int compare(const char_type *s1, const char_type *s2, std::size_t n)
Definition: my_char_traits.h:50
unsigned char char_type
Definition: my_char_traits.h:41
unsigned int int_type
Definition: my_char_traits.h:42
static void assign(char_type &c1, const char_type &c2)
Definition: my_char_traits.h:44
Definition: my_char_traits.h:30
int n
Definition: xcom_base.cc:509