JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
demangle.hpp
Go to the documentation of this file.
1/** \file jsonv/demangle.hpp
2 *
3 * Copyright (c) 2015 by Travis Gockel. All rights reserved.
4 *
5 * This program is free software: you can redistribute it and/or modify it under the terms of the Apache License
6 * as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * \author Travis Gockel (travis@gockelhut.com)
10**/
11#ifndef __JSONV_DEMANGLE_HPP_INCLUDED__
12#define __JSONV_DEMANGLE_HPP_INCLUDED__
13
14#include <jsonv/config.hpp>
15#include <string_view>
16
17#include <functional>
18#include <string>
19
20namespace jsonv
21{
22
23/** \addtogroup Serialization
24 * \{
25**/
26
27/** Convert the input \a source from a mangled type into a human-friendly version. This is used by \c formats (and the
28 * associated serialization functions) to give more user-friendly names in type errors.
29 *
30 * \see demangle_function
31 * \see set_demangle_function
32**/
33JSONV_PUBLIC std::string demangle(std::string_view source);
34
35/** Type of function used in setting a custom demangler.
36 *
37 * \see demangle
38 * \see set_demangle_function
39**/
40using demangle_function = std::function<std::string (std::string_view source)>;
41
42/** Sets the global demangle function. This controls the behavior of \c demangle -- the provided \a func will be called
43 * by \c demangle.
44 *
45 * \see demangle
46**/
48
49/** Resets the demangle function to the default.
50 *
51 * \see set_demangle_function
52**/
54
55/** Get the demangled type name of the current exception. This is meant to be called from `catch (...)` blocks to
56 * attempt to get more information about the exception type when it doesn't derive from a known entity.
57 *
58 * \returns The demangled type name of the current exception or "unknown" if this cannot be discovered. Failure to
59 * discover is not an error -- this can happen if the exception is foreign to C++ (it does not have a
60 * \c std::type_info implementation) or if discovery is not known for this platform.
61**/
63
64/** \} **/
65
66}
67
68#endif/*__JSONV_DEMANGLE_HPP_INCLUDED__*/
An adapter for enumeration types.
Copyright (c) 2014-2020 by Travis Gockel.
#define JSONV_PUBLIC
This function or class is part of the public API for JSON Voorhees.
Definition config.hpp:102
std::function< std::string(std::string_view source)> demangle_function
Type of function used in setting a custom demangler.
Definition demangle.hpp:40
JSONV_PUBLIC std::string demangle(std::string_view source)
Convert the input source from a mangled type into a human-friendly version.
JSONV_PUBLIC void reset_demangle_function()
Resets the demangle function to the default.
JSONV_PUBLIC void set_demangle_function(demangle_function func)
Sets the global demangle function.
JSONV_PUBLIC std::string current_exception_type_name()
Get the demangled type name of the current exception.