30#include <boost/algorithm/string.hpp>
40#elif defined(VCS_SHORT_HASH) && defined(VCS_WC_MODIFIED)
41const std::string
revision = std::string(
VERSION) +
" (" + VCS_SHORT_HASH + (VCS_WC_MODIFIED ?
"-Modified" :
"-Clean") +
")";
49 : nums_(3,0), special_(
""), special_separator_(
'\0')
59 char special_separator,
const std::string& special)
60 : nums_(3,0), special_(special), special_separator_(special_separator)
70 , special_separator_(
'\0')
84 const std::string::size_type breakpoint_pos = v.find_first_not_of(
".0123456789");
85 std::string left_side;
86 if(breakpoint_pos != std::string::npos) {
87 const std::string right_side = v.substr(breakpoint_pos);
88 assert(right_side.empty() ==
false);
96 if(right_side.size() > 1) {
101 left_side = v.substr(0, breakpoint_pos);
116 for(std::size_t
i = 0; (
i <
s); ++
i) {
123 const std::size_t
s =
nums_.size();
125 std::ostringstream o;
126 for(std::size_t k = 0; k <
s; ++k) {
170 return nums_.size() <= 3;
178 template<
template<
typename>
class Fcn>
181 std::vector<unsigned int> lc = l.
components();
182 std::vector<unsigned int> rc = r.
components();
184 const std::size_t lsize = lc.size();
185 const std::size_t rsize = rc.size();
186 const std::size_t csize = std::max(lsize, rsize);
189 if(lsize < csize) lc.resize(csize, 0);
190 if(rsize < csize) rc.resize(csize, 0);
192 using comp_list = std::vector<unsigned int>;
193 using comp_pair = std::tuple<const comp_list&, const std::string&>;
204 return version_comparison_internal<std::equal_to>(l, r);
209 return version_comparison_internal<std::not_equal_to>(l, r);
214 return version_comparison_internal<std::less>(l, r);
219 return version_comparison_internal<std::greater>(l, r);
224 return version_comparison_internal<std::less_equal>(l, r);
229 return version_comparison_internal<std::greater_equal>(l, r);
236 }
else if(op_str ==
"!=") {
238 }
else if(op_str ==
"<") {
240 }
else if(op_str ==
"<=") {
242 }
else if(op_str ==
">") {
244 }
else if(op_str ==
">=") {
Represents version numbers.
std::string str() const
Serializes the version number into string form.
unsigned int revision_level() const
Retrieves the revision level (x3 in "x1.x2.x3").
void set_minor_version(unsigned int)
Sets the minor version number.
const std::string & special_version() const
Retrieves the special version suffix (e.g.
void set_major_version(unsigned int)
Sets the major version number.
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
const std::vector< unsigned int > & components() const
Read-only access to all numeric components.
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
std::vector< unsigned int > nums_
void set_revision_level(unsigned int)
Sets the revision level.
bool is_canonical() const
Whether the version number is considered canonical for mainline Wesnoth.
version_info()
Default constructor.
bool is_dev_version() const
Whether this version represents a development version of Wesnoth aka whether the minor version odd.
bool operator>(const version_info &l, const version_info &r)
Greater-than operator for version_info.
bool do_version_check(const version_info &a, VERSION_COMP_OP op, const version_info &b)
bool operator!=(const version_info &l, const version_info &r)
Inequality operator for version_info.
bool operator>=(const version_info &l, const version_info &r)
Greater-than-or-equal operator for version_info.
bool operator<=(const version_info &l, const version_info &r)
Less-than-or-equal operator for version_info.
bool operator==(const version_info &l, const version_info &r)
Equality operator for version_info.
VERSION_COMP_OP parse_version_op(const std::string &op_str)
bool operator<(const version_info &l, const version_info &r)
Less-than operator for version_info.
Interfaces for manipulating version numbers of engine, add-ons, etc.
New lexcical_cast header.
General math utility functions.
constexpr bool is_odd(T num)
Game configuration data as global variables.
const version_info min_savegame_version(MIN_SAVEGAME_VERSION)
const version_info test_version("test")
const version_info wesnoth_version(VERSION)
const std::string revision
constexpr bool portable_isalpha(int c)
std::vector< std::string > split(const config_attribute_value &val)
static map_location::direction s
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
#define MIN_SAVEGAME_VERSION
Some older savegames of Wesnoth cannot be loaded anymore, this variable defines the minimum required ...