Make BaseVersion const-correct in order to remove const-cast from Meta::Version
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#include "BaseVersion.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
bool JavaInstall::operator<(const JavaInstall& rhs)
|
||||
bool JavaInstall::operator<(const JavaInstall& rhs) const
|
||||
{
|
||||
auto archCompare = StringUtils::naturalCompare(arch, rhs.arch, Qt::CaseInsensitive);
|
||||
if (archCompare != 0)
|
||||
@@ -35,17 +35,17 @@ bool JavaInstall::operator<(const JavaInstall& rhs)
|
||||
return StringUtils::naturalCompare(path, rhs.path, Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
bool JavaInstall::operator==(const JavaInstall& rhs)
|
||||
bool JavaInstall::operator==(const JavaInstall& rhs) const
|
||||
{
|
||||
return arch == rhs.arch && id == rhs.id && path == rhs.path;
|
||||
}
|
||||
|
||||
bool JavaInstall::operator>(const JavaInstall& rhs)
|
||||
bool JavaInstall::operator>(const JavaInstall& rhs) const
|
||||
{
|
||||
return (!operator<(rhs)) && (!operator==(rhs));
|
||||
}
|
||||
|
||||
bool JavaInstall::operator<(BaseVersion& a)
|
||||
bool JavaInstall::operator<(BaseVersion& a) const
|
||||
{
|
||||
try {
|
||||
return operator<(dynamic_cast<JavaInstall&>(a));
|
||||
@@ -54,7 +54,7 @@ bool JavaInstall::operator<(BaseVersion& a)
|
||||
}
|
||||
}
|
||||
|
||||
bool JavaInstall::operator>(BaseVersion& a)
|
||||
bool JavaInstall::operator>(BaseVersion& a) const
|
||||
{
|
||||
try {
|
||||
return operator>(dynamic_cast<JavaInstall&>(a));
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
struct JavaInstall : public BaseVersion {
|
||||
JavaInstall() {}
|
||||
JavaInstall(QString id, QString arch, QString path) : id(id), arch(arch), path(path) {}
|
||||
virtual QString descriptor() override { return id.toString(); }
|
||||
virtual QString descriptor() const override { return id.toString(); }
|
||||
|
||||
virtual QString name() override { return id.toString(); }
|
||||
virtual QString name() const override { return id.toString(); }
|
||||
|
||||
virtual QString typeString() const override { return arch; }
|
||||
|
||||
virtual bool operator<(BaseVersion& a) override;
|
||||
virtual bool operator>(BaseVersion& a) override;
|
||||
bool operator<(const JavaInstall& rhs);
|
||||
bool operator==(const JavaInstall& rhs);
|
||||
bool operator>(const JavaInstall& rhs);
|
||||
virtual bool operator<(BaseVersion& a) const override;
|
||||
virtual bool operator>(BaseVersion& a) const override;
|
||||
bool operator<(const JavaInstall& rhs) const;
|
||||
bool operator==(const JavaInstall& rhs) const;
|
||||
bool operator>(const JavaInstall& rhs) const;
|
||||
|
||||
JavaVersion id;
|
||||
QString arch;
|
||||
|
||||
@@ -78,7 +78,7 @@ MetadataPtr parseJavaMeta(const QJsonObject& in)
|
||||
return meta;
|
||||
}
|
||||
|
||||
bool Metadata::operator<(const Metadata& rhs)
|
||||
bool Metadata::operator<(const Metadata& rhs) const
|
||||
{
|
||||
auto id = version;
|
||||
if (id < rhs.version) {
|
||||
@@ -97,17 +97,17 @@ bool Metadata::operator<(const Metadata& rhs)
|
||||
return StringUtils::naturalCompare(m_name, rhs.m_name, Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
bool Metadata::operator==(const Metadata& rhs)
|
||||
bool Metadata::operator==(const Metadata& rhs) const
|
||||
{
|
||||
return version == rhs.version && m_name == rhs.m_name;
|
||||
}
|
||||
|
||||
bool Metadata::operator>(const Metadata& rhs)
|
||||
bool Metadata::operator>(const Metadata& rhs) const
|
||||
{
|
||||
return (!operator<(rhs)) && (!operator==(rhs));
|
||||
}
|
||||
|
||||
bool Metadata::operator<(BaseVersion& a)
|
||||
bool Metadata::operator<(BaseVersion& a) const
|
||||
{
|
||||
try {
|
||||
return operator<(dynamic_cast<Metadata&>(a));
|
||||
@@ -116,7 +116,7 @@ bool Metadata::operator<(BaseVersion& a)
|
||||
}
|
||||
}
|
||||
|
||||
bool Metadata::operator>(BaseVersion& a)
|
||||
bool Metadata::operator>(BaseVersion& a) const
|
||||
{
|
||||
try {
|
||||
return operator>(dynamic_cast<Metadata&>(a));
|
||||
|
||||
@@ -32,17 +32,17 @@ enum class DownloadType { Manifest, Archive, Unknown };
|
||||
|
||||
class Metadata : public BaseVersion {
|
||||
public:
|
||||
virtual QString descriptor() override { return version.toString(); }
|
||||
virtual QString descriptor() const override { return version.toString(); }
|
||||
|
||||
virtual QString name() override { return m_name; }
|
||||
virtual QString name() const override { return m_name; }
|
||||
|
||||
virtual QString typeString() const override { return vendor; }
|
||||
|
||||
virtual bool operator<(BaseVersion& a) override;
|
||||
virtual bool operator>(BaseVersion& a) override;
|
||||
bool operator<(const Metadata& rhs);
|
||||
bool operator==(const Metadata& rhs);
|
||||
bool operator>(const Metadata& rhs);
|
||||
virtual bool operator<(BaseVersion& a) const override;
|
||||
virtual bool operator>(BaseVersion& a) const override;
|
||||
bool operator<(const Metadata& rhs) const;
|
||||
bool operator==(const Metadata& rhs) const;
|
||||
bool operator>(const Metadata& rhs) const;
|
||||
|
||||
QString m_name;
|
||||
QString vendor;
|
||||
|
||||
Reference in New Issue
Block a user