MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / FindBestVersion

Function FindBestVersion

Source/VersionChecker.cpp:92–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90using ft_version_t = std::tuple<int, int, int, int>;
91
92std::pair<nlohmann::json, ft_version_t> FindBestVersion(const nlohmann::json &j) {
93 ft_version_t current = {VERSION_API, VERSION_MAJ, VERSION_MIN, VERSION_REV};
94 const nlohmann::json *jPtr = nullptr;
95
96 for (const auto &i : j) {
97 ft_version_t ver = { };
98 auto &[api, maj, min, rev] = ver;
99 const std::string &tag = i["tag_name"];
100 ::sscanf_s(tag.data(), "v%u.%u.%u%*1[.r]%u", &api, &maj, &min, &rev);
101 if (ver > current) {
102 current = ver;
103 jPtr = &i;
104 }
105 }
106
107 return std::make_pair(jPtr ? *jPtr : nlohmann::json { }, current);
108}
109
110} // namespace
111

Callers 1

ThreadFnMethod · 0.85

Calls 1

dataMethod · 0.45

Tested by

no test coverage detected