MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / parse

Method parse

launcher/Version.cpp:74–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void Version::parse()
75{
76 m_sections.clear();
77 QString currentSection;
78
79 if (m_string.isEmpty())
80 return;
81
82 auto classChange = [&](QChar lastChar, QChar currentChar) {
83 if (lastChar.isNull())
84 return false;
85 if (lastChar.isDigit() != currentChar.isDigit())
86 return true;
87
88 const QList<QChar> s_separators{ '.', '-', '+' };
89 if (s_separators.contains(currentChar) && currentSection.at(0) != currentChar)
90 return true;
91
92 return false;
93 };
94
95 currentSection += m_string.at(0);
96 for (int i = 1; i < m_string.size(); ++i) {
97 const auto& current_char = m_string.at(i);
98 if (classChange(m_string.at(i - 1), current_char)) {
99 if (!currentSection.isEmpty())
100 m_sections.append(Section(currentSection));
101 currentSection = "";
102 }
103
104 currentSection += current_char;
105 }
106
107 if (!currentSection.isEmpty())
108 m_sections.append(Section(currentSection));
109}
110
111/// qDebug print support for the Version class
112QDebug operator<<(QDebug debug, const Version& v)

Callers 1

messageReceivedMethod · 0.45

Calls 8

SectionClass · 0.85
isDigitMethod · 0.80
appendMethod · 0.80
clearMethod · 0.45
isEmptyMethod · 0.45
containsMethod · 0.45
atMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected