23 : nums_(3,0), special_(
""), special_separator_(
'\0')
29 : nums_(3,0), special_(special), special_separator_(special_separator)
39 , special_separator_(
'\0')
53 const std::string::size_type breakpoint_pos = v.find_first_not_of(
".0123456789");
55 if(breakpoint_pos != std::string::npos) {
56 const std::string right_side = v.substr(breakpoint_pos);
57 assert(right_side.empty() ==
false);
59 if((right_side[0] >=
'A' && right_side[0] <=
'Z') || (right_side[0] >=
'a' && right_side[0] <=
'z')) {
65 if(right_side.size() > 1) {
70 left_side = v.substr(0, breakpoint_pos);
77 const size_t s = components.size();
85 for(
size_t i = 0; (
i <
s); ++
i) {
86 nums_[
i] = lexical_cast_default<unsigned int>(components[
i]);
92 const size_t s =
nums_.size();
95 for(
size_t k = 0; k <
s; ++k) {
139 return nums_.size() <= 3;
156 template<
typename _Toperator,
typename _Tfallback_operator>
157 bool recursive_order_operation(
const std::vector<unsigned int>&
l,
const std::vector<unsigned int>&
r,
size_t k)
159 if(k >= l.size() || k >= r.size()) {
163 unsigned int const& lvalue = l[k];
164 unsigned int const& rvalue = r[k];
167 _Tfallback_operator fallback_o;
169 bool ret = o(lvalue, rvalue);
170 if((!ret) && fallback_o(lvalue, rvalue)) {
171 ret = recursive_order_operation<_Toperator, _Tfallback_operator>(
l,
r,++k);
177 #pragma warning (push)
178 #pragma warning (disable: 4706)
182 std::vector<unsigned int> lc = l.
components();
183 std::vector<unsigned int> rc = r.
components();
185 const size_t lsize = lc.size();
186 const size_t rsize = rc.size();
187 const size_t csize = std::max(lsize, rsize);
190 if(lsize < csize) lc.resize(csize, 0);
191 if(rsize < csize) rc.resize(csize, 0);
195 const std::vector<unsigned int>& lcc = lc;
196 const std::vector<unsigned int>& rcc = rc;
200 case EQUAL:
case NOT_EQUAL: {
201 for(
size_t i = 0;
i < csize; ++
i) {
202 unsigned int const& lvalue = lc[
i];
203 unsigned int const& rvalue = rc[
i];
205 if((result = (lvalue != rvalue))) {
207 #pragma warning (pop)
213 result = result && lvalue == rvalue;
222 result = recursive_order_operation<std::less<unsigned int>, std::equal_to<unsigned int> >(lcc, rcc, 0);
225 result = recursive_order_operation<std::greater<unsigned int>, std::equal_to<unsigned int> >(lcc, rcc, 0);
248 return version_numbers_comparison_internal(l, r, LT) || (
249 version_numbers_comparison_internal(l, r, EQUAL) && (
258 return version_numbers_comparison_internal(l, r, GT) || (
259 version_numbers_comparison_internal(l, r, EQUAL) && (
268 return l < r || l ==
r;
273 return l > r || l ==
r;
280 }
else if(op_str ==
"!=") {
282 }
else if(op_str ==
"<") {
284 }
else if(op_str ==
"<=") {
286 }
else if(op_str ==
">") {
288 }
else if(op_str ==
">=") {
bool is_canonical() const
Whether the version number is considered canonical for mainline Wesnoth.
VERSION_COMP_OP parse_version_op(const std::string &op_str)
bool operator>(const version_info &l, const version_info &r)
Greater-than operator for version_info.
void set_major_version(unsigned int)
Sets the major version number.
void set_revision_level(unsigned int)
Sets the revision level.
const std::vector< unsigned int > & components() const
Read-only access to all numeric components.
std::string & strip(std::string &str)
Remove whitespace from the front and back of the string 'str'.
GLdouble GLdouble GLdouble b
GLboolean GLboolean GLboolean GLboolean a
Templates and utility-routines for strings and numbers.
void set_minor_version(unsigned int)
Sets the minor version number.
GLenum GLenum GLuint components
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").
bool operator>=(const version_info &l, const version_info &r)
Greater-than-or-equal operator for version_info.
unsigned int minor_version() const
Retrieves the minor version number (x2 in "x1.x2.x3").
bool operator<(const version_info &l, const version_info &r)
Less-than operator for version_info.
bool operator!=(const version_info &l, const version_info &r)
Inequality operator for version_info.
unsigned int major_version() const
Retrieves the major version number (x1 in "x1.x2.x3").
GLdouble GLdouble GLdouble r
Represents version numbers.
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
bool do_version_check(const version_info &a, VERSION_COMP_OP op, const version_info &b)
version_info()
Default constructor.
const std::string & special_version() const
Retrieves the special version suffix (e.g.
bool operator==(const version_info &l, const version_info &r)
Equality operator for version_info.
Interfaces for manipulating version numbers of engine, add-ons, etc.
std::vector< unsigned int > nums_
GLsizei const GLcharARB ** string
bool operator<=(const version_info &l, const version_info &r)
Less-than-or-equal operator for version_info.