2014-02-02 13:05:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
2022-05-02 19:34:55 +00:00
|
|
|
#include <QStringView>
|
2014-09-06 16:16:56 +00:00
|
|
|
#include <QList>
|
|
|
|
|
2014-02-02 13:05:07 +00:00
|
|
|
class QUrl;
|
|
|
|
|
2021-07-25 17:11:59 +00:00
|
|
|
class Version
|
2014-02-02 13:05:07 +00:00
|
|
|
{
|
2018-06-28 21:18:45 +00:00
|
|
|
public:
|
2018-07-15 12:51:05 +00:00
|
|
|
Version(const QString &str);
|
|
|
|
Version() {}
|
2014-02-02 13:05:07 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
bool operator<(const Version &other) const;
|
|
|
|
bool operator<=(const Version &other) const;
|
|
|
|
bool operator>(const Version &other) const;
|
|
|
|
bool operator>=(const Version &other) const;
|
|
|
|
bool operator==(const Version &other) const;
|
|
|
|
bool operator!=(const Version &other) const;
|
2014-02-02 13:05:07 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
QString toString() const
|
|
|
|
{
|
|
|
|
return m_string;
|
|
|
|
}
|
2014-02-02 13:05:07 +00:00
|
|
|
|
|
|
|
private:
|
2018-07-15 12:51:05 +00:00
|
|
|
QString m_string;
|
|
|
|
struct Section
|
|
|
|
{
|
|
|
|
explicit Section(const QString &fullString)
|
|
|
|
{
|
|
|
|
m_fullString = fullString;
|
|
|
|
int cutoff = m_fullString.size();
|
|
|
|
for(int i = 0; i < m_fullString.size(); i++)
|
|
|
|
{
|
|
|
|
if(!m_fullString[i].isDigit())
|
|
|
|
{
|
|
|
|
cutoff = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-05-02 19:34:55 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
auto numPart = QStringView{m_fullString}.left(cutoff);
|
|
|
|
#else
|
2018-07-15 12:51:05 +00:00
|
|
|
auto numPart = m_fullString.leftRef(cutoff);
|
2022-05-02 19:34:55 +00:00
|
|
|
#endif
|
2018-07-15 12:51:05 +00:00
|
|
|
if(numPart.size())
|
|
|
|
{
|
|
|
|
numValid = true;
|
|
|
|
m_numPart = numPart.toInt();
|
|
|
|
}
|
2022-05-02 19:34:55 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
auto stringPart = QStringView{m_fullString}.mid(cutoff);
|
|
|
|
#else
|
2018-07-15 12:51:05 +00:00
|
|
|
auto stringPart = m_fullString.midRef(cutoff);
|
2022-05-02 19:34:55 +00:00
|
|
|
#endif
|
2018-07-15 12:51:05 +00:00
|
|
|
if(stringPart.size())
|
|
|
|
{
|
|
|
|
m_stringPart = stringPart.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
explicit Section() {}
|
|
|
|
bool numValid = false;
|
|
|
|
int m_numPart = 0;
|
|
|
|
QString m_stringPart;
|
|
|
|
QString m_fullString;
|
2014-09-06 16:16:56 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
inline bool operator!=(const Section &other) const
|
|
|
|
{
|
|
|
|
if(numValid && other.numValid)
|
|
|
|
{
|
|
|
|
return m_numPart != other.m_numPart || m_stringPart != other.m_stringPart;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_fullString != other.m_fullString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inline bool operator<(const Section &other) const
|
|
|
|
{
|
|
|
|
if(numValid && other.numValid)
|
|
|
|
{
|
|
|
|
if(m_numPart < other.m_numPart)
|
|
|
|
return true;
|
|
|
|
if(m_numPart == other.m_numPart && m_stringPart < other.m_stringPart)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_fullString < other.m_fullString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inline bool operator>(const Section &other) const
|
|
|
|
{
|
|
|
|
if(numValid && other.numValid)
|
|
|
|
{
|
|
|
|
if(m_numPart > other.m_numPart)
|
|
|
|
return true;
|
|
|
|
if(m_numPart == other.m_numPart && m_stringPart > other.m_stringPart)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_fullString > other.m_fullString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
QList<Section> m_sections;
|
2014-09-06 16:16:56 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
void parse();
|
2014-02-02 13:05:07 +00:00
|
|
|
};
|