File: version.h

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (103 lines) | stat: -rw-r--r-- 2,633 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * Copyright (C) Volition, Inc. 1999.  All rights reserved.
 *
 * All source code herein is the property of Volition, Inc. You may not sell 
 * or otherwise commercially exploit the source or things you created based on the 
 * source.
 *
*/



#ifndef __FS2_VERSIONING_HEADER_FILE
#define __FS2_VERSIONING_HEADER_FILE

#include "globalincs/vmallocator.h"

// ----------------------------------------------------------------------------------------------------------------
// VERSION DEFINES/VARS
//

// Here are the version defines.  
//	Gets displayed as MAJOR.MINOR, or 1.21 if MAJOR = 1, MINOR = 21.
//	Prior to release, MAJOR should be zero.  After release, it should be 1.  Probably never increase to 2 as that could
//	cause confusion with a sequel.
//	MINOR should increase by 1 for each minor upgrade and by 10 for major upgrades.
//	With each rev we send, we should increase MINOR.
// Version history (full version):
//		1.0	Initial US/UK release
//		1.01	Patch for Win95 volume label bug
//		1.20	German release version


// fs2_open version numbers:
//   the first version is 3.0 :-)
//   Major.Minor.Bugfix

#include "project.h"

// The GCC POSIX headers seem to think defining a common word like "major" is a good idea...
// FYI, no it isn't.
#ifdef major
#undef major
#endif
#ifdef minor
#undef minor
#endif

namespace gameversion {

struct version {
	int major = 0;
	int minor = 0;
	int build = 0;
	int revision = 0;

	version() = default;

	version(int major, int minor = 0, int build = 0, int revision = 0);

	version(const SCP_string& semver, int missing = -1);
	
	bool isValid() const;

	bool operator<(const version& other) const;
	bool operator==(const version& other) const;
	bool operator!=(const version& other) const;
	bool operator>(const version& rhs) const;
	bool operator<=(const version& rhs) const;
	bool operator>=(const version& rhs) const;
};

version parse_version();
version parse_version_inline();

version get_executable_version();

/**
 * @brief Checks if the current version is at least the given version
 *
 * @param v The version to check
 *
 * @returns @c true when we are at least the given version, @c false otherwise
 */
bool check_at_least(const version& v);

/**
 * @brief Returns the string representation of the passed version
 * @param v The version to format
 * @param exclude_build Whether to exclude the build and revision numbers (i.e. only print major and minor)
 * @returns A string representation of the version number
 */
SCP_string format_version(const version& v, bool exclude_build = false);

/**
 * @brief
 * @return
 */
SCP_string get_version_string();

}


#endif