-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompareMacros.hpp
45 lines (38 loc) · 4.08 KB
/
CompareMacros.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
#pragma once
#include "macroexpansion.hpp"
// ============================================================================================
#define _QJS_COMPARE_F(...) FOR_EACH_2(__COMPARE_F, __VA_ARGS__)
#define _QJS_COMPARE_B(...) FOR_EACH_2(__COMPARE_B, __VA_ARGS__)
#define _QJS_COMPARE_BF(option) _QJS_COMPARE_##option
#define __COMPARE_F(name) (this->JS_F(name) == ___another___instance__.JS_F(name)) &&
#define __COMPARE_B(base) ((base) * this == (base) ___another___instance__) &&
#define QJS_FUNC_COMP(CLASS, ...) \
public: \
bool operator==(const CLASS &___another___instance__) const \
{ \
QJsonObject ___json_object_; \
return FOR_EACH(_QJS_COMPARE_BF, __VA_ARGS__) true; \
} \
\
bool operator!=(const CLASS &_another) const \
{ \
return !(*this == _another); \
}
// ============================================================================================
#define QJS_FUNC_COPY(CLASS, ...) \
public: \
CLASS(const CLASS &another) \
{ \
*this = another; \
} \
CLASS &operator=(const CLASS &___another___instance__) \
{ \
FOR_EACH(_QJS_COPY_BF, __VA_ARGS__); \
return *this; \
}
#define _QJS_COPY_B(...) FOR_EACH_2(__COPY_B, __VA_ARGS__)
#define _QJS_COPY_F(...) FOR_EACH_2(__COPY_F, __VA_ARGS__)
#define _QJS_COPY_BF(option) _QJS_COPY_##option
#define __COPY_B(base) base::operator=(___another___instance__);
#define __COPY_F(name) this->JS_F(name) = ___another___instance__.JS_F(name);
// ============================================================================================