31 #include <boost/algorithm/string.hpp>
41 #elif defined(VCS_SHORT_HASH) && defined(VCS_WC_MODIFIED)
42 const std::string
revision = std::string(
VERSION) +
" (" + VCS_SHORT_HASH + (VCS_WC_MODIFIED ?
"-Modified" :
"-Clean") +
")";
50 : nums_(3,0), special_(
""), special_separator_(
'\0')
60 char special_separator,
const std::string& special)
61 : nums_(3,0), special_(special), special_separator_(special_separator)
71 , special_separator_(
'\0')
85 const std::string::size_type breakpoint_pos = v.find_first_not_of(
".0123456789");
86 std::string left_side;
87 if(breakpoint_pos != std::string::npos) {
88 const std::string right_side = v.substr(breakpoint_pos);
89 assert(right_side.empty() ==
false);
91 if(std::isalpha(right_side[0], std::locale::classic())) {
97 if(right_side.size() > 1) {
102 left_side = v.substr(0, breakpoint_pos);
117 for(std::size_t
i = 0; (
i <
s); ++
i) {
124 const std::size_t
s =
nums_.size();
126 std::ostringstream o;
127 for(std::size_t k = 0; k <
s; ++k) {
171 return nums_.size() <= 3;
179 template<
template<
typename>
class Fcn>
182 std::vector<unsigned int> lc = l.
components();
183 std::vector<unsigned int> rc = r.
components();
185 const std::size_t lsize = lc.size();
186 const std::size_t rsize = rc.size();
187 const std::size_t csize = std::max(lsize, rsize);
190 if(lsize < csize) lc.resize(csize, 0);
191 if(rsize < csize) rc.resize(csize, 0);
193 using comp_list = std::vector<unsigned int>;
194 using comp_pair = std::tuple<const comp_list&, const std::string&>;
205 return version_comparison_internal<std::equal_to>(l, r);
210 return version_comparison_internal<std::not_equal_to>(l, r);
215 return version_comparison_internal<std::less>(l, r);
220 return version_comparison_internal<std::greater>(l, r);
225 return version_comparison_internal<std::less_equal>(l, r);
230 return version_comparison_internal<std::greater_equal>(l, r);
237 }
else if(op_str ==
"!=") {
239 }
else if(op_str ==
"<") {
241 }
else if(op_str ==
"<=") {
243 }
else if(op_str ==
">") {
245 }
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").
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.
const std::vector< unsigned int > & components() const
Read-only access to all numeric components.
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
void trim(std::string_view &s)
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 ...