1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-23 05:07:13 +01:00
SqMod/modules/xml/Document.cpp
Sandu Liviu Catalin f4a11ef825 Separated major non mandatory libraries into their onwn modules.
Consolidated and simplified the module API system.
Various other fixes and improvements.
2016-02-27 11:57:10 +02:00

41 lines
1.3 KiB
C++

// ------------------------------------------------------------------------------------------------
#include "Document.hpp"
#include "Node.hpp"
#include "Module.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
bool Document::Validate() const
{
if (m_Doc)
return true;
// Invalid document reference
_SqMod->SqThrow("Invalid XML document reference");
return false;
}
// ------------------------------------------------------------------------------------------------
bool Document::CanLoad() const
{
// Is the document even valid?
if (!Validate())
return false;
// Are there any other references?
else if (m_Doc.Count() == 1)
return true;
// To load new values now, would mean to cause undefined behavior in existing references
_SqMod->SqThrow("Loading is disabled while document is referenced");
return false;
}
// ------------------------------------------------------------------------------------------------
Node Document::GetNode() const
{
if (m_Doc)
return Node(m_Doc, m_Doc->document_element());
return Node();
}
} // Namespace:: SqMod