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