SessionCreator xmldoc not by pointer.

This commit is contained in:
brunoherbelin
2020-08-12 22:53:35 +02:00
parent a7ba118562
commit 2f6f67bdd3
2 changed files with 7 additions and 8 deletions

View File

@@ -14,6 +14,7 @@
#include "MediaPlayer.h"
#include <tinyxml2.h>
#include "tinyxml2Toolkit.h"
using namespace tinyxml2;
@@ -40,22 +41,20 @@ std::string SessionCreator::info(const std::string& filename)
SessionCreator::SessionCreator(Session *session): Visitor(), session_(session)
{
xmlDoc_ = new XMLDocument;
}
SessionCreator::~SessionCreator()
{
delete xmlDoc_;
}
bool SessionCreator::load(const std::string& filename)
{
XMLError eResult = xmlDoc_->LoadFile(filename.c_str());
XMLError eResult = xmlDoc_.LoadFile(filename.c_str());
if ( XMLResultError(eResult))
return false;
XMLElement *header = xmlDoc_->FirstChildElement(APP_NAME);
XMLElement *header = xmlDoc_.FirstChildElement(APP_NAME);
if (header == nullptr) {
Log::Warning("%s is not a %s session file.", filename.c_str(), APP_NAME);
return false;
@@ -70,10 +69,10 @@ bool SessionCreator::load(const std::string& filename)
}
// ok, ready to read sources
loadSession( xmlDoc_->FirstChildElement("Session") );
loadSession( xmlDoc_.FirstChildElement("Session") );
// excellent, session was created: load optionnal config
if (session_){
loadConfig( xmlDoc_->FirstChildElement("Views") );
loadConfig( xmlDoc_.FirstChildElement("Views") );
}
return true;

View File

@@ -2,13 +2,13 @@
#define SESSIONCREATOR_H
#include "Visitor.h"
#include "tinyxml2Toolkit.h"
#include <tinyxml2.h>
class Session;
class SessionCreator : public Visitor {
tinyxml2::XMLDocument *xmlDoc_;
tinyxml2::XMLDocument xmlDoc_;
tinyxml2::XMLElement *xmlCurrent_;
Session *session_;