29 #include <boost/algorithm/string.hpp> 39 #elif defined(VCS_SHORT_HASH) && defined(VCS_WC_MODIFIED) 40 const std::string revision = std::string(
VERSION) +
" (" + VCS_SHORT_HASH + (VCS_WC_MODIFIED ?
"-Modified" :
"-Clean") +
")";
48 : nums_(3,0), special_(
""), special_separator_(
'\0')
58 char special_separator,
const std::string& special)
83 const std::string::size_type breakpoint_pos = v.find_first_not_of(
".0123456789");
84 std::string left_side;
85 if(breakpoint_pos != std::string::npos) {
86 const std::string right_side = v.substr(breakpoint_pos);
87 assert(right_side.empty() ==
false);
89 if(std::isalpha(right_side[0], std::locale::classic())) {
95 if(right_side.size() > 1) {
100 left_side = v.substr(0, breakpoint_pos);
107 const std::size_t
s = components.size();
115 for(std::size_t
i = 0; (
i <
s); ++
i) {
116 nums_[
i] = lexical_cast_default<unsigned int>(components[
i]);
122 const std::size_t
s =
nums_.size();
124 std::ostringstream o;
125 for(std::size_t k = 0; k <
s; ++k) {
169 return nums_.size() <= 3;
173 template<
template<
typename>
class Fcn>
176 std::vector<unsigned int> lc = l.
components();
177 std::vector<unsigned int> rc = r.
components();
179 const std::size_t lsize = lc.size();
180 const std::size_t rsize = rc.size();
181 const std::size_t csize = std::max(lsize, rsize);
184 if(lsize < csize) lc.resize(csize, 0);
185 if(rsize < csize) rc.resize(csize, 0);
187 using comp_list = std::vector<unsigned int>;
188 using comp_pair = std::tuple<const comp_list&, const std::string&>;
199 return version_comparison_internal<std::equal_to>(l, r);
204 return version_comparison_internal<std::not_equal_to>(l, r);
209 return version_comparison_internal<std::less>(l, r);
214 return version_comparison_internal<std::greater>(l, r);
219 return version_comparison_internal<std::less_equal>(l, r);
224 return version_comparison_internal<std::greater_equal>(l, r);
231 }
else if(op_str ==
"!=") {
233 }
else if(op_str ==
"<") {
235 }
else if(op_str ==
"<=") {
237 }
else if(op_str ==
">") {
239 }
else if(op_str ==
">=") {
Interfaces for manipulating version numbers of engine, add-ons, etc.
VERSION_COMP_OP parse_version_op(const std::string &op_str)
New lexcical_cast header.
void set_major_version(unsigned int)
Sets the major version number.
unsigned int revision_level() const
Retrieves the revision level (x3 in "x1.x2.x3").
void set_revision_level(unsigned int)
Sets the revision level.
bool do_version_check(const version_info &a, VERSION_COMP_OP op, const version_info &b)
const std::string & special_version() const
Retrieves the special version suffix (e.g.
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
void trim(string_view &s)
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.
const version_info test_version("test")
const std::vector< unsigned int > & components() const
Read-only access to all numeric components.
bool operator==(const version_info &l, const version_info &r)
Equality operator for version_info.
bool operator<(const version_info &l, const version_info &r)
Less-than operator for version_info.
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
void set_minor_version(unsigned int)
Sets the minor version number.
bool operator!=(const version_info &l, const version_info &r)
Inequality operator for version_info.
bool is_canonical() const
Whether the version number is considered canonical for mainline Wesnoth.
#define MIN_SAVEGAME_VERSION
Some older savegames of Wesnoth cannot be loaded anymore, this variable defines the minimum required ...
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
const std::string revision
Game configuration data as global variables.
static map_location::DIRECTION s
const version_info wesnoth_version(VERSION)
Represents version numbers.
std::vector< std::string > split(const config_attribute_value &val)
std::string str() const
Serializes the version number into string form.
version_info()
Default constructor.
const version_info min_savegame_version(MIN_SAVEGAME_VERSION)
std::vector< unsigned int > nums_
bool operator>(const version_info &l, const version_info &r)
Greater-than operator for version_info.