boo/include/boo/System.hpp

79 lines
4.6 KiB
C++
Raw Normal View History

2018-10-06 20:36:44 -07:00
#pragma once
2015-08-30 20:40:58 -07:00
2016-09-10 18:21:24 -07:00
#ifdef _WIN32
2017-12-05 19:20:59 -08:00
#include <winapifamily.h>
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
#define WINDOWS_STORE 1
#else
#define WINDOWS_STORE 0
#endif
2016-09-10 18:21:24 -07:00
#include <windows.h>
#include <D3Dcommon.h>
#include <wrl/client.h>
template <class T>
using ComPtr = Microsoft::WRL::ComPtr<T>;
2017-03-05 14:59:58 -08:00
template <class T>
2018-12-07 21:17:51 -08:00
static inline ComPtr<T>* ReferenceComPtr(ComPtr<T>& ptr) {
return reinterpret_cast<ComPtr<T>*>(ptr.GetAddressOf());
}
2016-09-10 18:21:24 -07:00
#endif
2015-08-30 20:40:58 -07:00
#include <string>
2017-11-12 22:13:32 -08:00
#include <string_view>
2015-08-30 20:40:58 -07:00
2019-07-19 21:22:36 -07:00
#include <fmt/format.h>
2015-11-21 20:18:30 -08:00
#ifndef ENABLE_BITWISE_ENUM
2018-12-07 21:17:51 -08:00
#define ENABLE_BITWISE_ENUM(type) \
constexpr type operator|(type a, type b) noexcept { \
2018-12-07 21:17:51 -08:00
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) | static_cast<T>(b)); \
} \
constexpr type operator&(type a, type b) noexcept { \
2018-12-07 21:17:51 -08:00
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) & static_cast<T>(b)); \
} \
constexpr type& operator|=(type& a, type b) noexcept { \
2018-12-07 21:17:51 -08:00
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) | static_cast<T>(b)); \
return a; \
} \
constexpr type& operator&=(type& a, type b) noexcept { \
2018-12-07 21:17:51 -08:00
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) & static_cast<T>(b)); \
return a; \
} \
constexpr type operator~(type key) noexcept { \
2018-12-07 21:17:51 -08:00
using T = std::underlying_type_t<type>; \
return type(~static_cast<T>(key)); \
} \
constexpr bool True(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) != 0; \
} \
constexpr bool False(type key) noexcept { \
return !True(key); \
2018-12-07 21:17:51 -08:00
}
2015-11-21 20:18:30 -08:00
#endif
2015-11-20 17:12:22 -08:00
2018-12-07 21:17:51 -08:00
namespace boo {
2015-08-30 20:40:58 -07:00
2018-05-19 23:11:49 -07:00
#ifndef NDEBUG
2018-12-07 21:17:51 -08:00
#define __BooTraceArgs , const char *file, int line
2018-05-19 23:11:49 -07:00
#define __BooTraceArgsUse , file, line
#define __BooTraceInitializer , m_file(file), m_line(line)
2018-12-07 21:17:51 -08:00
#define __BooTraceFields \
const char* m_file; \
int m_line;
2018-05-24 23:30:42 -07:00
#define BooTrace , __FILE__, __LINE__
2018-05-19 23:11:49 -07:00
#else
#define __BooTraceArgs
#define __BooTraceArgsUse
#define __BooTraceInitializer
#define __BooTraceFields
2018-05-24 23:30:42 -07:00
#define BooTrace
2018-05-19 23:11:49 -07:00
#endif
2018-12-07 21:17:51 -08:00
} // namespace boo