Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
FlingTypes.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <limits>
5 #include <stdexcept>
6 #include <inttypes.h>
7 #include <entt/core/hashed_string.hpp>
8 #include <entt/entity/helper.hpp>
9 
10 // Integer typedefs for ease of use
11 typedef uint8_t UINT8;
12 typedef unsigned short UINT16;
13 typedef uint32_t UINT32;
14 typedef uint64_t UINT64;
15 
16 typedef int8_t INT8;
17 typedef signed short INT16;
18 typedef int32_t INT32;
19 typedef int64_t INT64;
20 
21 #define HS(str) entt::hashed_string { (str) }
22 
23 namespace Fling
24 {
25  // Use hashed strings as Guid's
26  typedef entt::hashed_string Guid;
27  typedef entt::hashed_string::hash_type Guid_Handle;
28  static Guid INVALID_GUID = { "INVALID_GUID"_hs };
29 }
30 
36 template <class T>
37 UINT32 to_u32(T value)
38 {
39  static_assert(std::is_arithmetic<T>::value, "T must be numeric");
40 
41  if (static_cast<uintmax_t>(value) > static_cast<uintmax_t>(std::numeric_limits<UINT32>::max()))
42  {
43  throw std::runtime_error("to_u32() failed, value is too big to be converted to UINT32");
44  }
45 
46  return static_cast<UINT32>(value);
47 }
int64_t INT64
Definition: FlingTypes.h:19
uint64_t UINT64
Definition: FlingTypes.h:14
int8_t INT8
Definition: FlingTypes.h:16
entt::hashed_string::hash_type Guid_Handle
Definition: FlingTypes.h:27
unsigned short UINT16
Definition: FlingTypes.h:12
int32_t INT32
Definition: FlingTypes.h:18
entt::hashed_string Guid
Definition: FlingTypes.h:26
UINT32 to_u32(T value)
Helper function to check size_t is correctly converted to uint32_t.
Definition: FlingTypes.h:37
uint8_t UINT8
Definition: FlingTypes.h:11
static Guid INVALID_GUID
Definition: FlingTypes.h:28
uint32_t UINT32
Definition: FlingTypes.h:13
Definition: Engine.h:29
signed short INT16
Definition: FlingTypes.h:17