1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Sandu Liviu Catalin
8dc0ca18f5 Minor changes. 2022-03-09 22:59:19 +02:00
Sandu Liviu Catalin
7e39fab21a Reuse method. 2022-03-09 22:41:00 +02:00
Sandu Liviu Catalin
da139c6a81 Update XML.hpp 2022-03-09 22:37:06 +02:00
Sandu Liviu Catalin
27521f209d Fix return value. 2022-03-09 22:33:35 +02:00
Sandu Liviu Catalin
e6cbdfaf30 Allow XML chaining. 2022-03-09 22:25:51 +02:00
Sandu Liviu Catalin
fd62cafe33 Update XML.cpp 2022-03-09 22:11:03 +02:00
2 changed files with 57 additions and 53 deletions

View File

@ -138,9 +138,10 @@ SQInteger XmlAttribute::GetLong() const
}
// ------------------------------------------------------------------------------------------------
void XmlAttribute::SetLong(SQInteger value)
XmlAttribute & XmlAttribute::SetLong(SQInteger value)
{
m_Attr = value;
return *this;
}
// ------------------------------------------------------------------------------------------------
@ -150,9 +151,10 @@ SQInteger XmlAttribute::GetUlong() const
}
// ------------------------------------------------------------------------------------------------
void XmlAttribute::SetUlong(SQInteger value)
XmlAttribute & XmlAttribute::SetUlong(SQInteger value)
{
m_Attr = static_cast< uint64_t >(value);
return *this;
}
// ------------------------------------------------------------------------------------------------
@ -186,9 +188,10 @@ SQInteger XmlText::GetLong() const
}
// ------------------------------------------------------------------------------------------------
void XmlText::SetLong(SQInteger value)
XmlText & XmlText::SetLong(SQInteger value)
{
m_Text = value;
return *this;
}
// ------------------------------------------------------------------------------------------------
@ -198,9 +201,10 @@ SQInteger XmlText::GetUlong() const
}
// ------------------------------------------------------------------------------------------------
void XmlText::SetUlong(SQInteger value)
XmlText & XmlText::SetUlong(SQInteger value)
{
m_Text = static_cast< uint64_t >(value);
return *this;
}
// ------------------------------------------------------------------------------------------------
@ -259,8 +263,8 @@ void Register_XML(HSQUIRRELVM vm)
.Prop(_SC("Next"), &XmlAttribute::NextAttribute)
.Prop(_SC("Prev"), &XmlAttribute::PrevAttribute)
// Member Methods
.Func(_SC("SetName"), &XmlAttribute::ApplyName)
.Func(_SC("SetValue"), &XmlAttribute::ApplyValue)
.FmtFunc(_SC("SetName"), &XmlAttribute::SetName)
.FmtFunc(_SC("SetValue"), &XmlAttribute::ApplyValue)
.Func(_SC("AsString"), &XmlAttribute::AsString)
.Func(_SC("AsInt"), &XmlAttribute::AsInt)
.Func(_SC("AsUint"), &XmlAttribute::AsUint)
@ -350,8 +354,8 @@ void Register_XML(HSQUIRRELVM vm)
.Overload(_SC("AppendBuffer"), &XmlNode::AppendBuffer1)
.Overload(_SC("AppendBuffer"), &XmlNode::AppendBuffer2)
.Overload(_SC("AppendBuffer"), &XmlNode::AppendBuffer3)
.Func(_SC("SetName"), &XmlNode::ApplyName)
.Func(_SC("SetValue"), &XmlNode::ApplyValue)
.FmtFunc(_SC("SetName"), &XmlNode::SetName)
.FmtFunc(_SC("SetValue"), &XmlNode::ApplyValue)
.Func(_SC("GetChild"), &XmlNode::Child)
.Func(_SC("GetAttr"), &XmlNode::GetAttribute)
.Func(_SC("GetAttribute"), &XmlNode::GetAttribute)
@ -368,8 +372,8 @@ void Register_XML(HSQUIRRELVM vm)
.Func(_SC("PrependAttrCopy"), &XmlNode::PrependAttrCopy)
.Func(_SC("InsertAttrCopyAfter"), &XmlNode::InsertAttrCopyAfter)
.Func(_SC("InsertAttrCopyBefore"), &XmlNode::InsertAttrCopyBefore)
.Func(_SC("AppendChild"), &XmlNode::AppendChild)
.Func(_SC("PrependChild"), &XmlNode::PrependChild)
.FmtFunc(_SC("AppendChild"), &XmlNode::AppendChild)
.FmtFunc(_SC("PrependChild"), &XmlNode::PrependChild)
.Func(_SC("AppendChildNode"), &XmlNode::AppendChildNode)
.Func(_SC("PrependChildNode"), &XmlNode::PrependChildNode)
.Func(_SC("AppendChildType"), &XmlNode::AppendChildType)
@ -386,9 +390,9 @@ void Register_XML(HSQUIRRELVM vm)
.Func(_SC("PrependMove"), &XmlNode::PrependMove)
.Func(_SC("InsertMoveAfter"), &XmlNode::InsertMoveAfter)
.Func(_SC("InsertMoveBefore"), &XmlNode::InsertMoveBefore)
.Func(_SC("RemoveAttr"), &XmlNode::RemoveAttr)
.FmtFunc(_SC("RemoveAttr"), &XmlNode::RemoveAttr)
.Func(_SC("RemoveAttrInst"), &XmlNode::RemoveAttrInst)
.Func(_SC("RemoveChild"), &XmlNode::RemoveChild)
.FmtFunc(_SC("RemoveChild"), &XmlNode::RemoveChild)
.Func(_SC("RemoveChildInst"), &XmlNode::RemoveChildInst)
.Overload(_SC("FindChildByAttr"), &XmlNode::FindChildByAttr2)
.Overload(_SC("FindChildByAttr"), &XmlNode::FindChildByAttr3)
@ -421,7 +425,7 @@ void Register_XML(HSQUIRRELVM vm)
.Overload(_SC("SaveFile"), &XmlDocument::SaveFile4)
);
RootTable(vm).Bind(_SC("SqXml"), xmlns);
RootTable(vm).Bind(_SC("SqXML"), xmlns);
ConstTable(vm).Enum(_SC("SqXmlNodeType"), Enumeration(vm)
.Const(_SC("Null"), static_cast< int32_t >(node_null))

View File

@ -663,7 +663,7 @@ protected:
* Explicit constructor.
*/
XmlNode(DocumentRef doc, const Type & node)
: m_Doc(std::move(doc)), m_Node(node)
: m_Node(node), m_Doc(std::move(doc))
{
/* ... */
}
@ -671,8 +671,8 @@ protected:
private:
// ---------------------------------------------------------------------------------------------
DocumentRef m_Doc{}; // The main xml document instance.
Type m_Node{}; // The managed document node.
DocumentRef m_Doc{}; // The main xml document instance.
public:
@ -777,20 +777,13 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify node name.
*/
void SetName(StackStrF & name)
XmlNode & SetName(StackStrF & name)
{
if (!m_Node.set_name(name.mPtr))
{
STHROWF("Unable to set XML node name");
STHROWF("Unable to set XML node name `{}`", name.ToStr());
}
}
/* --------------------------------------------------------------------------------------------
* Modify the node name.
*/
bool ApplyName(StackStrF & name)
{
return m_Node.set_name(name.mPtr);
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -804,12 +797,13 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify node value.
*/
void SetValue(StackStrF & name)
XmlNode & SetValue(StackStrF & name)
{
if (!m_Node.set_value(name.mPtr))
{
STHROWF("Unable to set XML node value");
}
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1331,20 +1325,13 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve attribute name.
*/
void SetName(StackStrF & name)
XmlAttribute & SetName(StackStrF & name)
{
if (!m_Attr.set_name(name.mPtr))
{
STHROWF("Unable to set XML attribute name");
STHROWF("Unable to set XML attribute name `{}`", name.ToStr());
}
}
/* --------------------------------------------------------------------------------------------
* Modify the attribute name.
*/
bool ApplyName(StackStrF & name)
{
return m_Attr.set_name(name.mPtr);
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1358,12 +1345,13 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve attribute value.
*/
void SetValue(StackStrF & name)
XmlAttribute SetValue(StackStrF & name)
{
if (!m_Attr.set_value(name.mPtr))
{
STHROWF("Unable to set XML attribute value");
}
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1501,9 +1489,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a string.
*/
void SetString(StackStrF & value)
XmlAttribute & SetString(StackStrF & value)
{
m_Attr = value.mPtr;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1517,9 +1506,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a integer.
*/
void SetInt(int32_t value)
XmlAttribute & SetInt(int32_t value)
{
m_Attr = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1533,9 +1523,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a unsigned integer.
*/
void SetUint(uint32_t value)
XmlAttribute & SetUint(uint32_t value)
{
m_Attr = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1549,9 +1540,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a floating point.
*/
void SetFloat(SQFloat value)
XmlAttribute & SetFloat(SQFloat value)
{
m_Attr = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1565,9 +1557,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a double floating point.
*/
void SetDouble(SQFloat value)
XmlAttribute & SetDouble(SQFloat value)
{
m_Attr = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1578,7 +1571,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a long integer.
*/
void SetLong(SQInteger value);
XmlAttribute & SetLong(SQInteger value);
/* --------------------------------------------------------------------------------------------
* Retrieve the value as a unsigned long integer.
@ -1588,7 +1581,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a unsigned long integer.
*/
void SetUlong(SQInteger value);
XmlAttribute & SetUlong(SQInteger value);
/* --------------------------------------------------------------------------------------------
* Retrieve the value as a boolean.
@ -1601,9 +1594,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a boolean.
*/
void SetBool(bool value)
XmlAttribute & SetBool(bool value)
{
m_Attr = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1853,9 +1847,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a string.
*/
void SetString(StackStrF & value)
XmlText & SetString(StackStrF & value)
{
m_Text = value.mPtr;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1869,9 +1864,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a integer.
*/
void SetInt(int32_t value)
XmlText & SetInt(int32_t value)
{
m_Text = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1885,9 +1881,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a unsigned integer.
*/
void SetUint(uint32_t value)
XmlText & SetUint(uint32_t value)
{
m_Text = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1901,9 +1898,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a floating point.
*/
void SetFloat(SQFloat value)
XmlText & SetFloat(SQFloat value)
{
m_Text = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1917,9 +1915,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a double floating point.
*/
void SetDouble(SQFloat value)
XmlText & SetDouble(SQFloat value)
{
m_Text = value;
return *this;
}
/* --------------------------------------------------------------------------------------------
@ -1930,7 +1929,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a long integer.
*/
void SetLong(SQInteger value);
XmlText & SetLong(SQInteger value);
/* --------------------------------------------------------------------------------------------
* Retrieve the value as a unsigned long integer.
@ -1940,7 +1939,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a unsigned long integer.
*/
void SetUlong(SQInteger value);
XmlText & SetUlong(SQInteger value);
/* --------------------------------------------------------------------------------------------
* Retrieve the value as a boolean.
@ -1953,9 +1952,10 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the value as a boolean.
*/
void SetBool(bool value)
XmlText & SetBool(bool value)
{
m_Text = value;
return *this;
}
/* --------------------------------------------------------------------------------------------