OpenVPN 3 Core Library
Loading...
Searching...
No Matches
demangle.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12// Demangle a C++ name (GCC only)
13
14#ifndef OPENVPN_COMMON_DEMANGLE_H
15#define OPENVPN_COMMON_DEMANGLE_H
16
17#include <cxxabi.h>
18
19#include <string>
20#include <memory>
21
22namespace openvpn {
23
24inline std::string cxx_demangle(const char *mangled_name)
25{
26 int status;
27 std::unique_ptr<char, decltype(&free)> realname{abi::__cxa_demangle(mangled_name, 0, 0, &status), &free};
28
29 return status ? "DEMANGLE_ERROR" : realname.get();
30}
31
32} // namespace openvpn
33
34#endif
std::string cxx_demangle(const char *mangled_name)
Definition demangle.hpp:24