2016-02-27 10:57:10 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Document.hpp"
|
|
|
|
#include "Node.hpp"
|
|
|
|
#include "Module.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-28 16:39:26 +01:00
|
|
|
SQInteger Document::Typename(HSQUIRRELVM vm)
|
2016-02-27 10:57:10 +01:00
|
|
|
{
|
2016-02-28 16:39:26 +01:00
|
|
|
static SQChar name[] = _SC("SqXmlDocument");
|
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Document::Validate() const
|
|
|
|
{
|
|
|
|
// Validate the document handle
|
|
|
|
if (!m_Doc)
|
|
|
|
SqThrowF("Invalid XML document reference");
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-28 16:39:26 +01:00
|
|
|
void Document::CanLoad() const
|
2016-02-27 10:57:10 +01:00
|
|
|
{
|
|
|
|
// Is the document even valid?
|
2016-02-28 16:39:26 +01:00
|
|
|
if (!m_Doc)
|
|
|
|
SqThrowF("Invalid XML document reference");
|
2016-02-27 10:57:10 +01:00
|
|
|
// Are there any other references?
|
2016-02-28 16:39:26 +01:00
|
|
|
else if (m_Doc.Count() > 1)
|
|
|
|
// To load new values now, would mean to cause undefined behavior in existing references
|
|
|
|
SqThrowF("Loading is disabled while document is referenced");
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Node Document::GetNode() const
|
|
|
|
{
|
|
|
|
if (m_Doc)
|
|
|
|
return Node(m_Doc, m_Doc->document_element());
|
|
|
|
return Node();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|