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-05-22 21:34:27 +02:00
|
|
|
static const SQChar name[] = _SC("SqXmlDocument");
|
2016-02-28 16:39:26 +01:00
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
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-04-02 10:04:28 +02:00
|
|
|
m_Doc.Validate();
|
2016-02-27 10:57:10 +01:00
|
|
|
// Are there any other references?
|
2016-04-02 10:04:28 +02:00
|
|
|
if (m_Doc.Count() > 1)
|
|
|
|
{
|
2016-02-28 16:39:26 +01:00
|
|
|
// To load new values now, would mean to cause undefined behavior in existing references
|
2016-03-22 23:26:35 +01:00
|
|
|
STHROWF("Loading is disabled while document is referenced");
|
2016-04-02 10:04:28 +02:00
|
|
|
}
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Node Document::GetNode() const
|
|
|
|
{
|
2016-04-02 10:04:28 +02:00
|
|
|
// Validate the document handle
|
|
|
|
m_Doc.Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return Node(m_Doc, m_Doc->document_element());
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|