use pbd's gstdio compatibility wrapper
[ardour.git] / libs / audiographer / audiographer / debug_utils.h
1 #ifndef AUDIOGRAPHER_DEBUG_UTILS_H
2 #define AUDIOGRAPHER_DEBUG_UTILS_H
3
4 #include "flag_field.h"
5
6 #include <cstdlib>
7 #include <string>
8
9 #ifdef __GNUC__
10 #include <cxxabi.h>
11 #include <cstdlib>
12 #endif
13
14 #include "audiographer/visibility.h"
15
16 namespace AudioGrapher
17 {
18
19 /// Utilities for debugging
20 struct LIBAUDIOGRAPHER_API DebugUtils
21 {
22         /// Returns the demangled name of the object passed as the parameter
23         template<typename T>
24         static std::string demangled_name (T const & obj)
25         {
26 #ifdef __GNUC__
27                 int status;
28                 char * res = abi::__cxa_demangle (typeid(obj).name(), 0, 0, &status);
29                 if (status == 0) {
30                         std::string s(res);
31                         std::free (res);
32                         return s;
33                 }
34 #endif
35                 return typeid(obj).name();
36         }
37         
38         /// Returns name of ProcessContext::Flag
39         static std::string process_context_flag_name (FlagField::Flag flag);
40 };
41
42 } // namespace
43
44 #endif // AUDIOGRAPHER_DEBUG_UTILS_H