MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / parse

Method parse

launcher/Version.cpp:101–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99} // namespace
100
101void Version::parse()
102{
103 auto len = m_string.size();
104 for (int i = 0; i < len;) {
105 Section cur(Section::Type::Textual);
106 auto c = m_string.at(i);
107 if (c == '+') {
108 break; // Ignore appendices
109 }
110 // custom: the space is special to handle the strings like "1.20 Pre-Release 1"
111 // this is needed to support Modrinth versions
112 if (c == '-' || c == ' ') {
113 // Add dash to component
114 cur.value += c;
115 i++;
116 // If the next rune is non-digit, mark as pre-release (requires >= 1 non-digit after dash so the component has length > 1)
117 if (i < len && !m_string.at(i).isDigit()) {
118 cur.t = Section::Type::PreRelease;
119 }
120 } else if (c.isDigit()) {
121 // Mark as numeric
122 cur.t = Section::Type::Numeric;
123 }
124 for (; i < len; i++) {
125 auto r = m_string.at(i);
126 if ((r.isDigit() != (cur.t == Section::Type::Numeric)) // starts a new section
127 || (r == ' ' && cur.t == Section::Type::Numeric) // custom: numeric section then a space is a pre-release
128 || (r == '-' && cur.t != Section::Type::PreRelease) // "---" is a valid pre-release component
129 || r == '+') {
130 // Run completed (do not consume this rune)
131 break;
132 }
133 // Add rune to current run
134 cur.value += r;
135 }
136 if (!cur.value.isEmpty()) {
137 if (cur.t == Section::Type::Numeric) {
138 removeLeadingZeros(cur.value);
139 }
140 m_sections.append(cur);
141 }
142 }
143}
144
145std::strong_ordering Version::operator<=>(const Version& other) const
146{

Callers 4

processZipPackMethod · 0.45
messageReceivedMethod · 0.45
mergeZipFilesFunction · 0.45
extractSubDirFunction · 0.45

Calls 6

removeLeadingZerosFunction · 0.85
isDigitMethod · 0.80
appendMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected