Luna/libluna/include/luna/SourceLocation.h
apio 77887eed80
All checks were successful
continuous-integration/drone/push Build is passing
luna -> libluna
2023-02-27 15:22:39 +01:00

43 lines
881 B
C++

#pragma once
#include <luna/Types.h>
#ifndef STRINGIZE_VALUE_OF
#define STRINGIZE(x) #x
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
#endif
class SourceLocation
{
public:
constexpr const char* file()
{
return m_file;
}
constexpr u32 line()
{
return m_line;
}
constexpr const char* function()
{
return m_function;
}
constexpr static SourceLocation current(const char* file = __builtin_FILE(), u32 line = __builtin_LINE(),
const char* function = __builtin_FUNCTION())
{
return SourceLocation { file, line, function };
}
private:
constexpr SourceLocation(const char* file, u32 line, const char* function)
: m_file(file), m_line(line), m_function(function)
{
}
const char* m_file;
u32 m_line;
const char* m_function;
};