ManaPlus
Namespaces | Functions | Variables
itemoptiondb.cpp File Reference

(986a3bf)

#include "resources/db/itemoptiondb.h"
#include "configuration.h"
#include "utils/checkutils.h"
#include "resources/beingcommon.h"
#include "resources/db/itemfielddb.h"
#include "debug.h"

Go to the source code of this file.

Namespaces

 anonymous_namespace{itemoptiondb.cpp}
 

Functions

static void addFieldByName (std::vector< ItemFieldType * > &options, const xmlNodePtr node, const ItemFieldInfos &fields, const char *const name)
 
static void readOptionFields (std::vector< ItemFieldType * > &options, const xmlNodePtr node, const ItemFieldInfos &fields)
 

Variables

ItemOptionDb::OptionInfos anonymous_namespace{itemoptiondb.cpp}::mOptions
 
const std::vector< ItemFieldType * > anonymous_namespace{itemoptiondb.cpp}::mEmptyOption
 
bool anonymous_namespace{itemoptiondb.cpp}::mLoaded = false
 

Function Documentation

◆ addFieldByName()

static void addFieldByName ( std::vector< ItemFieldType * > &  options,
const xmlNodePtr  node,
const ItemFieldInfos fields,
const char *const  name 
)
static

Definition at line 53 of file itemoptiondb.cpp.

57 {
58  std::string value = XML::getProperty(node, name, "");
59  if (value.empty())
60  return;
61 
62  FOR_EACH (ItemFieldInfos::const_iterator, it, fields)
63  {
64  const std::string fieldName = (*it).first;
65  if (fieldName == value)
66  {
67  options.push_back((*it).second);
68  return;
69  }
70  }
71 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:174

References FOR_EACH, and XML::getProperty().

Referenced by readOptionFields().

◆ readOptionFields()

static void readOptionFields ( std::vector< ItemFieldType * > &  options,
const xmlNodePtr  node,
const ItemFieldInfos fields 
)
static

Definition at line 73 of file itemoptiondb.cpp.

76 {
77  addFieldByName(options, node, fields, "field");
78  for (int f = 0; f < 15; f ++)
79  {
80  const std::string field = strprintf("field%d", f);
81  addFieldByName(options, node, fields, field.c_str());
82  }
83 }
static void addFieldByName(std::vector< ItemFieldType * > &options, const xmlNodePtr node, const ItemFieldInfos &fields, const char *const name)
std::string strprintf(const char *const format,...)

References addFieldByName(), and strprintf().

Referenced by ItemOptionDb::loadXmlFile().