FS2_Open
Open source remastering of the Freespace 2 engine
version.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 #include "globalincs/pstypes.h"
11 #include "globalincs/version.h"
12 
13 namespace version
14 {
15  bool check_at_least(int major, int minor, int build, int revision)
16  {
17  if (FS_VERSION_MAJOR < major)
18  {
19  return false;
20  }
21  if (FS_VERSION_MAJOR > major)
22  {
23  // Major is greater than the given version => the rest doesn't matter
24  return true;
25  }
26  // major is now equal to our major version
27 
28  if (FS_VERSION_MINOR < minor)
29  {
30  return false;
31  }
32  if (FS_VERSION_MINOR > minor)
33  {
34  // Minor is greater than the given version => the rest doesn't matter
35  return true;
36  }
37  // minor is now equal to our minor version
38 
39  if (FS_VERSION_BUILD < build)
40  {
41  return false;
42  }
43  if (FS_VERSION_BUILD > build)
44  {
45  // build is greater than the given version => the rest doesn't matter
46  return true;
47  }
48  // build is now equal to our build version
49 
50  if (revision == 0)
51  {
52  // Special case, if there is no revision info, skip it
53  return true;
54  }
55  if (FS_VERSION_REVIS == 0)
56  {
57  // Special case, when there is no revision ignore it
58  return true;
59  }
60 
61  if (FS_VERSION_REVIS < revision)
62  {
63  return false;
64  }
65  if (FS_VERSION_REVIS > revision)
66  {
67  // build is greater than the given version => the rest doesn't matter
68  return true;
69  }
70 
71  // revision is now equal to our revision version
72  return true;
73  }
74 
75  SCP_string format_version(int major, int minor, int build, int revision)
76  {
78 
79  ss << major << "." << minor << "." << build;
80 
81  if (revision != 0)
82  {
83  ss << "." << revision;
84  }
85 
86  return ss.str();
87  }
88 }
89 
std::basic_stringstream< char, std::char_traits< char >, std::allocator< char > > SCP_stringstream
Definition: vmallocator.h:23
#define FS_VERSION_MAJOR
Definition: version.h:37
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
#define FS_VERSION_MINOR
Definition: version.h:38
SCP_string format_version(int major, int minor, int build, int revision)
Returns the string representation of the passed version.
Definition: version.cpp:75
#define FS_VERSION_REVIS
Definition: version.h:40
bool check_at_least(int major, int minor, int build, int revision)
Checks if the current version is at least the given version.
Definition: version.cpp:15
#define FS_VERSION_BUILD
Definition: version.h:39