make xml parsing more verbose.

pull/2966/head
Kim Kulling 2020-09-29 21:01:10 +02:00
parent 484d305987
commit c591f7de2f
4 changed files with 12 additions and 16 deletions

View File

@ -48,12 +48,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AMFImporter.hpp" #include "AMFImporter.hpp"
// Header files, Assimp.
#include <assimp/SceneCombiner.h> #include <assimp/SceneCombiner.h>
#include <assimp/StandardShapes.h> #include <assimp/StandardShapes.h>
#include <assimp/StringUtils.h> #include <assimp/StringUtils.h>
// Header files, stdlib.
#include <iterator> #include <iterator>
namespace Assimp { namespace Assimp {
@ -379,7 +377,9 @@ void AMFImporter::Postprocess_BuildMeshSet(const AMFMesh &pNodeElement, const st
// check if volume use material // check if volume use material
if (!ne_volume->MaterialID.empty()) { if (!ne_volume->MaterialID.empty()) {
if (!Find_ConvertedMaterial(ne_volume->MaterialID, &cur_mat)) Throw_ID_NotFound(ne_volume->MaterialID); if (!Find_ConvertedMaterial(ne_volume->MaterialID, &cur_mat)) {
Throw_ID_NotFound(ne_volume->MaterialID);
}
} }
// inside "volume" collect all data and place to arrays or create new objects // inside "volume" collect all data and place to arrays or create new objects

View File

@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef INCLUDED_AI_IRRXML_WRAPPER #ifndef INCLUDED_AI_IRRXML_WRAPPER
#define INCLUDED_AI_IRRXML_WRAPPER #define INCLUDED_AI_IRRXML_WRAPPER
// some long includes .... #include <assimp/DefaultLogger.hpp>
#include "BaseImporter.h" #include "BaseImporter.h"
#include "IOStream.hpp" #include "IOStream.hpp"
#include <pugixml.hpp> #include <pugixml.hpp>
@ -117,6 +117,7 @@ public:
bool parse(IOStream *stream) { bool parse(IOStream *stream) {
if (nullptr == stream) { if (nullptr == stream) {
ASSIMP_LOG_DEBUG("Stream is nullptr.");
return false; return false;
} }
@ -126,6 +127,7 @@ public:
mDoc = new pugi::xml_document(); mDoc = new pugi::xml_document();
pugi::xml_parse_result parse_result = mDoc->load_string(&mData[0], pugi::parse_full); pugi::xml_parse_result parse_result = mDoc->load_string(&mData[0], pugi::parse_full);
if (parse_result.status == pugi::status_ok) { if (parse_result.status == pugi::status_ok) {
ASSIMP_LOG_DEBUG("Error while parse xml.");
result = true; result = true;
} }

View File

@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h> #include <assimp/scene.h>
using namespace Assimp; using namespace Assimp;
class utScene : public ::testing::Test { class utScene : public ::testing::Test {

View File

@ -58,25 +58,20 @@ protected:
TEST_F(utXmlParser, parse_xml_test) { TEST_F(utXmlParser, parse_xml_test) {
XmlParser parser; XmlParser parser;
std::string filename = ASSIMP_TEST_MODELS_DIR "/x3d/ComputerKeyboard.x3d"; std::string filename = ASSIMP_TEST_MODELS_DIR "/x3d/ComputerKeyboard.x3d";
IOStream *stream = mIoSystem.Open(filename.c_str(), "rb"); std::unique_ptr<IOStream> stream(mIoSystem.Open(filename.c_str(), "rb"));
bool result = parser.parse(stream); EXPECT_NE(stream.get(), nullptr);
bool result = parser.parse(stream.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
mIoSystem.Close(stream);
} }
TEST_F(utXmlParser, parse_xml_and_traverse_test) { TEST_F(utXmlParser, parse_xml_and_traverse_test) {
XmlParser parser; XmlParser parser;
std::string filename = ASSIMP_TEST_MODELS_DIR "/x3d/ComputerKeyboard.x3d"; std::string filename = ASSIMP_TEST_MODELS_DIR "/x3d/ComputerKeyboard.x3d";
std::unique_ptr<IOStream> stream(mIoSystem.Open(filename.c_str(), "rb"));
IOStream *stream = mIoSystem.Open(filename.c_str(), "rb"); EXPECT_NE(stream.get(), nullptr);
bool result = parser.parse(stream); bool result = parser.parse(stream.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
XmlNode root = parser.getRootNode(); XmlNode root = parser.getRootNode();
std::string name = root.name();
std::string name1 = root.name();
EXPECT_NE(nullptr, root);
mIoSystem.Close(stream);
std::string name2 = root.name();
XmlNodeIterator nodeIt(root); XmlNodeIterator nodeIt(root);
EXPECT_TRUE(nodeIt.isEmpty()); EXPECT_TRUE(nodeIt.isEmpty());