OpenClonk
C4StartupModsDlg.cpp File Reference
#include "C4Include.h"
#include "gui/C4StartupModsDlg.h"
#include "C4Version.h"
#include "lib/SHA1.h"
#include "game/C4Application.h"
#include "gui/C4UpdateDlg.h"
#include "game/C4Game.h"
#include "graphics/C4GraphicsResource.h"
#include "graphics/C4Draw.h"
#include "network/C4HTTP.h"
#include <tinyxml.h>
#include <fstream>
#include <sstream>
#include <regex>
Include dependency graph for C4StartupModsDlg.cpp:

Go to the source code of this file.

Functions

std::string getSafeStringValue (const TiXmlElement *xml, const char *childName, std::string fallback="", bool isAttribute=false)
 

Function Documentation

◆ getSafeStringValue()

std::string getSafeStringValue ( const TiXmlElement *  xml,
const char *  childName,
std::string  fallback = "",
bool  isAttribute = false 
)

Definition at line 37 of file C4StartupModsDlg.cpp.

38 {
39  if (xml == nullptr) return fallback;
40  if (isAttribute)
41  {
42  const char * value = xml->Attribute(childName);
43  if (value == nullptr)
44  return fallback;
45  return{ value };
46  }
47  const TiXmlElement *child = xml->FirstChildElement(childName);
48  if (child == nullptr) return fallback;
49  const char *nodeText = child->GetText();
50  if (nodeText == nullptr) return fallback;
51  const std::string value(nodeText);
52  if (!value.empty()) return value;
53  return fallback;
54 };

Referenced by C4StartupModsListEntry::FromXML(), and ModXMLData::ModXMLData().

Here is the caller graph for this function: