ManaPlus
Namespaces | Functions | Variables
itemfielddb.cpp File Reference

(986a3bf)

#include "resources/db/itemfielddb.h"
#include "configuration.h"
#include "utils/checkutils.h"
#include "utils/dtor.h"
#include "resources/beingcommon.h"
#include "resources/item/itemfieldtype.h"
#include "debug.h"

Go to the source code of this file.

Namespaces

 anonymous_namespace{itemfielddb.cpp}
 

Functions

static void loadFields (const xmlNodePtr groupNode, ItemFieldInfos &fields1, ItemFieldInfos &fields2)
 

Variables

ItemFieldInfos anonymous_namespace{itemfielddb.cpp}::mRequiredInfos
 
ItemFieldInfos anonymous_namespace{itemfielddb.cpp}::mAddInfos
 
bool anonymous_namespace{itemfielddb.cpp}::mLoaded = false
 

Function Documentation

◆ loadFields()

static void loadFields ( const xmlNodePtr  groupNode,
ItemFieldInfos fields1,
ItemFieldInfos fields2 
)
static

Definition at line 55 of file itemfielddb.cpp.

58 {
59  for_each_xml_child_node(node, groupNode)
60  {
61  if (!xmlNameEqual(node, "field"))
62  continue;
63 
64  const std::string name = XML::getProperty(node,
65  "name",
66  "");
67  if (name.empty())
68  {
69  reportAlways("Empty name field in ItemFieldDb")
70  continue;
71  }
72  const std::string description = XML::langProperty(node,
73  "description",
74  "");
75  if (description.empty())
76  {
77  reportAlways("Empty description field in ItemFieldDb")
78  continue;
79  }
80  const bool sign = XML::getBoolProperty(node,
81  "signed",
82  true);
83  if (fields2.find(name) != fields2.end())
84  {
86  "Same field name detected in requeted and add groups: %s",
87  name.c_str())
88  continue;
89  }
90  if (fields1.find(name) != fields1.end())
91  {
93  "Same field name detected: %s",
94  name.c_str())
95  continue;
96  }
97  fields1[name] = new ItemFieldType(name,
98  description,
99  sign);
100  }
101 }
#define reportAlways(...)
Definition: checkutils.h:253
#define new
Definition: debug_new.h:147
if(!vert) return
#define for_each_xml_child_node(var, parent)
Definition: libxml.h:161
bool find(const std::string &key)
Definition: libxml.cpp:86
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
Definition: libxml.cpp:258
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
Definition: libxml.cpp:269
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:174
std::string empty
Definition: podict.cpp:26

References for_each_xml_child_node, XML::getBoolProperty(), XML::getProperty(), XML::langProperty(), and reportAlways.

Referenced by ItemFieldDb::loadXmlFile().