-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpch.hpp
195 lines (150 loc) · 4.35 KB
/
pch.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#pragma once
#include <memory>
#include <string>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <map>
#include <filesystem>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <stack>
#include <stddef.h>
#include <utility>
#include <vector>
namespace fs = std::filesystem;
template <typename T>
using Scope = std::unique_ptr<T>;
template <typename T, typename... Args>
constexpr Scope<T> createScope(Args &&...args)
{
return std::make_unique<T>(std::forward<Args>(args)...);;
}
template <typename T>
using Ref = std::shared_ptr<T>;
template <typename T, typename... Args>
constexpr Ref<T> createRef(Args &&...args)
{
return std::make_shared<T>(std::forward<Args>(args)...);;
}
//!PTRs
#define MAKE_SCOPE(className, ...) createScope<className>(__VA_ARGS__)
#define MAKE_REF(className, ...) createRef<className>(__VA_ARGS__)
//!NAMESPACES
#define NAMESPACE(name) namespace name {
#define END_NAMESPACE }
#define ALIAS(origin, replace) \
using origin = replace;
//!PROPERTIES
#define PROPERTY(type, name) \
protected: \
type m_##name; \
public: \
const type& get_##name() const { return m_##name; } \
void set_##name(const type& value) { m_##name = value; } \
#define READONLY_PROPERTY(type, name) \
protected: \
type m_##name; \
public: \
type get_##name() const { return m_##name; } \
#define CONST_PROPERTY(type, name, value) \
protected: \
const type m_##name = value; \
public: \
const type& get_##name() const { return m_##name; } \
#define STATIC_PROPERTY(type, name) \
protected: \
static type m_##name; \
public: \
static const type& get_##name() { return m_##name; } \
static void set_##name(const type& value) { m_##name = value; } \
//!STRUCTURES
#define ENUM(name, ...) \
enum name { \
__VA_ARGS__ \
};
#define ENUM_CLASS(name, ...) \
enum class name { \
__VA_ARGS__ \
};
#define STRUCT(name, ...) \
struct name { \
__VA_ARGS__ \
};
#define TEMPLATED_STRUCT(name, type, ...) \
template<typename type> \
struct name { \
__VA_ARGS__ \
};
#define END_ENUM \
};
#define END_STRUCT \
};
//!METHODS
#define FUNC(type, name, ...) \
type name(__VA_ARGS__);
#define FUNC_CONST(type, name, ...) \
type name(__VA_ARGS__) const;
#define FUNC_VIRTUAL(type, name, ...) \
virtual type name(__VA_ARGS__) = 0;
#define FUNC_VIRTUAL(type, name, ...) \
virtual type name(__VA_ARGS__) = 0;
#define FUNC_CONST_VIRTUAL(type, name, ...) \
virtual type name(__VA_ARGS__) const = 0;
#define FUNC_OVERRIDE(type, name, ...) \
type name(__VA_ARGS__) override;
#define FUNC_CONST_OVERRIDE(type, name, ...) \
type name(__VA_ARGS__) const override;
#define FUNC_OVERLOAD(type, name, ...) \
FUNC(type, name, __VA_ARGS__)
#define FUNC_INLINE(type, name, ...) \
inline type name() { __VA_ARGS__; }
#define FUNC_INLINE_CONST(type, name, ...) \
inline type name() const { __VA_ARGS__; }
#define TEMPLATED_FUNC(name, type, returnType, ...) \
template<typename type> \
returnType name(__VA_ARGS__){ \
#define FUNC_IMPL(klass, type, name, ...) \
type klass::name(__VA_ARGS__) {
#define FUNC_IMPL_CONST(klass, type, name, ...) \
type klass::name(__VA_ARGS__) const {
#define FUNC_END }
//!CONSTRUCTORS
#define CTOR(name, ...) \
name(__VA_ARGS__);
#define TEMPLATED_CTOR(name, type, ...) \
template<typename type> \
name(__VA_ARGS__){
#define DTOR(name) \
~name();
#define CTOR_IMPL_WITH_PARAMS(klass, ...) \
klass::klass() : __VA_ARGS__ { \
#define CTOR_IMPL_NO_PARAMS(klass) \
klass::klass() { \
#define CTOR_END }
#define DTOR_IMPL(klass) \
klass::~klass() {
#define DTOR_END }
//!CLASSES
#define CLASS(className, ...) \
class className { \
public: \
CTOR(className, __VA_ARGS__); \
DTOR(className);
#define TEMPLATED_CLASS(className, type, ...) \
template<typename type> \
class className { \
public:
#define END_CLASS };
#define INTERFACE(className) \
class I##className { \
public: \
virtual ~I##className() = default;
#define END_INTERFACE };
#define DERIVED_CLASS(className, baseClassName, ...) \
class className : public baseClassName { \
public: \
CTOR(className, __VA_ARGS__) \
DTOR(className)
#define END_DERIVED_CLASS };