Skip to content

Commit

Permalink
Remove tinyxml2 version < 6 specific logic
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Oct 23, 2023
1 parent f8a5c3b commit 2c535d9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 45 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR})
#--------------------------------------
# Find Tinyxml2
gz_find_package(TINYXML2 PRETTY tinyxml2
VERSION 6.0
REQUIRED_BY graphics
PRIVATE_FOR graphics)

Expand Down
9 changes: 0 additions & 9 deletions graphics/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
gz_get_libsources_and_unittests(sources gtest_sources)


if(NOT USE_EXTERNAL_TINYXML2)
# If we are using our internal copy of tinyxml2, then add its
# source file.
message(STATUS "Adding tinyxml2 source files")
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2/tinyxml2.cpp)
endif()


gz_add_component(graphics SOURCES ${sources} GET_TARGET_NAME graphics_target)

target_link_libraries(${graphics_target}
Expand Down
20 changes: 0 additions & 20 deletions graphics/src/ColladaExporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@

#include "tinyxml2.h"

#ifndef TINYXML2_MAJOR_VERSION_GE_6
#if TINYXML2_MAJOR_VERSION >= 6
#define TINYXML2_MAJOR_VERSION_GE_6
#endif
#endif

#ifdef _WIN32
static const char pathSeparator = '\\';
#define snprintf _snprintf
Expand All @@ -50,24 +44,10 @@ static void LogTinyXml2DocumentError(
{
warning += std::to_string(_doc.ErrorID()) + "): ";

#ifdef TINYXML2_MAJOR_VERSION_GE_6
const char * error1 = _doc.ErrorStr();
#else
const char * error1 = _doc.GetErrorStr1();
#endif

if (error1)
warning += "str1=" + std::string(error1);

#ifndef TINYXML2_MAJOR_VERSION_GE_6
const char * error2 = _doc.GetErrorStr2();

if (error1 && error2)
warning += ", ";

if (error2)
warning += "str2=" + std::string(error2);
#endif
}
else
{
Expand Down
18 changes: 2 additions & 16 deletions graphics/src/SVGLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@

#include "tinyxml2.h"

#ifndef TINYXML2_MAJOR_VERSION_GE_6
#if TINYXML2_MAJOR_VERSION >= 6
#define TINYXML2_MAJOR_VERSION_GE_6
#endif
#endif

#include "gz/common/Console.hh"
#include "gz/common/Util.hh"

Expand Down Expand Up @@ -885,20 +879,12 @@ bool SVGLoader::Parse(const std::string &_filename,
tinyxml2::XMLDocument doc;
if (doc.LoadFile(_filename.c_str()) != tinyxml2::XML_SUCCESS)
{
#ifdef TINYXML2_MAJOR_VERSION_GE_6
const char *str1 = doc.ErrorStr();
const char *str2 = nullptr;
#else
const char *str1 = doc.GetErrorStr1();
const char *str2 = doc.GetErrorStr2();
#endif
std::string err1 = str1 ? str1 : "n/a";
std::string err2 = str2 ? str2 : "n/a";
std::string err1 = str1 != nullptr ? str1 : "n/a";

gzerr << "Failed to load file " << _filename << std::endl
<< "XML error type " << doc.ErrorName() << "\n"
<< "XML error info 1 " << err1 << "\n"
<< "XML error info 2 " << err2 << "\n";
<< "XML error info 1 " << err1 << "\n";
return false;
}

Expand Down

0 comments on commit 2c535d9

Please sign in to comment.