1 //============================================================================= 2 // 3 // Adventure Game Studio (AGS) 4 // 5 // Copyright (C) 1999-2011 Chris Jones and 2011-20xx others 6 // The full list of copyright holders can be found in the Copyright.txt 7 // file, which is part of this source code distribution. 8 // 9 // The AGS source code is provided under the Artistic License 2.0. 10 // A copy of this license can be found in the file License.txt and at 11 // http://www.opensource.org/licenses/artistic-license-2.0.php 12 // 13 //============================================================================= 14 // 15 // Class, depicting version of the AGS engine 16 // 17 //============================================================================= 18 #ifndef __AGS_CN_MAIN__VERSION_H 19 #define __AGS_CN_MAIN__VERSION_H 20 21 #include "util/string.h" 22 23 namespace AGS 24 { 25 namespace Common 26 { 27 28 using Common::String; 29 30 struct Version 31 { 32 int32_t Major; 33 int32_t Minor; 34 int32_t Release; 35 int32_t Revision; 36 String Special; 37 String BuildInfo; 38 39 String LongString; 40 String ShortString; 41 String BackwardCompatibleString; 42 43 // Last engine version, using different version format than AGS Editor (3.22.1120 / 3.2.2.1120) 44 static const Version LastOldFormatVersion; 45 46 Version(); 47 Version(int32_t major, int32_t minor, int32_t release); 48 Version(int32_t major, int32_t minor, int32_t release, int32_t revision); 49 Version(int32_t major, int32_t minor, int32_t release, int32_t revision, const String &special); 50 Version(int32_t major, int32_t minor, int32_t release, int32_t revision, const String &special, const String &build_info); 51 Version(const String &version_string); 52 AsNumberVersion53 inline int32_t AsNumber() const 54 { 55 return Major * 10000 + Minor * 100 + Release; 56 } 57 AsLongNumberVersion58 inline int64_t AsLongNumber() const 59 { 60 return (int64_t)Major * 100000000L + (int64_t)Minor * 1000000L + (int64_t)Release * 10000L + Revision; 61 } 62 AsSmallNumberVersion63 inline int32_t AsSmallNumber() const 64 { 65 return Major * 100 + Minor; 66 } 67 68 void SetFromString(const String &version_string); 69 70 inline bool operator < (const Version &other) const 71 { 72 return AsLongNumber() < other.AsLongNumber(); 73 } 74 75 inline bool operator <= (const Version &other) const 76 { 77 return AsLongNumber() <= other.AsLongNumber(); 78 } 79 80 inline bool operator > (const Version &other) const 81 { 82 return AsLongNumber() > other.AsLongNumber(); 83 } 84 85 inline bool operator >= (const Version &other) const 86 { 87 return AsLongNumber() >= other.AsLongNumber(); 88 } 89 90 inline bool operator == (const Version &other) const 91 { 92 return AsLongNumber() == other.AsLongNumber(); 93 } 94 95 inline bool operator != (const Version &other) const 96 { 97 return AsLongNumber() != other.AsLongNumber(); 98 } 99 100 private: 101 void MakeString(); 102 }; 103 104 } // namespace Common 105 } // namespace AGS 106 107 #endif // __AGS_CN_MAIN__VERSION_H 108