ManaPlus
Functions
itemxmlutils.h File Reference

(986a3bf)

#include "utils/vector.h"
#include "utils/xml.h"
#include "resources/itemfieldinfos.h"

Go to the source code of this file.

Functions

void readItemStatsString (std::string &effect, const xmlNodePtr node, const ItemFieldInfos &fields)
 
void readItemStatsVector (std::vector< std::string > &effect, const xmlNodePtr node, const ItemFieldInfos &fields)
 

Function Documentation

◆ readItemStatsString()

void readItemStatsString ( std::string &  effect,
const xmlNodePtr  node,
const ItemFieldInfos fields 
)

Definition at line 88 of file itemxmlutils.cpp.

91 {
92  if (translator == nullptr)
93  {
94  reportAlways("called readItemStatsString without translator")
95  return;
96  }
97 
98  FOR_EACH (ItemFieldInfos::const_iterator, it, fields)
99  {
100  std::string field;
101  if (!readField(it, node, field))
102  continue;
103  if (!effect.empty())
104  effect.append(" / ");
105  effect.append(field);
106  }
107 }
#define reportAlways(...)
Definition: checkutils.h:253
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
std::map< std::string, ItemFieldType * > ItemFieldInfos
static bool readField(ItemFieldInfos::const_iterator it, const xmlNodePtr node, std::string &combined)
PoDict * translator
Definition: podict.cpp:28

References FOR_EACH, readField(), reportAlways, and translator.

Referenced by ItemDB::loadXmlFile().

◆ readItemStatsVector()

void readItemStatsVector ( std::vector< std::string > &  effect,
const xmlNodePtr  node,
const ItemFieldInfos fields 
)

Definition at line 109 of file itemxmlutils.cpp.

112 {
113  if (translator == nullptr)
114  {
115  reportAlways("called readItemStatsVector without translator")
116  return;
117  }
118 
119  FOR_EACH (ItemFieldInfos::const_iterator, it, fields)
120  {
121  std::string field;
122  if (!readField(it, node, field))
123  continue;
124  effect.push_back(field);
125  }
126 }

References FOR_EACH, readField(), reportAlways, and translator.

Referenced by ClanDb::loadXmlFile().