summaryrefslogtreecommitdiff
path: root/libs/audiographer/audiographer/debug_utils.h
blob: 410567d51b7cb74537fee9113af13b7dd2430742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef AUDIOGRAPHER_DEBUG_UTILS_H
#define AUDIOGRAPHER_DEBUG_UTILS_H

#include "flag_field.h"

#include <cstdlib>
#include <string>

#ifdef __GNUC__
#include <cxxabi.h>
#include <cstdlib>
#endif

#include "audiographer/visibility.h"

namespace AudioGrapher
{

/// Utilities for debugging
struct LIBAUDIOGRAPHER_API DebugUtils
{
	/// Returns the demangled name of the object passed as the parameter
	template<typename T>
	static std::string demangled_name (T const & obj)
	{
#ifdef __GNUC__
		int status;
		char * res = abi::__cxa_demangle (typeid(obj).name(), 0, 0, &status);
		if (status == 0) {
			std::string s(res);
			std::free (res);
			return s;
		}
#endif
		return typeid(obj).name();
	}

	/// Returns name of ProcessContext::Flag
	static std::string process_context_flag_name (FlagField::Flag flag);
};

} // namespace

#endif // AUDIOGRAPHER_DEBUG_UTILS_H