2014-02-02 18:35:07 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
2014-09-06 21:46:56 +05:30
|
|
|
#include <QList>
|
|
|
|
|
2015-10-05 05:17:27 +05:30
|
|
|
#include "multimc_logic_export.h"
|
2014-02-02 18:35:07 +05:30
|
|
|
|
|
|
|
class QUrl;
|
|
|
|
|
2018-06-29 02:48:45 +05:30
|
|
|
class MULTIMC_LOGIC_EXPORT Version
|
2014-02-02 18:35:07 +05:30
|
|
|
{
|
2018-06-29 02:48:45 +05:30
|
|
|
public:
|
2018-07-15 18:21:05 +05:30
|
|
|
Version(const QString &str);
|
|
|
|
Version() {}
|
2014-02-02 18:35:07 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
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 18:35:07 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
QString toString() const
|
|
|
|
{
|
|
|
|
return m_string;
|
|
|
|
}
|
2014-02-02 18:35:07 +05:30
|
|
|
|
|
|
|
private:
|
2018-07-15 18:21:05 +05:30
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto numPart = m_fullString.leftRef(cutoff);
|
|
|
|
if(numPart.size())
|
|
|
|
{
|
|
|
|
numValid = true;
|
|
|
|
m_numPart = numPart.toInt();
|
|
|
|
}
|
|
|
|
auto stringPart = m_fullString.midRef(cutoff);
|
|
|
|
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 21:46:56 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
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 21:46:56 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
void parse();
|
2014-02-02 18:35:07 +05:30
|
|
|
};
|