TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_types.hpp
1 
10 #ifndef TurtleBrains_Types_hpp
11 #define TurtleBrains_Types_hpp
12 
13 #include <turtle_brains/core/tb_configuration.hpp>
14 #include <turtle_brains/core/tb_defines.hpp>
15 #include <cstdint>
16 #include <cstddef>
17 
18 namespace TurtleBrains::Core
19 {
20 
21  using int8 = std::int8_t;
22  using uint8 = std::uint8_t;
23  using byte = std::uint8_t;
24  using int16 = std::int16_t;
25  using uint16 = std::uint16_t;
26  using int32 = std::int32_t;
27  using uint32 = std::uint32_t;
28  using int64 = std::int64_t;
29  using uint64 = std::uint64_t;
30 
31  class size
32  {
33  public:
34  explicit size(const tbCore::uint32 value) :
35  mValue(value)
36  {
37  }
38 
39  explicit size(const std::size_t value) :
40  mValue(value)
41  {
42  }
43 
44  operator tbCore::uint32() const {
45  return tbCore::RangedCast<tbCore::uint32>(mValue);
46  }
47 
48  operator int() const {
49  return tbCore::RangedCast<int>(mValue);
50  }
51 
52  operator size_t() const {
53  return mValue;
54  }
55 
56  std::size_t mValue;
57  };
58 
59  class size32
60  {
61  public:
62  size32(const tbCore::uint32 value) :
63  mValue(value)
64  {
65  }
66 
67  size32(const std::size_t value) :
68  mValue(tbCore::RangedCast<tbCore::uint32>(value))
69  {
70  }
71 
72  operator tbCore::uint32() const {
73  return mValue;
74  }
75 
76  tbCore::uint32 mValue;
77  };
78 
79  class size64
80  {
81  public:
82  size64(const tbCore::uint32 value) :
83  mValue(value)
84  {
85  }
86 
87  size64(const std::size_t value) :
88  mValue(value)
89  {
90  }
91 
92  tbCore::uint64 mValue;
93  };
94 
95  //eh, kinda
96  using InputFile = std::istream;
97  using OutputFile = std::ostream;
98 
99 }; /* namespace TurtleBrains::Core */
100 
101 namespace TurtleBrains
102 {
103  // Common Buffer Sizes or Sanity Checks... These should return a size() rather than size_t but compiler didn't want
104  // to. Something something...
105  inline constexpr size_t OneKilobyte(void) { return 1024; }
106  inline constexpr size_t TwoKilobytes(void) { return OneKilobyte() * 2; }
107  inline constexpr size_t FourKilobytes(void) { return OneKilobyte() * 4; }
108  inline constexpr size_t OneMegabyte(void) { return 1024 * 1024; }
109  inline constexpr size_t OneGigabyte(void) { return 1024 * 1024 * 1024; }
110 };
111 
112 namespace tbCore = TurtleBrains::Core;
113 
114 #endif /* TurtleBrains_Types_hpp */
Definition: tb_types.hpp:60
Definition: tb_types.hpp:80
Definition: tb_types.hpp:32
Contains core functionality for each component of the API.
Definition: tb_debug_logger.hpp:125
std::uint8_t uint8
Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
Definition: tb_types.hpp:22
std::uint16_t uint16
Unsigned integer with a size of 16 bits. Supports values from 0 to 65535.
Definition: tb_types.hpp:25
std::int64_t int64
Signed integer with a size of 64 bits. Supports values from -(2^63) to (2^63 - 1).
Definition: tb_types.hpp:28
std::int16_t int16
Signed integer with a size of 16 bits. Supports values from -32768 to 32767.
Definition: tb_types.hpp:24
std::int8_t int8
Signed integer with a size of 8 bits. Supports values from -128 to 127.
Definition: tb_types.hpp:21
std::uint32_t uint32
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1).
Definition: tb_types.hpp:27
std::uint64_t uint64
Unsigned integer with a size of 64 bits, Supports values from 0 to (2^64 - 1).
Definition: tb_types.hpp:29
std::int32_t int32
Signed integer with a size of 32 bits. Supports values from -2147483648 to 2147483647.
Definition: tb_types.hpp:26
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:22