xoreos  0.0.5
version.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos 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 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_NWN_VERSION_H
26 #define ENGINES_NWN_VERSION_H
27 
28 #include "src/common/types.h"
29 
30 #include "src/aurora/types.h"
31 
32 namespace Common {
33  class UString;
34 }
35 
36 namespace Engines {
37 
38 namespace NWN {
39 
40 class Version {
41 public:
42  Version(Aurora::Platform platform);
43  ~Version();
44 
46  bool detect(const Common::UString &directory);
47 
49  bool hasVersion() const;
50 
52 
54 
55  uint64 getVersion() const;
56  uint16 getVersionMajor() const;
57  uint16 getVersionMinor() const;
58  uint16 getVersionBuild() const;
59 
61 
62  bool isTooOld() const;
63  bool isTooNew() const;
64 
65  static uint64 getOptimumVersion();
69 
71 
72 private:
73  static const uint16 kOptimumVersionMajor = 1;
74  static const uint16 kOptimumVersionMinor = 69;
75  static const uint16 kOptimumVersionBuild = 8109;
76 
78 
83 
84  bool detectWindows(const Common::UString &directory);
85  bool detectMacOSX (const Common::UString &directory);
86  bool detectLinux (const Common::UString &directory);
87 
88  byte *readFile(const Common::UString &directory, const Common::UString &file, size_t &size);
89  byte *readFile(const Common::UString &path, size_t &size);
90 };
91 
92 } // End of namespace NWN
93 
94 } // End of namespace Engines
95 
96 #endif // ENGINES_NWN_VERSION_H
bool detectWindows(const Common::UString &directory)
Definition: version.cpp:149
static const uint16 kOptimumVersionMinor
Definition: version.h:74
uint16 getVersionBuild() const
Return the build number.
Definition: version.cpp:90
Definition: 2dafile.h:39
bool isTooNew() const
Is this version newer than the optimum?
Definition: version.cpp:123
uint64 getVersion() const
Return the combined version.
Definition: version.cpp:78
A class holding an UTF-8 string.
Definition: ustring.h:48
bool isTooOld() const
Is this version older than the optimum?
Definition: version.cpp:119
uint64_t uint64
Definition: types.h:206
uint16 getVersionMinor() const
Return the minor version.
Definition: version.cpp:86
bool detect(const Common::UString &directory)
Try to detect the version of the NWN installation in this directory.
Definition: version.cpp:130
uint16 _versionMajor
v1.69.8109 -> 1
Definition: version.h:79
static uint64 getOptimumVersion()
Return the optimum combined version.
Definition: version.cpp:98
static const uint16 kOptimumVersionMajor
Definition: version.h:73
uint16 _versionMinor
v1.69.8109 -> 69
Definition: version.h:80
static const uint16 kOptimumVersionBuild
Definition: version.h:75
uint16_t uint16
Definition: types.h:202
byte * readFile(const Common::UString &directory, const Common::UString &file, size_t &size)
Definition: version.cpp:331
Common::UString getVersionString() const
Definition: version.cpp:94
Common::UString getPlatformName() const
Definition: version.cpp:74
static uint16 getOptimumVersionMajor()
Return the optimum major version.
Definition: version.cpp:102
static Common::UString getOptimumVersionString()
Definition: version.cpp:114
uint16 _versionBuild
v1.69.8109 -> 8109
Definition: version.h:81
Version(Aurora::Platform platform)
Definition: version.cpp:58
Low-level type definitions to handle fixed width types portably.
static uint16 getOptimumVersionMinor()
Return the optimum minor version.
Definition: version.cpp:106
Aurora::Platform getPlatform() const
Definition: version.cpp:70
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
bool detectMacOSX(const Common::UString &directory)
Definition: version.cpp:224
uint64 _version
The combined version number.
Definition: version.h:82
static uint16 getOptimumVersionBuild()
Return the optimum build number.
Definition: version.cpp:110
Aurora::Platform _platform
Definition: version.h:77
bool hasVersion() const
Did we detect a version?
Definition: version.cpp:66
uint16 getVersionMajor() const
Return the major version.
Definition: version.cpp:82
bool detectLinux(const Common::UString &directory)
Definition: version.cpp:283
Platform
Definition: types.h:429
uint8 byte
Definition: types.h:209