src/Main.h

changeset 629
b75c6cce02e2
child 634
5ef894f699d7
equal deleted inserted replaced
628:6b13e4c2e97b 629:b75c6cce02e2
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013, 2014 Santeri 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 // =============================================================================
20 // This file is included one way or another in every source file of LDForge.
21 // Stuff defined and included here is universally included.
22
23 #ifndef LDFORGE_MAIN_H
24 #define LDFORGE_MAIN_H
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <stdint.h>
29 #include <stdarg.h>
30 #include <QString>
31 #include <QTextFormat>
32
33 #include "PropertyMacro.h"
34 #include "Configuration.h"
35
36 #define APPNAME "LDForge"
37 #define UNIXNAME "ldforge"
38 #define VERSION_MAJOR 0
39 #define VERSION_MINOR 2
40 #define VERSION_PATCH 999
41 #define BUILD_ID BUILD_INTERNAL
42
43 #define BUILD_INTERNAL 0
44 #define BUILD_RELEASE 1
45
46 // =============================================
47 #ifdef DEBUG
48 # undef RELEASE
49 #endif // DEBUG
50
51 #ifdef RELEASE
52 # undef DEBUG
53 #endif // RELEASE
54
55 // =============================================
56 #define alias auto&
57 #define elif(A) else if (A)
58
59 // Null pointer
60 static const std::nullptr_t null = nullptr;
61
62 #ifdef WIN32
63 # define DIRSLASH "\\"
64 # define DIRSLASH_CHAR '\\'
65 #else // WIN32
66 # define DIRSLASH "/"
67 # define DIRSLASH_CHAR '/'
68 #endif // WIN32
69
70 #ifdef __GNUC__
71 #define FUNCNAME __PRETTY_FUNCTION__
72 #else
73 #define FUNCNAME __func__
74 #endif // __GNUC__
75
76 #ifdef IN_IDE_PARSER
77 void dlog(void, ...) {}
78 #else
79 # ifdef DEBUG
80 # define dlog(...) log (QString (__PRETTY_FUNCTION__) + ": " __VA_ARGS__)
81 # else
82 # define dlog(...)
83 # endif // DEBUG
84 #endif // IN_IDE_PARSER
85
86 #define dvalof(A) dlog ("value of '%1' = %2\n", #A, A)
87
88 // Replace assert with a version that shows a GUI dialog if possible.
89 // On Windows I just can't get the actual error messages otherwise.
90 void assertionFailure (const char* file, int line, const char* funcname, const char* expr);
91
92 #undef assert
93
94 #ifdef DEBUG
95 # define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); }
96 #else
97 # define assert(N) {}
98 #endif // DEBUG
99
100 // Version string identifier
101 QString versionString();
102 QString fullVersionString();
103
104 #define properties private
105 #define typedefs public
106 #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z}))
107
108 // -----------------------------------------------------------------------------
109 #ifdef IN_IDE_PARSER // KDevelop workarounds:
110 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
111 # define COMPILE_DATE "14-01-10 10:31:09"
112
113 # ifndef va_start
114 # define va_start(va, arg)
115 # endif // va_start
116
117 # ifndef va_end
118 # define va_end(va)
119 # endif // va_end
120
121 static const char* __func__ = ""; // Current function name
122 typedef void FILE; // :|
123 #endif // IN_IDE_PARSER
124
125 #endif // LDFORGE_MAIN_H

mercurial