ScummVM API documentation
version.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 //=============================================================================
23 //
24 // Class, depicting version of the AGS engine
25 //
26 //=============================================================================
27 
28 #ifndef AGS_SHARED_UTIL_VERSION_H
29 #define AGS_SHARED_UTIL_VERSION_H
30 
31 #include "ags/shared/util/string.h"
32 
33 namespace AGS3 {
34 namespace AGS {
35 namespace Shared {
36 
37 using Shared::String;
38 
39 struct Version {
40  int32_t Major;
41  int32_t Minor;
42  int32_t Release;
43  int32_t Revision;
44  String Special;
45  String BuildInfo;
46 
47  String LongString;
48  String ShortString;
49  String BackwardCompatibleString;
50 
51  Version();
52  Version(int32_t major, int32_t minor, int32_t release);
53  Version(int32_t major, int32_t minor, int32_t release, int32_t revision);
54  Version(int32_t major, int32_t minor, int32_t release, int32_t revision, const String &special);
55  Version(int32_t major, int32_t minor, int32_t release, int32_t revision, const String &special, const String &build_info);
56  Version(const String &version_string);
57 
58  inline int32_t AsNumber() const {
59  return Major * 10000 + Minor * 100 + Release;
60  }
61 
62  inline int64_t AsLongNumber() const {
63  return (int64_t)Major * 100000000L + (int64_t)Minor * 1000000L + (int64_t)Release * 10000L + Revision;
64  }
65 
66  inline int32_t AsSmallNumber() const {
67  return Major * 100 + Minor;
68  }
69 
70  void SetFromString(const String &version_string);
71 
72  inline bool operator < (const Version &other) const {
73  return AsLongNumber() < other.AsLongNumber();
74  }
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 private:
97  void MakeString();
98 };
99 
100 } // namespace Shared
101 } // namespace AGS
102 } // namespace AGS3
103 
104 #endif
Definition: achievements_tables.h:27
Definition: version.h:39
Definition: string.h:62
Definition: ags.h:40