diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-01-27 22:31:07 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-02 00:14:06 +0200 |
commit | 791221e923586bb717396ecf18bd13e57034df99 (patch) | |
tree | 9f608af07375b38626c8964671620477158341ba /depends/util/include | |
parent | 593111b14463e9d5d08256061b981b5ab1cfb710 (diff) | |
download | MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.gz MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.lz MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.xz MultiMC-791221e923586bb717396ecf18bd13e57034df99.zip |
NOISSUE Refactors and moving of things
Diffstat (limited to 'depends/util/include')
-rw-r--r-- | depends/util/include/modutils.h | 68 |
1 files changed, 60 insertions, 8 deletions
diff --git a/depends/util/include/modutils.h b/depends/util/include/modutils.h index 1fecd4d5..bc608f96 100644 --- a/depends/util/include/modutils.h +++ b/depends/util/include/modutils.h @@ -30,24 +30,76 @@ private: QString m_string; struct Section { - explicit Section(const QString &str, const int num) : numValid(true), number(num), string(str) {} - explicit Section(const QString &str) : numValid(false), string(str) {} + 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; - int number; - QString string; + bool numValid = false; + int m_numPart = 0; + QString m_stringPart; + QString m_fullString; inline bool operator!=(const Section &other) const { - return (numValid && other.numValid) ? (number != other.number) : (string != other.string); + 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 { - return (numValid && other.numValid) ? (number < other.number) : (string < other.string); + 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 { - return (numValid && other.numValid) ? (number > other.number) : (string > other.string); + 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; |