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

View File

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