1 #if !defined(_BTK_BUILD_HPP_) 2 #define _BTK_BUILD_HPP_ 4 #include <SDL2/SDL_assert.h> 5 #include <SDL2/SDL_log.h> 13 #include <Btk/defs.hpp> 17 #define BTK_FUNCTION __FUNCSIG__ 18 #elif defined(__GNUC__) 22 #define BTK_FUNCTION __PRETTY_FUNCTION__ 24 #define BTK_FUNCTION SDL_FUNCTION 28 #define BTK_LOGINFO(...) SDL_Log(__VA_ARGS__) 29 #define BTK_LOGWARN(...) SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,__VA_ARGS__) 31 #define BTK_LOGINFO(...) 32 #define BTK_LOGWARN(...) 36 #define BTK_ASSERT(EXP) if(not(EXP)){\ 37 _Btk_ReportFailure(__FILE__,__LINE__,BTK_FUNCTION,#EXP);\ 38 SDL_TriggerBreakpoint();\ 41 #define BTK_ASSERT(EXP) 51 extern "C" void BTKAPI _Btk_Backtrace();
56 extern "C" void BTKAPI _Btk_ReportFailure(
63 extern "C" inline void _Btk_Backtrace(){};
64 extern "C" inline void _Btk_ReportFailure(
74 template<
class T,
class U>
77 return dynamic_cast<T
>(std::forward<U>(u));
79 return static_cast<T
>(std::forward<U>(u));
82 inline int vscprintf(
const char *fmt,va_list varg){
84 return _vscprintf(fmt,varg);
86 return vsnprintf(
nullptr,0,fmt,varg);
98 char *ret = abi::__cxa_demangle(info.name(),
nullptr,
nullptr,
nullptr);
104 std::string name(ret);
123 inline std::string
cformat(
const char *fmt,...){
130 strsize = _vscprintf(fmt,varg);
132 strsize = vsnprintf(
nullptr,0,fmt,varg);
141 vsprintf(&str[0],fmt,varg);
153 inline void cformat(std::string &str,
const char *fmt,...){
159 strsize = _vscprintf(fmt,varg);
161 strsize = vsnprintf(
nullptr,0,fmt,varg);
165 size_t length = str.length();
167 str.resize(strsize + str.size());
168 char *end = &str[length];
171 vsprintf(end,fmt,varg);
175 #endif // _BTK_BUILD_HPP_ This header include many useful containers.
Definition: async.hpp:7
std::string cformat(const char *fmt,...)
Using c-syle formatting.
Definition: build.hpp:123
std::string get_typename(const std::type_info &info)
Get the typename of a type.
Definition: build.hpp:96