2014-05-02 08:30:32 +02:00
|
|
|
#include "stdafx.h"
|
2014-07-11 13:59:13 +02:00
|
|
|
#include "Utilities/rXml.h"
|
2014-05-02 08:30:32 +02:00
|
|
|
#include <wx/xml/xml.h>
|
|
|
|
|
|
|
|
rXmlNode::rXmlNode()
|
|
|
|
{
|
|
|
|
ownPtr = true;
|
|
|
|
handle = reinterpret_cast<void *>(new wxXmlNode());
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlNode::rXmlNode(void *ptr)
|
|
|
|
{
|
|
|
|
ownPtr = false;
|
|
|
|
handle = ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlNode::rXmlNode(const rXmlNode& other)
|
|
|
|
{
|
|
|
|
ownPtr = true;
|
|
|
|
handle = reinterpret_cast<void *>(new wxXmlNode(*reinterpret_cast<wxXmlNode*>(other.handle)));
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlNode &rXmlNode::operator=(const rXmlNode& other)
|
|
|
|
{
|
|
|
|
if (ownPtr)
|
|
|
|
{
|
|
|
|
delete reinterpret_cast<wxXmlNode*>(handle);
|
|
|
|
}
|
|
|
|
handle = reinterpret_cast<void *>(new wxXmlNode(*reinterpret_cast<wxXmlNode*>(other.handle)));
|
|
|
|
ownPtr = true;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlNode::~rXmlNode()
|
|
|
|
{
|
|
|
|
if (ownPtr)
|
|
|
|
{
|
|
|
|
delete reinterpret_cast<wxXmlNode*>(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<rXmlNode> rXmlNode::GetChildren()
|
|
|
|
{
|
|
|
|
wxXmlNode* result = reinterpret_cast<wxXmlNode*>(handle)->GetChildren();
|
2014-06-08 13:43:13 +02:00
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
return std::make_shared<rXmlNode>(reinterpret_cast<void*>(result));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return std::shared_ptr<rXmlNode>(nullptr);
|
|
|
|
}
|
2014-05-02 08:30:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<rXmlNode> rXmlNode::GetNext()
|
|
|
|
{
|
|
|
|
wxXmlNode* result = reinterpret_cast<wxXmlNode*>(handle)->GetNext();
|
2014-06-08 13:43:13 +02:00
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
return std::make_shared<rXmlNode>(reinterpret_cast<void*>(result));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return std::shared_ptr<rXmlNode>(nullptr);
|
|
|
|
}
|
2014-05-02 08:30:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string rXmlNode::GetName()
|
|
|
|
{
|
|
|
|
return fmt::ToUTF8(reinterpret_cast<wxXmlNode*>(handle)->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string rXmlNode::GetAttribute(const std::string &name)
|
|
|
|
{
|
|
|
|
return fmt::ToUTF8(reinterpret_cast<wxXmlNode*>(handle)->GetAttribute(fmt::FromUTF8(name)));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string rXmlNode::GetNodeContent()
|
|
|
|
{
|
|
|
|
return fmt::ToUTF8(reinterpret_cast<wxXmlNode*>(handle)->GetNodeContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlDocument::rXmlDocument()
|
|
|
|
{
|
|
|
|
handle = reinterpret_cast<void *>(new wxXmlDocument());
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlDocument::rXmlDocument(const rXmlDocument& other)
|
|
|
|
{
|
|
|
|
handle = reinterpret_cast<void *>(new wxXmlDocument(*reinterpret_cast<wxXmlDocument*>(other.handle)));
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlDocument &rXmlDocument::operator = (const rXmlDocument& other)
|
|
|
|
{
|
|
|
|
delete reinterpret_cast<wxXmlDocument*>(handle);
|
|
|
|
handle = reinterpret_cast<void *>(new wxXmlDocument(*reinterpret_cast<wxXmlDocument*>(other.handle)));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
rXmlDocument::~rXmlDocument()
|
|
|
|
{
|
|
|
|
delete reinterpret_cast<wxXmlDocument*>(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rXmlDocument::Load(const std::string & path)
|
|
|
|
{
|
|
|
|
reinterpret_cast<wxXmlDocument*>(handle)->Load(fmt::FromUTF8(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<rXmlNode> rXmlDocument::GetRoot()
|
|
|
|
{
|
|
|
|
return std::make_shared<rXmlNode>(reinterpret_cast<void*>(reinterpret_cast<wxXmlDocument*>(handle)->GetRoot()));
|
|
|
|
}
|