ATLAS Offline Software
Loading...
Searching...
No Matches
error.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12
14#ifdef __GXX_ABI_VERSION
15# include <cstdlib>
16# include <cxxabi.h>
17#endif
18#include <print>
19
20
21#ifdef XAOD_STANDALONE
22
23
24namespace AthContainers_detail {
25
26
28void reportMessageStandalone (const std::string& context,
29 const std::string& severity,
30 const std::string& file, int line,
31 const std::string& msg) {
32
33 // Make sure that the message's source/location is not longer than a
34 // pre-set maximum value.
35 std::string source (context);
36 static constexpr std::size_t CONTEXT_WIDTH = 18;
37 if (source.size() > CONTEXT_WIDTH) {
38 source.resize(CONTEXT_WIDTH - 3);
39 source += "...";
40 }
41
42 // Print the message to stdout/std::cout.
43 std::println ("{:<{}} {} {}:{}: {}",
44 source, CONTEXT_WIDTH, severity, file, line, msg);
45 return;
46}
47
48
58std::string typeinfoName (const std::type_info& ti)
59{
60 // In case the "translation" is not successful, the fallback is to
61 // keep the original, mangled name:
62 std::string result = ti.name();
63
64#ifdef __GXX_ABI_VERSION
65 // Try to demangle the name:
66 int status;
67 char* typeName = abi::__cxa_demangle( ti.name(), 0, 0, &status );
68 if (status == 0) {
69 // Take the demangled name, and free up the memory allocated in
70 // the process:
72 ::free( typeName );
73 }
74#endif
75
76 return result;
77}
78
79
80} // namespace AthContainers_detail
81
82
83#endif // XAOD_STANDALONE
Helper for emitting error messages.
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
status
Definition merge.py:16
MsgStream & msg
Definition testRead.cxx:32
TFile * file