version_number_t: provide all comparison operators via Boost::Operators

This commit is contained in:
Moritz Bunkus 2019-09-11 20:54:41 +02:00
parent 0d4ecaee60
commit a47add8196
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
5 changed files with 20 additions and 3 deletions

View File

@ -16,6 +16,10 @@
v36.0.0. If it does, it will be updated to the built-in list changed in
v37.0.0. Fixes #2611.
## Build system changes
* Boost's Operators header library is now required.
# Version 37.0.0 "Leave It" 2019-08-24

View File

@ -94,8 +94,8 @@ programs and libraries you absolutely need are:
- [zlib](http://www.zlib.net/) — a compression library
- [Boost](http://www.boost.org/) — Several of Boost's libraries are
used: `RegEx`, `filesystem`, `system`, `math`, `Range`, `rational`,
`variant`. At least v1.49.0 is required.
used: `RegEx`, `filesystem`, `system`, `math`, `operators`, `Range`,
`rational`, `variant`. At least v1.49.0 is required.
- [libxslt's xsltproc binary](http://xmlsoft.org/libxslt/) and
[DocBook XSL stylesheets](https://sourceforge.net/projects/docbook/files/docbook-xsl/)

View File

@ -48,6 +48,10 @@ if test x"$ac_cv_header_boost_integer_common_factor_hpp" != xyes; then
])
fi
AX_BOOST_CHECK_HEADERS([boost/operators.hpp],,[
AC_MSG_ERROR([Boost's Operators library is required but wasn't found])
])
AX_BOOST_CHECK_HEADERS([boost/range.hpp],,[
AC_MSG_ERROR([Boost's Range library is required but wasn't found])
])

View File

@ -102,6 +102,13 @@ version_number_t::operator <(const version_number_t &cmp)
return compare(cmp) == -1;
}
bool
version_number_t::operator ==(const version_number_t &cmp)
const
{
return compare(cmp) == 0;
}
std::string
version_number_t::to_string()
const

View File

@ -16,6 +16,7 @@
#include "common/common_pch.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/operators.hpp>
#include "common/xml/xml.h"
@ -24,7 +25,7 @@
#define MTX_DOWNLOAD_URL "https://mkvtoolnix.download/downloads.html"
#define MTX_NEWS_URL "https://mkvtoolnix.download/doc/NEWS.md"
struct version_number_t {
struct version_number_t: boost::totally_ordered<version_number_t> {
std::vector<unsigned int> parts;
unsigned int build{};
bool valid{};
@ -33,6 +34,7 @@ struct version_number_t {
version_number_t(const std::string &s);
bool operator <(const version_number_t &cmp) const;
bool operator ==(const version_number_t &cmp) const;
int compare(const version_number_t &cmp) const;
std::string to_string() const;