ManaPlus
Namespaces | Functions | Variables
libxml.cpp File Reference

(986a3bf)

#include "utils/xml/libxml.h"
#include "fs/virtfs/fs.h"
#include "utils/cast.h"
#include "utils/checkutils.h"
#include "utils/fuzzer.h"
#include "utils/stringutils.h"
#include "utils/translation/podict.h"
#include <fstream>
#include "debug.h"

Go to the source code of this file.

Namespaces

 anonymous_namespace{libxml.cpp}
 
 XML
 

Functions

static void xmlErrorLogger (void *ctx, const char *msg,...)
 
int XML::getProperty (const xmlNodePtr node, const char *const name, int def)
 
int XML::getIntProperty (const xmlNodePtr node, const char *const name, int def, const int min, const int max)
 
float XML::getFloatProperty (const xmlNodePtr node, const char *const name, float def)
 
double XML::getDoubleProperty (const xmlNodePtr node, const char *const name, double def)
 
std::string XML::getProperty (const xmlNodePtr node, const char *const name, const std::string &def)
 
std::string XML::langProperty (const xmlNodePtr node, const char *const name, const std::string &def)
 
bool XML::getBoolProperty (const xmlNodePtr node, const char *const name, const bool def)
 
xmlNodePtr XML::findFirstChildByName (const xmlNode *const parent, const char *const name)
 
void XML::initXML ()
 
void XML::cleanupXML ()
 

Variables

bool anonymous_namespace{libxml.cpp}::valid = false
 

Function Documentation

◆ xmlErrorLogger()

static void xmlErrorLogger ( void *  ctx,
const char *  msg,
  ... 
)
static

Definition at line 56 of file libxml.cpp.

57 {
58  if (msg == nullptr)
59  return;
60 
61  size_t size = 1024;
62  const size_t msgSize = strlen(msg);
63  if (msgSize * 3 > size)
64  size = msgSize * 3;
65 
66  char* buf = new char[size + 1];
67  va_list ap;
68 
69  // Use a temporary buffer to fill in the variables
70  va_start(ap, msg);
71  vsnprintf(buf, size, msg, ap);
72  buf[size] = 0;
73  va_end(ap);
74 
75  if (logger != nullptr)
76  logger->log_r("%s", buf);
77  else
78  puts(buf);
79 
80  // Delete temporary buffer
81  delete [] buf;
82  valid = false;
83 }
void log_r(const char *const log_text,...)
Definition: logger.cpp:365
Logger * logger
Definition: logger.cpp:89
bool msg(InputEvent &event)
Definition: chat.cpp:39
int size()
Definition: emotedb.cpp:306

References Logger::log_r(), logger, Actions::msg(), EmoteDB::size(), and anonymous_namespace{libxml.cpp}::valid.

Referenced by XML::initXML().