src/macros.h

changeset 1319
39d7a9642eea
parent 1318
568fcfc6da71
child 1320
bdb4804bc09c
equal deleted inserted replaced
1318:568fcfc6da71 1319:39d7a9642eea
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 - 2017 Teemu Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #pragma once
20
21 #ifndef __GNUC__
22 # define __attribute__(X)
23 #endif
24
25 #define DEFINE_CLASS(SELF, SUPER) \
26 public: \
27 using Self = SELF; \
28 using Super = SUPER;
29
30 #ifdef WIN32
31 # define DIRSLASH "\\"
32 # define DIRSLASH_CHAR '\\'
33 #else // WIN32
34 # define DIRSLASH "/"
35 # define DIRSLASH_CHAR '/'
36 #endif // WIN32
37
38 #define MAKE_ITERABLE_ENUM(T) \
39 template<> \
40 struct EnumLimits<T> \
41 {\
42 enum { First = 0, Last = static_cast<int>(T::_End) - 1, Count = Last + 1 };\
43 }; \
44 inline T operator++ (T& a) { a = static_cast<T>(static_cast<int>(a) + 1); return a; } \
45 inline T operator-- (T& a) { a = static_cast<T>(static_cast<int>(a) - 1); return a; } \
46 inline T operator++ (T& a, int) { T result = a; a = static_cast<T>(static_cast<int>(a) + 1); return result; } \
47 inline T operator-- (T& a, int) { T result = a; a = static_cast<T>(static_cast<int>(a) - 1); return result; }
48
49 template<typename T>
50 struct EnumLimits {};

mercurial