##// END OF EJS Templates
Ajout de la version
perrinel -
r6:2f8953ec6d3f
parent child
Show More
@@ -0,0 +1,78
1 #include "Version.h"
2
3 /***************************************************
4 * @SCIQLOP_CMAKE_GENERATION_WARNING@ *
5 ***************************************************/
6
7 #include <QtCore/QDateTime>
8 #include <QtCore/QStringList>
9
10 namespace sciqlop {
11
12 const char *Version::VERSION_SUFFIX = "@SCIQLOP_VERSION_SUFFIX@";
13
14 /**
15 * From the C99 standard:
16 * __DATE__: The date of translation of the preprocessing translation unit:
17 * a character string literal of the form "Mmm dd yyyy", where the names of
18 * the months are the same as those generated by the asctime function, and
19 * the first character of dd is a space character if the value is less than
20 * 10. If the date of translation is not available, an
21 * implementation-defined valid date shall be supplied.
22 */
23 const char *Version::BUILD_DATE = __DATE__;
24 /**
25 * From the C99 standard:
26 * __TIME__: The time of translation of the preprocessing translation unit:
27 * a character string literal of the form "hh:mm:ss" as in the time
28 * generated by the asctime function. If the time of translation is not
29 * available, an implementation-defined valid time shall be supplied.
30 */
31 const char *Version::BUILD_TIME = __TIME__;
32
33 QDateTime Version::buildDateTime()
34 {
35 static QDateTime buildDateTime;
36 if (!buildDateTime.isValid()) {
37 // Convert BUILD_DATE to a QDate
38 // The __DATE__ macro return the month name with the asctime() function,
39 // which doesn't support localization, the month names returned are
40 // always the same. On the contrary, the "MMM" format on
41 // QDate::fromString() is localized, so this method can't be used to
42 // retrieve the month and we must manually do it instead.
43 QString buildDateStr = QString(BUILD_DATE);
44 QString buildMonthStr = buildDateStr.left(3);
45 QString buildDayAndYearStr = buildDateStr.mid(4).trimmed();
46
47 QDate buildDate = QDate::fromString(buildDayAndYearStr, "d yyyy");
48 QStringList monthList = QStringList() << "Jan"
49 << "Feb"
50 << "Mar"
51 << "Apr"
52 << "May"
53 << "Jun"
54 << "Jul"
55 << "Aug"
56 << "Sep"
57 << "Oct"
58 << "Nov"
59 << "Dec";
60 for (int i = 0; i < monthList.size(); ++i) {
61 if (buildMonthStr == monthList.at(i)) {
62 buildDate.setDate(buildDate.year(), i + 1, buildDate.day());
63 break;
64 }
65 }
66
67 // Convert BUILD_TIME to a QTime
68 QTime buildTime = QTime::fromString(BUILD_TIME, "hh:mm:ss");
69
70 // Set the buildDateTime
71 buildDateTime.setDate(buildDate);
72 buildDateTime.setTime(buildTime);
73 }
74
75 return buildDateTime;
76 }
77
78 } // namespace sciqlop
@@ -0,0 +1,98
1 // TODO copyright
2 /**
3 * @file Version.h
4 */
5 #ifndef SCIQLOP_VERSION_H
6 #define SCIQLOP_VERSION_H
7
8 /***************************************************
9 * @SCIQLOP_CMAKE_GENERATION_WARNING@ *
10 ***************************************************/
11
12 //#include "SciqlopExport.h"
13 #include <QtCore/QString>
14
15 class QDateTime;
16
17 namespace sciqlop {
18
19 /**
20 * Holds the version of Sciqlop.
21 *
22 * @attention Don't update this class directly, it is generated from the
23 * `resources/Version.h.in` and `resources/Version.cpp.in` files, along with
24 * the cmake variables defined in the `cmake/sciqlop_version.cmake` file.
25 *
26 * To change the Sciqlop version number, update the `cmake/sciqlop_version.cmake`
27 * file, and to change this class other than to change the version number,
28 * update the `resources/Version.h.in` and `resources/Version.cpp.in` files.
29 * @ingroup Utils
30 */
31 class /*SCIQLOP_API*/ Version {
32 public:
33 /**
34 * Retrieve the version of Sciqlop.
35 *
36 * The version is of the form MAJOR.MINOR.PATCH. If a suffix has been
37 * provided to the version, it is appended after the PATCH.
38 *
39 * The version can be modified by updating the cmake/sciqlop_version.cmake
40 * file.
41 *
42 * @return The version of Sciqlop as a QString.
43 */
44 static QString version()
45 {
46 static const QString v("@SCIQLOP_VERSION@");
47 return v;
48 }
49
50 /**
51 * @return The datetime of the build.
52 */
53 static QDateTime buildDateTime();
54
55 /**
56 * Major version.
57 */
58 static const int VERSION_MAJOR = @SCIQLOP_VERSION_MAJOR@;
59 /**
60 * Minor version.
61 */
62 static const int VERSION_MINOR = @SCIQLOP_VERSION_MINOR@;
63 /**
64 * Patch version.
65 */
66 static const int VERSION_PATCH = @SCIQLOP_VERSION_PATCH@;
67 /**
68 * Suffix version.
69 */
70 static const char *VERSION_SUFFIX;
71
72 /**
73 * Compile date computed with the __DATE__ macro.
74 *
75 * From the C99 standard:
76 * __DATE__: The date of translation of the preprocessing translation unit:
77 * a character string literal of the form "Mmm dd yyyy", where the names of
78 * the months are the same as those generated by the asctime function, and
79 * the first character of dd is a space character if the value is less than
80 * 10. If the date of translation is not available, an
81 * implementation-defined valid date shall be supplied.
82 */
83 static const char *BUILD_DATE;
84 /**
85 * Compile time computed with the __TIME__ macro.
86 *
87 * From the C99 standard:
88 * __TIME__: The time of translation of the preprocessing translation unit:
89 * a character string literal of the form "hh:mm:ss" as in the time
90 * generated by the asctime function. If the time of translation is not
91 * available, an implementation-defined valid time shall be supplied.
92 */
93 static const char *BUILD_TIME;
94 };
95
96 } // namespace sciqlop
97
98 #endif // SCIQLOP_VERSION_H
General Comments 0
You need to be logged in to leave comments. Login now