diff options
Diffstat (limited to 'depends/util/include/modutils.h')
-rw-r--r-- | depends/util/include/modutils.h | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/depends/util/include/modutils.h b/depends/util/include/modutils.h deleted file mode 100644 index fde51881..00000000 --- a/depends/util/include/modutils.h +++ /dev/null @@ -1,113 +0,0 @@ -#pragma once - -#include <QString> -#include <QList> - -#include "multimc_util_export.h" - -class QUrl; - -namespace Util -{ -struct Version -{ - Version(const QString &str); - Version() {} - - 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; - - QString toString() const - { - return m_string; - } - -private: - 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; - - 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; - - void parse(); -}; - -MULTIMC_UTIL_EXPORT bool versionIsInInterval(const QString &version, const QString &interval); -MULTIMC_UTIL_EXPORT bool versionIsInInterval(const Version &version, const QString &interval); -} - |