boo/include/boo/System.hpp

92 lines
2.1 KiB
C++
Raw Normal View History

2015-08-30 20:40:58 -07:00
#ifndef BOO_SYSTEM_HPP
#define BOO_SYSTEM_HPP
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>
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
2015-11-21 20:18:30 -08:00
#ifndef ENABLE_BITWISE_ENUM
2015-11-20 17:12:22 -08:00
#define ENABLE_BITWISE_ENUM(type)\
2016-07-31 13:25:02 -07:00
constexpr type operator|(type a, type b)\
2015-11-20 17:12:22 -08:00
{\
using T = std::underlying_type_t<type>;\
return type(static_cast<T>(a) | static_cast<T>(b));\
}\
2016-07-31 13:25:02 -07:00
constexpr type operator&(type a, type b)\
2015-11-20 17:12:22 -08:00
{\
using T = std::underlying_type_t<type>;\
return type(static_cast<T>(a) & static_cast<T>(b));\
}\
2016-07-31 21:32:27 -07:00
inline type& operator|=(type& a, const type& b)\
2015-11-20 17:12:22 -08:00
{\
using T = std::underlying_type_t<type>;\
a = type(static_cast<T>(a) | static_cast<T>(b));\
return a;\
}\
2016-07-31 21:32:27 -07:00
inline type& operator&=(type& a, const type& b)\
2015-11-20 17:12:22 -08:00
{\
using T = std::underlying_type_t<type>;\
a = type(static_cast<T>(a) & static_cast<T>(b));\
return a;\
}\
2016-07-31 21:32:27 -07:00
inline type operator~(const type& key)\
2015-11-20 17:12:22 -08:00
{\
using T = std::underlying_type_t<type>;\
return type(~static_cast<T>(key));\
}
2015-11-21 20:18:30 -08:00
#endif
2015-11-20 17:12:22 -08:00
2015-08-30 20:40:58 -07:00
namespace boo
{
#ifdef _WIN32
using SystemString = std::wstring;
2017-11-12 22:13:32 -08:00
using SystemStringView = std::wstring_view;
2015-08-30 20:40:58 -07:00
using SystemChar = wchar_t;
# ifndef _S
# define _S(val) L ## val
# endif
#else
using SystemString = std::string;
2017-11-12 22:13:32 -08:00
using SystemStringView = std::string_view;
2015-08-30 20:40:58 -07:00
using SystemChar = char;
# ifndef _S
# define _S(val) val
# endif
#endif
2018-05-19 23:11:49 -07:00
#ifndef NDEBUG
#define __BooTraceArgs , const char* file, int line
#define __BooTraceArgsUse , file, line
#define __BooTraceInitializer , m_file(file), m_line(line)
#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
2015-08-30 20:40:58 -07:00
}
2015-11-20 17:12:22 -08:00
#endif