MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ReadScriptParametersFromXML

Function ReadScriptParametersFromXML

Source/Scripting/scriptparams.cpp:324–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324void ReadScriptParametersFromXML(ScriptParamMap &spm, const TiXmlElement *params) {
325 LOG_ASSERT(params);
326 const TiXmlElement *param = params->FirstChildElement("parameter");
327 while (param) {
328 std::string name = param->Attribute("name");
329 std::string type_str = param->Attribute("type");
330 ScriptParam sp;
331 if (type_str == "int") {
332 int val;
333 param->QueryIntAttribute("val", &val);
334 sp.SetInt(val);
335 } else if (type_str == "float") {
336 float val = 0.0f;
337 param->QueryFloatAttribute("val", &val);
338 sp.SetFloat(val);
339 } else if (type_str == "string") {
340 sp.SetString(param->Attribute("val"));
341 } else if (type_str == "json") {
342 sp.SetJSONFromString(param->Attribute("val"));
343 }
344 spm[name] = sp;
345 param = param->NextSiblingElement();
346 }
347}
348
349void WriteScriptParamsToXML(const ScriptParamMap &pm, TiXmlElement *params) {
350 for (const auto &iter : pm) {

Callers 2

GetTSRIinfoFunction · 0.85
ParseLevelXMLFunction · 0.85

Calls 9

QueryIntAttributeMethod · 0.80
QueryFloatAttributeMethod · 0.80
SetJSONFromStringMethod · 0.80
FirstChildElementMethod · 0.45
AttributeMethod · 0.45
SetIntMethod · 0.45
SetFloatMethod · 0.45
SetStringMethod · 0.45
NextSiblingElementMethod · 0.45

Tested by

no test coverage detected