OSDN Git Service

Improved temp_folder() function + we will now clean-up the TEMP folder on application...
[mutilities/MUtilities.git] / include / MUtils / Version.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
20 //////////////////////////////////////////////////////////////////////////////////
21
22 #pragma once
23
24 //MUtils
25 #include <MUtils/Global.h>
26
27 //Qt
28 #include <QString>
29 #include <QDate>
30 #include <QTime>
31
32 namespace MUtils
33 {
34         class Version
35         {
36         public:
37                 //Get Build Date
38                 MUTILS_API static const QDate build_date(const char *const date_str = build_date_raw());
39
40                 //Get Build Time
41                 MUTILS_API static const QTime build_time(const char *const time_str = build_time_raw());
42
43                 //Compiler detection
44                 MUTILS_API static const char *const compiler_version(void)
45                 {
46                         #if defined(__INTEL_COMPILER)
47                                 #if (__INTEL_COMPILER >= 1500)
48                                         static const char *const COMPILER_VERS = "ICL 15." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
49                                 #elif (__INTEL_COMPILER >= 1400)
50                                         static const char *const COMPILER_VERS = "ICL 14." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
51                                 #elif (__INTEL_COMPILER >= 1300)
52                                         static const char *const COMPILER_VERS = "ICL 13." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
53                                 #elif (__INTEL_COMPILER >= 1200)
54                                         static const char *const COMPILER_VERS = "ICL 12." MUTILS_MAKE_STRING(__INTEL_COMPILER_BUILD_DATE);
55                                 #elif (__INTEL_COMPILER >= 1100)
56                                         static const char *const COMPILER_VERS = "ICL 11.x";
57                                 #elif (__INTEL_COMPILER >= 1000)
58                                         static const char *const COMPILER_VERS = "ICL 10.x";
59                                 #else
60                                         #error Compiler is not supported!
61                                 #endif
62                         #elif defined(_MSC_VER)
63                                 #if (_MSC_VER == 1800)
64                                         #if (_MSC_FULL_VER == 180021005)
65                                                 static const char *const COMPILER_VERS = "MSVC 2013";
66                                         #elif (_MSC_FULL_VER == 180030501)
67                                                 static const char *const COMPILER_VERS = "MSVC 2013.2";
68                                         #elif (_MSC_FULL_VER == 180030723)
69                                                 static const char *const COMPILER_VERS = "MSVC 2013.3";
70                                         #elif (_MSC_FULL_VER == 180031101)
71                                                 static const char *const COMPILER_VERS = "MSVC 2013.4";
72                                         #else
73                                                 #error Compiler version is not supported yet!
74                                         #endif
75                                 #elif (_MSC_VER == 1700)
76                                         #if (_MSC_FULL_VER == 170050727)
77                                                 static const char *const COMPILER_VERS = "MSVC 2012";
78                                         #elif (_MSC_FULL_VER == 170051106)
79                                                 static const char *const COMPILER_VERS = "MSVC 2012.1";
80                                         #elif (_MSC_FULL_VER == 170060315)
81                                                 static const char *const COMPILER_VERS = "MSVC 2012.2";
82                                         #elif (_MSC_FULL_VER == 170060610)
83                                                 static const char *const COMPILER_VERS = "MSVC 2012.3";
84                                         #elif (_MSC_FULL_VER == 170061030)
85                                                 static const char *const COMPILER_VERS = "MSVC 2012.4";
86                                         #else
87                                                 #error Compiler version is not supported yet!
88                                         #endif
89                                 #elif (_MSC_VER == 1600)
90                                         #if (_MSC_FULL_VER >= 160040219)
91                                                 static const char *const COMPILER_VERS = "MSVC 2010-SP1";
92                                         #else
93                                                 static const char *const COMPILER_VERS = "MSVC 2010";
94                                         #endif
95                                 #elif (_MSC_VER == 1500)
96                                         #if (_MSC_FULL_VER >= 150030729)
97                                                 static const char *const COMPILER_VERS = "MSVC 2008-SP1";
98                                         #else
99                                                 static const char *const COMPILER_VERS = "MSVC 2008";
100                                         #endif
101                                 #else
102                                         #error Compiler is not supported!
103                                 #endif
104                         #else
105                                 #error Compiler is not supported!
106                         #endif
107
108                         return COMPILER_VERS;
109                 }
110
111                 //Architecture detection
112                 MUTILS_API static const char *const compiler_arch(void)
113                 {
114                         #if defined(_M_X64)
115                                 static const char *const COMPILER_ARCH = "x64";
116                         #elif defined(_M_IX86)
117                                 static const char *const COMPILER_ARCH = "x86";
118                         #else
119                                 #error Architecture is not supported!
120                         #endif
121
122                         return COMPILER_ARCH;
123                 }
124         
125         private:
126                 //Raw Build date
127                 static const char *const build_date_raw(void)
128                 {
129                         static const char *const RAW_BUILD_DATE = __DATE__;
130                         return RAW_BUILD_DATE;
131                 }
132
133                 //Raw Build time
134                 static const char *const build_time_raw(void)
135                 {
136                         static const char *const RAW_BUILD_TIME = __TIME__;
137                         return RAW_BUILD_TIME;
138                 }
139
140                 //Disable construction
141                 Version(void)           { throw 666; }
142                 Version(const Version&) { throw 666; }
143         };
144 }
145
146 ///////////////////////////////////////////////////////////////////////////////