MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / compare

Method compare

launcher/minecraft/mod/Mod.cpp:71–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71std::pair<int, bool> Mod::compare(const Resource& other, SortType type) const
72{
73 auto cast_other = dynamic_cast<Mod const*>(&other);
74 if (!cast_other)
75 return Resource::compare(other, type);
76
77 switch (type) {
78 default:
79 case SortType::ENABLED:
80 case SortType::NAME:
81 case SortType::DO_UPDATES:
82 case SortType::DATE: {
83 auto res = Resource::compare(other, type);
84 if (res.first != 0)
85 return res;
86 // FIXME: Determine if this is a legitimate fallthrough
87 [[fallthrough]];
88 }
89 case SortType::VERSION: {
90 auto this_ver = Version(version());
91 auto other_ver = Version(cast_other->version());
92 if (this_ver > other_ver)
93 return { 1, type == SortType::VERSION };
94 if (this_ver < other_ver)
95 return { -1, type == SortType::VERSION };
96 }
97 }
98 return { 0, false };
99}
100
101bool Mod::applyFilter(QRegularExpression filter) const
102{

Callers 3

runMethod · 0.45
subSortLessThanMethod · 0.45
lessThanMethod · 0.45

Calls 2

VersionClass · 0.70
versionMethod · 0.45

Tested by

no test coverage detected