MySQL 8.4.3
Source Code Documentation
string_type.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 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 DD__STRING_TYPE
25#define DD__STRING_TYPE
26
27#include <stddef.h>
28#include <sstream>
29#include <string>
30#include <system_error>
31
32#include "sql/stateless_allocator.h" // Stateless_allocator
33
34namespace dd {
35/**
36 Functor class which allocates memory for String_type. Implementation
37 uses my_malloc with key_memory_DD_String_type.
38*/
40 void *operator()(size_t s) const;
41};
42
44
45/**
46 Template alias for char-based std::basic_string.
47*/
48template <class A>
49using Char_string_template = std::basic_string<char, std::char_traits<char>, A>;
50
52
53/**
54 Template alias for char-based std::basic_stringstream.
55 */
56template <class A>
58 std::basic_stringstream<char, std::char_traits<char>, A>;
59
60/**
61 Instantiation of std::basic_stringstream with the same allocator as
62 String_type. This is needed since a std::basic_stringstream::str()
63 returns a basic_string allocated with its own allocator. Note that
64 this also means that it is difficult to use a different PSI key for
65 the stream memory as that would mean the return type of
66 Stringstream_type::str() would be different and incompatible with
67 String_type.
68
69 To work around this would require the creation of a temporary
70 String_type from the string returned from stringstream::str().
71*/
73
74template <typename LEX_STRING_TYPE>
75String_type make_string_type(const LEX_STRING_TYPE &lst) {
76 return {lst.str, lst.length};
77}
78} // namespace dd
79
80namespace std {
81
82/**
83 Specialize std::hash for dd::String_type so that it can be
84 used with unordered_ containers. Uses our standard murmur3_32
85 implementation, and the same suitability restrictions apply.
86 @see murmur3_32
87*/
88template <>
89struct hash<dd::String_type> {
91 typedef size_t result_type;
92
93 size_t operator()(const dd::String_type &s) const;
94};
95} // namespace std
96#endif /* DD__STRING_TYPE */
Stateless_allocator is a C++ STL memory allocator skeleton based on Malloc_allocator,...
Definition: stateless_allocator.h:92
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
std::basic_string< char, std::char_traits< char >, A > Char_string_template
Template alias for char-based std::basic_string.
Definition: string_type.h:49
String_type make_string_type(const LEX_STRING_TYPE &lst)
Definition: string_type.h:75
Char_stringstream_template< String_type_allocator > Stringstream_type
Instantiation of std::basic_stringstream with the same allocator as String_type.
Definition: string_type.h:72
std::basic_stringstream< char, std::char_traits< char >, A > Char_stringstream_template
Template alias for char-based std::basic_stringstream.
Definition: string_type.h:58
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
Stateless_allocator< char, String_type_alloc > String_type_allocator
Definition: string_type.h:43
Definition: gcs_xcom_synode.h:64
Functor class which allocates memory for String_type.
Definition: string_type.h:39
void * operator()(size_t s) const
Definition: string_type.cc:34
size_t result_type
Definition: string_type.h:91
dd::String_type argument_type
Definition: string_type.h:90