MCPcopy Create free account
hub / github.com/MultiMC/Launcher / componentFromJsonV1

Function componentFromJsonV1

launcher/minecraft/PackProfile.cpp:101–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101static ComponentPtr componentFromJsonV1(PackProfile * parent, const QString & componentJsonPattern, const QJsonObject &obj)
102{
103 // critical
104 auto uid = Json::requireValueString(obj.value("uid"));
105 auto filePath = componentJsonPattern.arg(uid);
106 auto component = new Component(parent, uid);
107 component->m_version = Json::ensureValueString(obj.value("version"));
108 component->m_dependencyOnly = Json::ensureValueBoolean(obj.value("dependencyOnly"), false);
109 component->m_important = Json::ensureValueBoolean(obj.value("important"), false);
110
111 // cached
112 // TODO @RESILIENCE: ignore invalid values/structure here?
113 component->m_cachedVersion = Json::ensureValueString(obj.value("cachedVersion"));
114 component->m_cachedName = Json::ensureValueString(obj.value("cachedName"));
115 Meta::parseRequires(obj, &component->m_cachedRequires, "cachedRequires");
116 Meta::parseRequires(obj, &component->m_cachedConflicts, "cachedConflicts");
117 component->m_cachedVolatile = Json::ensureValueBoolean(obj.value("volatile"), false);
118 bool disabled = Json::ensureValueBoolean(obj.value("disabled"), false);
119 component->setEnabled(!disabled);
120 return component;
121}
122
123// Save the given component container data to a file
124static 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