MySQL 8.4.11
Source Code Documentation
typeid_name.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_TYPEID_NAME_INCLUDED
27#define MYSQL_HARNESS_TYPEID_NAME_INCLUDED
28
29#include <cstdlib>
30#include <memory>
31#include <string>
32#include <typeinfo>
33
34#ifdef HAVE_ABI_CXA_DEMANGLE
35#include <cxxabi.h>
36#endif // HAVE_ABI_CXA_DEMANGLE
37
38namespace mysql_harness {
39
40inline std::string typeid_name(const std::type_info &ti) {
41#ifdef HAVE_ABI_CXA_DEMANGLE
42 int status = 0;
43 std::unique_ptr<char, decltype(&std::free)> demangled{
44 abi::__cxa_demangle(ti.name(), nullptr, nullptr, &status), &std::free};
45
46 if (status == 0 && demangled != nullptr) {
47 return demangled.get();
48 }
49#endif // HAVE_ABI_CXA_DEMANGLE
50
51 return ti.name();
52}
53
54template <class T>
55std::string typeid_name(const T &v) {
56 return typeid_name(typeid(v));
57}
58
59template <class T>
60std::string typeid_name() {
61 return typeid_name(typeid(T));
62}
63
64} // namespace mysql_harness
65
66#endif // MYSQL_HARNESS_TYPEID_NAME_INCLUDED
#define free(A)
Definition: lexyy.cc:915
Definition: common.h:42
std::string typeid_name(const std::type_info &ti)
Definition: typeid_name.h:40
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2443
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61