From bad730dd0de24b2b17b91922c0c7f2b31b7b4d9b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 10 Jan 2012 18:43:15 +0300 Subject: Move libxml2 includes to xml.h --- src/animationparticle.h | 2 +- src/configuration.cpp | 3 --- src/configuration.h | 3 ++- src/main.cpp | 22 ++-------------------- src/resources/action.h | 2 +- src/resources/animation.h | 2 +- src/resources/chardb.cpp | 4 ---- src/resources/chardb.h | 2 +- src/resources/colordb.cpp | 2 -- src/resources/itemdb.cpp | 4 +--- src/resources/mapdb.cpp | 2 -- src/resources/mapreader.cpp | 1 - src/resources/mapreader.h | 2 +- src/resources/spritedef.cpp | 2 -- src/resources/spritedef.h | 2 +- src/rotationalparticle.h | 2 +- src/utils/xml.cpp | 16 ++++++++++++++++ src/utils/xml.h | 4 ++++ 18 files changed, 32 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/animationparticle.h b/src/animationparticle.h index 45110501a..27e7d0b22 100644 --- a/src/animationparticle.h +++ b/src/animationparticle.h @@ -25,7 +25,7 @@ #include "imageparticle.h" -#include +#include "utils/xml.h" class Animation; class Map; diff --git a/src/configuration.cpp b/src/configuration.cpp index bed7c0878..40c3ab8c3 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -27,9 +27,6 @@ #include "utils/paths.h" #include "utils/stringutils.h" -#include "utils/xml.h" - -#include #include diff --git a/src/configuration.h b/src/configuration.h index ae8908bfd..7e4c65a40 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -24,9 +24,10 @@ #define CONFIGURATION_H #include "utils/stringutils.h" +#include "utils/xml.h" + #include "defaults.h" -#include #include #include diff --git a/src/main.cpp b/src/main.cpp index 71794487c..9bffcfa2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,13 +27,12 @@ #include "client.h" #include "logger.h" -#include - #include #include #include #include "utils/stringutils.h" +#include "utils/xml.h" #ifdef __MINGW32__ #include @@ -210,23 +209,6 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) extern "C" char const *_nl_locale_name_default(void); #endif -static void xmlNullLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...) -{ - // Does nothing, that's the whole point of it -} - -// Initialize libxml2 and check for potential ABI mismatches between -// compiled version and the shared library actually used. -static void initXML() -{ - xmlInitParser(); - LIBXML_TEST_VERSION; - - // Suppress libxml2 error messages - xmlSetGenericErrorFunc(nullptr, xmlNullLogger); -} - - int main(int argc, char *argv[]) { #if defined(__MINGW32__) @@ -262,7 +244,7 @@ int main(int argc, char *argv[]) atexit((void(*)()) PHYSFS_deinit); - initXML(); + XML::initXML(); #ifdef WIN32 SetCurrentDirectory(PHYSFS_getBaseDir()); diff --git a/src/resources/action.h b/src/resources/action.h index 603135875..1e3965363 100644 --- a/src/resources/action.h +++ b/src/resources/action.h @@ -23,7 +23,7 @@ #ifndef ACTION_H #define ACTION_H -#include +#include "utils/xml.h" #include diff --git a/src/resources/animation.h b/src/resources/animation.h index f52234abb..33bfd76e9 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -23,7 +23,7 @@ #ifndef ANIMATION_H #define ANIMATION_H -#include +#include "utils/xml.h" #include #include diff --git a/src/resources/chardb.cpp b/src/resources/chardb.cpp index c6de2e189..30408c239 100644 --- a/src/resources/chardb.cpp +++ b/src/resources/chardb.cpp @@ -24,10 +24,6 @@ #include "client.h" #include "logger.h" -#include "utils/xml.h" - -#include - #include "debug.h" namespace diff --git a/src/resources/chardb.h b/src/resources/chardb.h index 8be2c34c4..c668c1a73 100644 --- a/src/resources/chardb.h +++ b/src/resources/chardb.h @@ -25,7 +25,7 @@ #include #include -#include +#include "utils/xml.h" /** * Char information database. diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 41393541f..2a79f0554 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -26,8 +26,6 @@ #include "utils/xml.h" -#include - #include "debug.h" namespace diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index e7cc0f931..2c381286a 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -23,6 +23,7 @@ #include "resources/itemdb.h" #include "client.h" +#include "configuration.h" #include "logger.h" #include "resources/iteminfo.h" @@ -32,9 +33,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" #include "utils/xml.h" -#include "configuration.h" - -#include #include "debug.h" diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp index e61ee45b0..1da3dd908 100644 --- a/src/resources/mapdb.cpp +++ b/src/resources/mapdb.cpp @@ -27,8 +27,6 @@ #include "utils/xml.h" -#include - #include "debug.h" namespace diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 5ebfe5fe3..8c8bf2f9d 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -35,7 +35,6 @@ #include "utils/base64.h" #include "utils/gettext.h" #include "utils/stringutils.h" -#include "utils/xml.h" #include #include diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index 301b7d7ce..8fc11e70f 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -23,7 +23,7 @@ #ifndef MAPREADER_H #define MAPREADER_H -#include +#include "utils/xml.h" #include diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 1122cb2e9..40bdb64c8 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -33,8 +33,6 @@ #include "configuration.h" -#include "utils/xml.h" - #include "debug.h" SpriteReference *SpriteReference::Empty = nullptr; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 9e756bdf7..3f656be0d 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -25,7 +25,7 @@ #include "resources/resource.h" -#include +#include "utils/xml.h" #include #include diff --git a/src/rotationalparticle.h b/src/rotationalparticle.h index 19e71e62c..96b7a29ff 100644 --- a/src/rotationalparticle.h +++ b/src/rotationalparticle.h @@ -25,7 +25,7 @@ #include "imageparticle.h" -#include +#include "utils/xml.h" class Animation; class Map; diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 87833d176..5a9558cc2 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -32,6 +32,11 @@ #include "debug.h" +static void xmlNullLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...) +{ + // Does nothing, that's the whole point of it +} + namespace XML { Document::Document(const std::string &filename, bool useResman): @@ -165,4 +170,15 @@ namespace XML return nullptr; } + // Initialize libxml2 and check for potential ABI mismatches between + // compiled version and the shared library actually used. + void initXML() + { + xmlInitParser(); + LIBXML_TEST_VERSION; + + // Suppress libxml2 error messages + xmlSetGenericErrorFunc(nullptr, xmlNullLogger); + } + } // namespace XML diff --git a/src/utils/xml.h b/src/utils/xml.h index e35a2a06f..2b97b45f5 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -23,6 +23,8 @@ #ifndef XML_H #define XML_H +#include +#include #include #include @@ -94,6 +96,8 @@ namespace XML * Finds the first child node with the given name */ xmlNodePtr findFirstChildByName(xmlNodePtr parent, const char *name); + + void initXML(); } #define for_each_xml_child_node(var, parent) \ -- cgit v1.2.3-70-g09d2