1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 //=============================================================================
24 //
25 // Class, depicting version of the AGS engine
26 //
27 //=============================================================================
28 
29 #ifndef AGS_SHARED_UTIL_VERSION_H
30 #define AGS_SHARED_UTIL_VERSION_H
31 
32 #include "ags/shared/util/string.h"
33 
34 namespace AGS3 {
35 namespace AGS {
36 namespace Shared {
37 
38 using Shared::String;
39 
40 struct Version {
41 	int32_t Major;
42 	int32_t Minor;
43 	int32_t Release;
44 	int32_t Revision;
45 	String  Special;
46 	String  BuildInfo;
47 
48 	String  LongString;
49 	String  ShortString;
50 	String  BackwardCompatibleString;
51 
52 	// Last engine version, using different version format than AGS Editor (3.22.1120 / 3.2.2.1120)
53 	static const Version LastOldFormatVersion;
54 
55 	Version();
56 	Version(int32_t major, int32_t minor, int32_t release);
57 	Version(int32_t major, int32_t minor, int32_t release, int32_t revision);
58 	Version(int32_t major, int32_t minor, int32_t release, int32_t revision, const String &special);
59 	Version(int32_t major, int32_t minor, int32_t release, int32_t revision, const String &special, const String &build_info);
60 	Version(const String &version_string);
61 
AsNumberVersion62 	inline int32_t AsNumber() const {
63 		return Major * 10000 + Minor * 100 + Release;
64 	}
65 
AsLongNumberVersion66 	inline int64_t AsLongNumber() const {
67 		return (int64_t)Major * 100000000L + (int64_t)Minor * 1000000L + (int64_t)Release * 10000L + Revision;
68 	}
69 
AsSmallNumberVersion70 	inline int32_t AsSmallNumber() const {
71 		return Major * 100 + Minor;
72 	}
73 
74 	void SetFromString(const String &version_string);
75 
76 	inline bool operator < (const Version &other) const {
77 		return AsLongNumber() < other.AsLongNumber();
78 	}
79 
80 	inline bool operator <= (const Version &other) const {
81 		return AsLongNumber() <= other.AsLongNumber();
82 	}
83 
84 	inline bool operator > (const Version &other) const {
85 		return AsLongNumber() > other.AsLongNumber();
86 	}
87 
88 	inline bool operator >= (const Version &other) const {
89 		return AsLongNumber() >= other.AsLongNumber();
90 	}
91 
92 	inline bool operator == (const Version &other) const {
93 		return AsLongNumber() == other.AsLongNumber();
94 	}
95 
96 	inline bool operator != (const Version &other) const {
97 		return AsLongNumber() != other.AsLongNumber();
98 	}
99 
100 private:
101 	void MakeString();
102 };
103 
104 } // namespace Shared
105 } // namespace AGS
106 } // namespace AGS3
107 
108 #endif
109