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

Function componentFromJsonV1

launcher/minecraft/PackProfile.cpp:129–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129static ComponentPtr componentFromJsonV1(PackProfile * parent, const QString & componentJsonPattern, const QJsonObject &obj)
130{
131 // critical
132 auto uid = Json::requireString(obj.value("uid"));
133 auto filePath = componentJsonPattern.arg(uid);
134 auto component = new Component(parent, uid);
135 component->m_version = Json::ensureString(obj.value("version"));
136 component->m_dependencyOnly = Json::ensureBoolean(obj.value("dependencyOnly"), false);
137 component->m_important = Json::ensureBoolean(obj.value("important"), false);
138
139 // cached
140 // TODO @RESILIENCE: ignore invalid values/structure here?
141 component->m_cachedVersion = Json::ensureString(obj.value("cachedVersion"));
142 component->m_cachedName = Json::ensureString(obj.value("cachedName"));
143 Meta::parseRequires(obj, &component->m_cachedRequires, "cachedRequires");
144 Meta::parseRequires(obj, &component->m_cachedConflicts, "cachedConflicts");
145 component->m_cachedVolatile = Json::ensureBoolean(obj.value("volatile"), false);
146 bool disabled = Json::ensureBoolean(obj.value("disabled"), false);
147 component->setEnabled(!disabled);
148 return component;
149}
150
151// Save the given component container data to a file
152static bool savePackProfile(const QString & filename, const ComponentContainer & container)

Callers 1

loadPackProfileFunction · 0.85

Calls 2

parseRequiresFunction · 0.85
setEnabledMethod · 0.80

Tested by

no test coverage detected