mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Fixed excpetion throwing in INI document to that generated corrupted messages because snprintf was used instead of vsnprintf.
Revised most of the INI plugin and cleaned code.
This commit is contained in:
parent
27fb281805
commit
a947a68256
@ -3,7 +3,8 @@
|
|||||||
#include "Module.hpp"
|
#include "Module.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <stdarg.h>
|
#include <cstring>
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <sqrat.h>
|
#include <sqrat.h>
|
||||||
@ -33,8 +34,10 @@ void SqThrowF(CSStr str, ...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, str);
|
va_start (args, str);
|
||||||
// Write the requested contents
|
// Write the requested contents
|
||||||
if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
||||||
strcpy(g_Buffer, "Unknown error has occurred");
|
{
|
||||||
|
std::strcpy(g_Buffer, "Unknown error has occurred");
|
||||||
|
}
|
||||||
// Release the argument list
|
// Release the argument list
|
||||||
va_end(args);
|
va_end(args);
|
||||||
// Throw the exception with the resulted message
|
// Throw the exception with the resulted message
|
||||||
@ -48,17 +51,26 @@ CSStr FmtStr(CSStr str, ...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start (args, str);
|
va_start (args, str);
|
||||||
// Write the requested contents
|
// Write the requested contents
|
||||||
if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
||||||
g_Buffer[0] = 0; /* make sure the string is terminated */
|
{
|
||||||
|
g_Buffer[0] = 0; // Make sure the string is terminated
|
||||||
|
}
|
||||||
// Release the argument list
|
// Release the argument list
|
||||||
va_end(args);
|
va_end(args);
|
||||||
// Return the data from the buffer
|
// Return the data from the buffer
|
||||||
return g_Buffer;
|
return g_Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
StackGuard::StackGuard()
|
||||||
|
: m_VM(_SqVM), m_Top(sq_gettop(m_VM))
|
||||||
|
{
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
StackGuard::StackGuard(HSQUIRRELVM vm)
|
StackGuard::StackGuard(HSQUIRRELVM vm)
|
||||||
: m_Top(sq_gettop(vm)), m_VM(vm)
|
: m_VM(vm), m_Top(sq_gettop(vm))
|
||||||
{
|
{
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
@ -69,6 +81,16 @@ StackGuard::~StackGuard()
|
|||||||
sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
|
sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DocumentRef::Validate() const
|
||||||
|
{
|
||||||
|
// Is the document handle valid?
|
||||||
|
if (!m_Ptr)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid INI document reference");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger IniResult::Typename(HSQUIRRELVM vm)
|
SQInteger IniResult::Typename(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,11 @@ CSStr FmtStr(CSStr str, ...);
|
|||||||
*/
|
*/
|
||||||
struct StackGuard
|
struct StackGuard
|
||||||
{
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
StackGuard();
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Base constructor.
|
* Base constructor.
|
||||||
*/
|
*/
|
||||||
@ -92,8 +97,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
Int32 m_Top; /* The top of the stack when this instance was created. */
|
HSQUIRRELVM m_VM; // The VM where the stack should be restored.
|
||||||
HSQUIRRELVM m_VM; /* The VM where the stack should be restored. */
|
Int32 m_Top; // The top of the stack when this instance was created.
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -120,6 +125,11 @@ public:
|
|||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef unsigned int Counter; // Reference counter type.
|
typedef unsigned int Counter; // Reference counter type.
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the document reference and throw an error if invalid.
|
||||||
|
*/
|
||||||
|
void Validate() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
@ -132,7 +142,9 @@ private:
|
|||||||
void Grab()
|
void Grab()
|
||||||
{
|
{
|
||||||
if (m_Ptr)
|
if (m_Ptr)
|
||||||
|
{
|
||||||
++(*m_Ref);
|
++(*m_Ref);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -420,11 +432,17 @@ public:
|
|||||||
Int32 Cmp(const IniResult & o) const
|
Int32 Cmp(const IniResult & o) const
|
||||||
{
|
{
|
||||||
if (m_Result == o.m_Result)
|
if (m_Result == o.m_Result)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
else if (m_Result > o.m_Result)
|
else if (m_Result > o.m_Result)
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
@ -20,30 +20,28 @@ SQInteger Document::Typename(HSQUIRRELVM vm)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void Document::Validate() const
|
|
||||||
{
|
|
||||||
// Is the document handle valid?
|
|
||||||
if (!m_Doc)
|
|
||||||
STHROWF("Invalid INI document reference");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 Document::Cmp(const Document & o) const
|
Int32 Document::Cmp(const Document & o) const
|
||||||
{
|
{
|
||||||
if (m_Doc == o.m_Doc)
|
if (m_Doc == o.m_Doc)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
else if (m_Doc.m_Ptr > o.m_Doc.m_Ptr)
|
else if (m_Doc.m_Ptr > o.m_Doc.m_Ptr)
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
IniResult Document::LoadFile(CSStr filepath)
|
IniResult Document::LoadFile(CSStr filepath)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to load the file from disk and return the result
|
// Attempt to load the file from disk and return the result
|
||||||
return IniResult("load INI file", m_Doc->LoadFile(filepath));
|
return IniResult("load INI file", m_Doc->LoadFile(filepath));
|
||||||
}
|
}
|
||||||
@ -52,7 +50,7 @@ IniResult Document::LoadFile(CSStr filepath)
|
|||||||
IniResult Document::LoadData(CSStr source, Int32 size)
|
IniResult Document::LoadData(CSStr source, Int32 size)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to load the file from memory and return the result
|
// Attempt to load the file from memory and return the result
|
||||||
return IniResult("load INI file", m_Doc->LoadData(source, size < 0 ? strlen(source) : size));
|
return IniResult("load INI file", m_Doc->LoadData(source, size < 0 ? strlen(source) : size));
|
||||||
}
|
}
|
||||||
@ -61,7 +59,7 @@ IniResult Document::LoadData(CSStr source, Int32 size)
|
|||||||
IniResult Document::SaveFile(CSStr filepath, bool signature)
|
IniResult Document::SaveFile(CSStr filepath, bool signature)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to save the file to disk and return the result
|
// Attempt to save the file to disk and return the result
|
||||||
return IniResult("save INI file", m_Doc->SaveFile(filepath, signature));
|
return IniResult("save INI file", m_Doc->SaveFile(filepath, signature));
|
||||||
}
|
}
|
||||||
@ -70,12 +68,14 @@ IniResult Document::SaveFile(CSStr filepath, bool signature)
|
|||||||
Object Document::SaveData(bool signature)
|
Object Document::SaveData(bool signature)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// The string where the content will be saved
|
// The string where the content will be saved
|
||||||
String source;
|
String source;
|
||||||
// Attempt to save the data to string
|
// Attempt to save the data to string
|
||||||
if (m_Doc->Save(source, signature) < 0)
|
if (m_Doc->Save(source, signature) < 0)
|
||||||
|
{
|
||||||
STHROWF("Unable to save INI document");
|
STHROWF("Unable to save INI document");
|
||||||
|
}
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const StackGuard sg(_SqVM);
|
const StackGuard sg(_SqVM);
|
||||||
// Transform it into a script object
|
// Transform it into a script object
|
||||||
@ -88,7 +88,7 @@ Object Document::SaveData(bool signature)
|
|||||||
Entries Document::GetAllSections() const
|
Entries Document::GetAllSections() const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Prepare a container to receive the entries
|
// Prepare a container to receive the entries
|
||||||
static Container entries;
|
static Container entries;
|
||||||
// Obtain all sections from the INI document
|
// Obtain all sections from the INI document
|
||||||
@ -101,7 +101,7 @@ Entries Document::GetAllSections() const
|
|||||||
Entries Document::GetAllKeys(CSStr section) const
|
Entries Document::GetAllKeys(CSStr section) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Prepare a container to receive the entries
|
// Prepare a container to receive the entries
|
||||||
static Container entries;
|
static Container entries;
|
||||||
// Obtain all sections from the INI document
|
// Obtain all sections from the INI document
|
||||||
@ -114,7 +114,7 @@ Entries Document::GetAllKeys(CSStr section) const
|
|||||||
Entries Document::GetAllValues(CSStr section, CSStr key) const
|
Entries Document::GetAllValues(CSStr section, CSStr key) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Prepare a container to receive the entries
|
// Prepare a container to receive the entries
|
||||||
static Container entries;
|
static Container entries;
|
||||||
// Obtain all sections from the INI document
|
// Obtain all sections from the INI document
|
||||||
@ -127,7 +127,7 @@ Entries Document::GetAllValues(CSStr section, CSStr key) const
|
|||||||
Int32 Document::GetSectionSize(CSStr section) const
|
Int32 Document::GetSectionSize(CSStr section) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return m_Doc->GetSectionSize(section);
|
return m_Doc->GetSectionSize(section);
|
||||||
}
|
}
|
||||||
@ -136,12 +136,15 @@ Int32 Document::GetSectionSize(CSStr section) const
|
|||||||
bool Document::HasMultipleKeys(CSStr section, CSStr key) const
|
bool Document::HasMultipleKeys(CSStr section, CSStr key) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Where to retrive whether the key has multiple instances
|
// Where to retrive whether the key has multiple instances
|
||||||
bool multiple = false;
|
bool multiple = false;
|
||||||
// Attempt to query the information
|
// Attempt to query the information
|
||||||
if (m_Doc->GetValue(section, key, NULL, &multiple) == NULL)
|
if (m_Doc->GetValue(section, key, nullptr, &multiple) == nullptr)
|
||||||
return true; /* Doesn't exist */
|
{
|
||||||
|
return true; // Doesn't exist
|
||||||
|
}
|
||||||
|
// Return the result
|
||||||
return multiple;
|
return multiple;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,43 +152,43 @@ bool Document::HasMultipleKeys(CSStr section, CSStr key) const
|
|||||||
CCStr Document::GetValue(CSStr section, CSStr key, CSStr def) const
|
CCStr Document::GetValue(CSStr section, CSStr key, CSStr def) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to query the information and return it
|
// Attempt to query the information and return it
|
||||||
return m_Doc->GetValue(section, key, def, NULL);
|
return m_Doc->GetValue(section, key, def, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger Document::GetInteger(CSStr section, CSStr key, SQInteger def) const
|
SQInteger Document::GetInteger(CSStr section, CSStr key, SQInteger def) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to query the information and return it
|
// Attempt to query the information and return it
|
||||||
return (SQInteger)m_Doc->GetLongValue(section, key, def, NULL);
|
return static_cast< SQInteger >(m_Doc->GetLongValue(section, key, def, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQFloat Document::GetFloat(CSStr section, CSStr key, SQFloat def) const
|
SQFloat Document::GetFloat(CSStr section, CSStr key, SQFloat def) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to query the information and return it
|
// Attempt to query the information and return it
|
||||||
return (SQFloat)m_Doc->GetDoubleValue(section, key, def, NULL);
|
return static_cast< SQFloat >(m_Doc->GetDoubleValue(section, key, def, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool Document::GetBoolean(CSStr section, CSStr key, bool def) const
|
bool Document::GetBoolean(CSStr section, CSStr key, bool def) const
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to query the information and return it
|
// Attempt to query the information and return it
|
||||||
return m_Doc->GetBoolValue(section, key, def, NULL);
|
return m_Doc->GetBoolValue(section, key, def, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
IniResult Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment)
|
IniResult Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to apply the specified information and return the result
|
// Attempt to apply the specified information and return the result
|
||||||
return IniResult("set INI value", m_Doc->SetValue(section, key, value, comment, force));
|
return IniResult("set INI value", m_Doc->SetValue(section, key, value, comment, force));
|
||||||
}
|
}
|
||||||
@ -194,7 +197,7 @@ IniResult Document::SetValue(CSStr section, CSStr key, CSStr value, bool force,
|
|||||||
IniResult Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment)
|
IniResult Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to apply the specified information and return the result
|
// Attempt to apply the specified information and return the result
|
||||||
return IniResult("set INI integer", m_Doc->SetLongValue(section, key, value, comment, hex, force));
|
return IniResult("set INI integer", m_Doc->SetLongValue(section, key, value, comment, hex, force));
|
||||||
}
|
}
|
||||||
@ -203,7 +206,7 @@ IniResult Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool h
|
|||||||
IniResult Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment)
|
IniResult Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to apply the specified information and return the result
|
// Attempt to apply the specified information and return the result
|
||||||
return IniResult("set INI float", m_Doc->SetDoubleValue(section, key, value, comment, force));
|
return IniResult("set INI float", m_Doc->SetDoubleValue(section, key, value, comment, force));
|
||||||
}
|
}
|
||||||
@ -212,7 +215,7 @@ IniResult Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force
|
|||||||
IniResult Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment)
|
IniResult Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to apply the specified information
|
// Attempt to apply the specified information
|
||||||
return IniResult("set INI boolean", m_Doc->SetBoolValue(section, key, value, comment, force));
|
return IniResult("set INI boolean", m_Doc->SetBoolValue(section, key, value, comment, force));
|
||||||
}
|
}
|
||||||
@ -221,7 +224,7 @@ IniResult Document::SetBoolean(CSStr section, CSStr key, bool value, bool force,
|
|||||||
bool Document::DeleteValue(CSStr section, CSStr key, CSStr value, bool empty)
|
bool Document::DeleteValue(CSStr section, CSStr key, CSStr value, bool empty)
|
||||||
{
|
{
|
||||||
// Validate the handle
|
// Validate the handle
|
||||||
Validate();
|
m_Doc.Validate();
|
||||||
// Attempt to remove the specified value and return the result
|
// Attempt to remove the specified value and return the result
|
||||||
return m_Doc->DeleteValue(section, key, value, empty);
|
return m_Doc->DeleteValue(section, key, value, empty);
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
Document & operator = (const Document & o);
|
Document & operator = (const Document & o);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Validate the document reference and throw an error if invalid.
|
|
||||||
*/
|
|
||||||
void Validate() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
@ -283,7 +278,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetValue(CSStr section, CSStr key, CSStr value)
|
IniResult SetValue(CSStr section, CSStr key, CSStr value)
|
||||||
{
|
{
|
||||||
return SetValue(section, key, value, false, NULL);
|
return SetValue(section, key, value, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -291,7 +286,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetValue(CSStr section, CSStr key, CSStr value, bool force)
|
IniResult SetValue(CSStr section, CSStr key, CSStr value, bool force)
|
||||||
{
|
{
|
||||||
return SetValue(section, key, value, force, NULL);
|
return SetValue(section, key, value, force, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -304,7 +299,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetInteger(CSStr section, CSStr key, SQInteger value)
|
IniResult SetInteger(CSStr section, CSStr key, SQInteger value)
|
||||||
{
|
{
|
||||||
return SetInteger(section, key, value, false, false, NULL);
|
return SetInteger(section, key, value, false, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -312,7 +307,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
|
IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
|
||||||
{
|
{
|
||||||
return SetInteger(section, key, value, hex, false, NULL);
|
return SetInteger(section, key, value, hex, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -320,7 +315,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
|
IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
|
||||||
{
|
{
|
||||||
return SetInteger(section, key, value, hex, force, NULL);
|
return SetInteger(section, key, value, hex, force, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -333,7 +328,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetFloat(CSStr section, CSStr key, SQFloat value)
|
IniResult SetFloat(CSStr section, CSStr key, SQFloat value)
|
||||||
{
|
{
|
||||||
return SetFloat(section, key, value, false, NULL);
|
return SetFloat(section, key, value, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -341,7 +336,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
|
IniResult SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
|
||||||
{
|
{
|
||||||
return SetFloat(section, key, value, force, NULL);
|
return SetFloat(section, key, value, force, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -354,7 +349,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetBoolean(CSStr section, CSStr key, bool value)
|
IniResult SetBoolean(CSStr section, CSStr key, bool value)
|
||||||
{
|
{
|
||||||
return SetBoolean(section, key, value, false, NULL);
|
return SetBoolean(section, key, value, false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -362,7 +357,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
IniResult SetBoolean(CSStr section, CSStr key, bool value, bool force)
|
IniResult SetBoolean(CSStr section, CSStr key, bool value, bool force)
|
||||||
{
|
{
|
||||||
return SetBoolean(section, key, value, force, NULL);
|
return SetBoolean(section, key, value, force, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -375,7 +370,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool DeleteValue(CSStr section)
|
bool DeleteValue(CSStr section)
|
||||||
{
|
{
|
||||||
return DeleteValue(section, NULL, NULL, false);
|
return DeleteValue(section, nullptr, nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -383,7 +378,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool DeleteValue(CSStr section, CSStr key)
|
bool DeleteValue(CSStr section, CSStr key)
|
||||||
{
|
{
|
||||||
return DeleteValue(section, key, NULL, false);
|
return DeleteValue(section, key, nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
@ -17,11 +17,17 @@ SQInteger Entries::Typename(HSQUIRRELVM vm)
|
|||||||
Int32 Entries::Cmp(const Entries & o) const
|
Int32 Entries::Cmp(const Entries & o) const
|
||||||
{
|
{
|
||||||
if (m_Elem == o.m_Elem)
|
if (m_Elem == o.m_Elem)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
else if (m_List.size() > o.m_List.size())
|
else if (m_List.size() > o.m_List.size())
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -29,7 +35,9 @@ void Entries::Next()
|
|||||||
{
|
{
|
||||||
// Are there any other elements ahead?
|
// Are there any other elements ahead?
|
||||||
if (!m_List.empty() && m_Elem != m_List.end())
|
if (!m_List.empty() && m_Elem != m_List.end())
|
||||||
++m_Elem; /* Go ahead one element */
|
{
|
||||||
|
++m_Elem; // Go ahead one element
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -37,7 +45,9 @@ void Entries::Prev()
|
|||||||
{
|
{
|
||||||
// Are there any other elements behind?
|
// Are there any other elements behind?
|
||||||
if (!m_List.empty() && m_Elem != m_List.begin())
|
if (!m_List.empty() && m_Elem != m_List.begin())
|
||||||
--m_Elem; /* Go back one element */
|
{
|
||||||
|
--m_Elem; // Go back one element
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -45,9 +55,14 @@ void Entries::Advance(Int32 n)
|
|||||||
{
|
{
|
||||||
// Are there any other elements ahead?
|
// Are there any other elements ahead?
|
||||||
if (m_List.empty() || m_Elem == m_List.end())
|
if (m_List.empty() || m_Elem == m_List.end())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Jump as many elements as possible within the specified distance
|
// Jump as many elements as possible within the specified distance
|
||||||
while ((--n >= 0) && m_Elem != m_List.end()) ++m_Elem;
|
while ((--n >= 0) && m_Elem != m_List.end())
|
||||||
|
{
|
||||||
|
++m_Elem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -55,9 +70,14 @@ void Entries::Retreat(Int32 n)
|
|||||||
{
|
{
|
||||||
// Are there any other elements behind?
|
// Are there any other elements behind?
|
||||||
if (m_List.empty() || m_Elem == m_List.begin())
|
if (m_List.empty() || m_Elem == m_List.begin())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Jump as many elements as possible within the specified distance
|
// Jump as many elements as possible within the specified distance
|
||||||
while ((--n >= 0) && m_Elem != m_List.begin()) --m_Elem;
|
while ((--n >= 0) && m_Elem != m_List.begin())
|
||||||
|
{
|
||||||
|
--m_Elem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -65,7 +85,9 @@ CSStr Entries::GetItem() const
|
|||||||
{
|
{
|
||||||
// is the current element valid?
|
// is the current element valid?
|
||||||
if (m_List.empty() || m_Elem == m_List.end())
|
if (m_List.empty() || m_Elem == m_List.end())
|
||||||
|
{
|
||||||
STHROWF("Invalid INI entry [item]");
|
STHROWF("Invalid INI entry [item]");
|
||||||
|
}
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return m_Elem->pItem;
|
return m_Elem->pItem;
|
||||||
}
|
}
|
||||||
@ -75,7 +97,9 @@ CSStr Entries::GetComment() const
|
|||||||
{
|
{
|
||||||
// is the current element valid?
|
// is the current element valid?
|
||||||
if (m_List.empty() || m_Elem == m_List.end())
|
if (m_List.empty() || m_Elem == m_List.end())
|
||||||
|
{
|
||||||
STHROWF("Invalid INI entry [comment]");
|
STHROWF("Invalid INI entry [comment]");
|
||||||
|
}
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return m_Elem->pComment;
|
return m_Elem->pComment;
|
||||||
}
|
}
|
||||||
@ -85,7 +109,9 @@ Int32 Entries::GetOrder() const
|
|||||||
{
|
{
|
||||||
// is the current element valid?
|
// is the current element valid?
|
||||||
if (m_List.empty() || m_Elem == m_List.end())
|
if (m_List.empty() || m_Elem == m_List.end())
|
||||||
|
{
|
||||||
STHROWF("Invalid INI entry [order]");
|
STHROWF("Invalid INI entry [order]");
|
||||||
|
}
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return m_Elem->nOrder;
|
return m_Elem->nOrder;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
DocumentRef m_Doc; /* The document that contains the elements. */
|
DocumentRef m_Doc; // The document that contains the elements.
|
||||||
Container m_List; /* The list of elements to iterate. */
|
Container m_List; // The list of elements to iterate.
|
||||||
Iterator m_Elem; /* The currently processed element. */
|
Iterator m_Elem; // The currently processed element.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
Int32 GetSize() const
|
Int32 GetSize() const
|
||||||
{
|
{
|
||||||
return (Int32)m_List.size();
|
return static_cast< Int32 >(m_List.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -135,9 +135,13 @@ public:
|
|||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
if (m_List.empty())
|
if (m_List.empty())
|
||||||
|
{
|
||||||
m_Elem = m_List.end();
|
m_Elem = m_List.end();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_Elem = m_List.begin();
|
m_Elem = m_List.begin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -166,7 +170,9 @@ public:
|
|||||||
void Sort()
|
void Sort()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
|
{
|
||||||
m_List.sort(DocumentRef::Type::Entry::KeyOrder());
|
m_List.sort(DocumentRef::Type::Entry::KeyOrder());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -175,7 +181,9 @@ public:
|
|||||||
void SortByKeyOrder()
|
void SortByKeyOrder()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
|
{
|
||||||
m_List.sort(DocumentRef::Type::Entry::KeyOrder());
|
m_List.sort(DocumentRef::Type::Entry::KeyOrder());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -184,7 +192,9 @@ public:
|
|||||||
void SortByLoadOrder()
|
void SortByLoadOrder()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
|
{
|
||||||
m_List.sort(DocumentRef::Type::Entry::LoadOrder());
|
m_List.sort(DocumentRef::Type::Entry::LoadOrder());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
#include "Document.hpp"
|
#include "Document.hpp"
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
#include <sqrat.h>
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
#include <stdio.h>
|
#include <sqrat.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
#if defined(WIN32) || defined(_WIN32)
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
@ -20,14 +20,14 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
PluginFuncs* _Func = NULL;
|
PluginFuncs* _Func = nullptr;
|
||||||
PluginCallbacks* _Clbk = NULL;
|
PluginCallbacks* _Clbk = nullptr;
|
||||||
PluginInfo* _Info = NULL;
|
PluginInfo* _Info = nullptr;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
HSQAPI _SqAPI = NULL;
|
HSQAPI _SqAPI = nullptr;
|
||||||
HSQEXPORTS _SqMod = NULL;
|
HSQEXPORTS _SqMod = nullptr;
|
||||||
HSQUIRRELVM _SqVM = NULL;
|
HSQUIRRELVM _SqVM = nullptr;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Bind speciffic functions to certain server events.
|
* Bind speciffic functions to certain server events.
|
||||||
@ -53,7 +53,9 @@ void OnSquirrelInitialize()
|
|||||||
_SqMod = sq_api_import(_Func);
|
_SqMod = sq_api_import(_Func);
|
||||||
// Did we failed to obtain the plugin exports?
|
// Did we failed to obtain the plugin exports?
|
||||||
if(!_SqMod)
|
if(!_SqMod)
|
||||||
|
{
|
||||||
OutputError("Failed to attach [%s] on host plugin.", SQINI_NAME);
|
OutputError("Failed to attach [%s] on host plugin.", SQINI_NAME);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Obtain the Squirrel API
|
// Obtain the Squirrel API
|
||||||
@ -70,12 +72,16 @@ void OnSquirrelLoad()
|
|||||||
{
|
{
|
||||||
// Make sure that we have a valid plugin API
|
// Make sure that we have a valid plugin API
|
||||||
if (!_SqMod)
|
if (!_SqMod)
|
||||||
return; /* Unable to proceed. */
|
{
|
||||||
|
return; // Unable to proceed!
|
||||||
|
}
|
||||||
// Obtain the Squirrel API and VM
|
// Obtain the Squirrel API and VM
|
||||||
_SqVM = _SqMod->GetSquirrelVM();
|
_SqVM = _SqMod->GetSquirrelVM();
|
||||||
// Make sure that a valid virtual machine exists
|
// Make sure that a valid virtual machine exists
|
||||||
if (!_SqVM)
|
if (!_SqVM)
|
||||||
return; /* Unable to proceed. */
|
{
|
||||||
|
return; // Unable to proceed!
|
||||||
|
}
|
||||||
// Set this as the default database
|
// Set this as the default database
|
||||||
DefaultVM::Set(_SqVM);
|
DefaultVM::Set(_SqVM);
|
||||||
// Register the module API
|
// Register the module API
|
||||||
@ -91,7 +97,7 @@ void OnSquirrelTerminate()
|
|||||||
{
|
{
|
||||||
OutputMessage("Terminating: %s", SQINI_NAME);
|
OutputMessage("Terminating: %s", SQINI_NAME);
|
||||||
// Release the current database (if any)
|
// Release the current database (if any)
|
||||||
DefaultVM::Set(NULL);
|
DefaultVM::Set(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -100,10 +106,12 @@ void OnSquirrelTerminate()
|
|||||||
bool CheckAPIVer(CCStr ver)
|
bool CheckAPIVer(CCStr ver)
|
||||||
{
|
{
|
||||||
// Obtain the numeric representation of the API version
|
// Obtain the numeric representation of the API version
|
||||||
long vernum = strtol(ver, NULL, 10);
|
long vernum = std::strtol(ver, nullptr, 10);
|
||||||
// Check against version mismatch
|
// Check against version mismatch
|
||||||
if (vernum == SQMOD_API_VER)
|
if (vernum == SQMOD_API_VER)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
// Log the incident
|
// Log the incident
|
||||||
OutputError("API version mismatch on %s", SQINI_NAME);
|
OutputError("API version mismatch on %s", SQINI_NAME);
|
||||||
OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
|
OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
|
||||||
@ -120,7 +128,9 @@ static int OnInternalCommand(unsigned int type, const char * text)
|
|||||||
{
|
{
|
||||||
case SQMOD_INITIALIZE_CMD:
|
case SQMOD_INITIALIZE_CMD:
|
||||||
if (CheckAPIVer(text))
|
if (CheckAPIVer(text))
|
||||||
|
{
|
||||||
OnSquirrelInitialize();
|
OnSquirrelInitialize();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SQMOD_LOAD_CMD:
|
case SQMOD_LOAD_CMD:
|
||||||
OnSquirrelLoad();
|
OnSquirrelLoad();
|
||||||
@ -158,9 +168,9 @@ void BindCallbacks()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void UnbindCallbacks()
|
void UnbindCallbacks()
|
||||||
{
|
{
|
||||||
_Clbk->OnInitServer = NULL;
|
_Clbk->OnInitServer = nullptr;
|
||||||
_Clbk->OnInternalCommand = NULL;
|
_Clbk->OnInternalCommand = nullptr;
|
||||||
_Clbk->OnShutdownServer = NULL;
|
_Clbk->OnShutdownServer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
@ -169,31 +179,31 @@ void RegisterAPI(HSQUIRRELVM vm)
|
|||||||
Table inins(vm);
|
Table inins(vm);
|
||||||
|
|
||||||
inins.Bind(_SC("Result"), Class< IniResult >(vm, _SC("SqIniResult"))
|
inins.Bind(_SC("Result"), Class< IniResult >(vm, _SC("SqIniResult"))
|
||||||
/* Constructors */
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< CSStr, SQInteger >()
|
.Ctor< CSStr, SQInteger >()
|
||||||
.Ctor< const IniResult & >()
|
.Ctor< const IniResult & >()
|
||||||
/* Core Metamethods */
|
// Core Metamethods
|
||||||
.Func(_SC("_cmp"), &IniResult::Cmp)
|
.Func(_SC("_cmp"), &IniResult::Cmp)
|
||||||
.SquirrelFunc(_SC("_typename"), &IniResult::Typename)
|
.SquirrelFunc(_SC("_typename"), &IniResult::Typename)
|
||||||
.Func(_SC("_tostring"), &IniResult::ToString)
|
.Func(_SC("_tostring"), &IniResult::ToString)
|
||||||
/* Properties */
|
// Properties
|
||||||
.Prop(_SC("Valid"), &IniResult::IsValid)
|
.Prop(_SC("Valid"), &IniResult::IsValid)
|
||||||
.Prop(_SC("Action"), &IniResult::GetAction)
|
.Prop(_SC("Action"), &IniResult::GetAction)
|
||||||
.Prop(_SC("Result"), &IniResult::GetResult)
|
.Prop(_SC("Result"), &IniResult::GetResult)
|
||||||
/* Functions */
|
// Member Methods
|
||||||
.Func(_SC("Check"), &IniResult::Check)
|
.Func(_SC("Check"), &IniResult::Check)
|
||||||
);
|
);
|
||||||
|
|
||||||
inins.Bind(_SC("Entries"), Class< Entries >(vm, _SC("SqIniEntries"))
|
inins.Bind(_SC("Entries"), Class< Entries >(vm, _SC("SqIniEntries"))
|
||||||
/* Constructors */
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< const Entries & >()
|
.Ctor< const Entries & >()
|
||||||
/* Core Metamethods */
|
// Core Metamethods
|
||||||
.Func(_SC("_cmp"), &Entries::Cmp)
|
.Func(_SC("_cmp"), &Entries::Cmp)
|
||||||
.SquirrelFunc(_SC("_typename"), &Entries::Typename)
|
.SquirrelFunc(_SC("_typename"), &Entries::Typename)
|
||||||
.Func(_SC("_tostring"), &Entries::ToString)
|
.Func(_SC("_tostring"), &Entries::ToString)
|
||||||
/* Properties */
|
// Properties
|
||||||
.Prop(_SC("Valid"), &Entries::IsValid)
|
.Prop(_SC("Valid"), &Entries::IsValid)
|
||||||
.Prop(_SC("Empty"), &Entries::IsEmpty)
|
.Prop(_SC("Empty"), &Entries::IsEmpty)
|
||||||
.Prop(_SC("References"), &Entries::GetRefCount)
|
.Prop(_SC("References"), &Entries::GetRefCount)
|
||||||
@ -201,7 +211,7 @@ void RegisterAPI(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("Item"), &Entries::GetItem)
|
.Prop(_SC("Item"), &Entries::GetItem)
|
||||||
.Prop(_SC("Comment"), &Entries::GetComment)
|
.Prop(_SC("Comment"), &Entries::GetComment)
|
||||||
.Prop(_SC("Order"), &Entries::GetOrder)
|
.Prop(_SC("Order"), &Entries::GetOrder)
|
||||||
/* Functions */
|
// Member Methods
|
||||||
.Func(_SC("Reset"), &Entries::Reset)
|
.Func(_SC("Reset"), &Entries::Reset)
|
||||||
.Func(_SC("Next"), &Entries::Next)
|
.Func(_SC("Next"), &Entries::Next)
|
||||||
.Func(_SC("Prev"), &Entries::Prev)
|
.Func(_SC("Prev"), &Entries::Prev)
|
||||||
@ -213,16 +223,16 @@ void RegisterAPI(HSQUIRRELVM vm)
|
|||||||
);
|
);
|
||||||
|
|
||||||
inins.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqIniDocument"))
|
inins.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqIniDocument"))
|
||||||
/* Constructors */
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< bool >()
|
.Ctor< bool >()
|
||||||
.Ctor< bool, bool >()
|
.Ctor< bool, bool >()
|
||||||
.Ctor< bool, bool, bool >()
|
.Ctor< bool, bool, bool >()
|
||||||
/* Core Metamethods */
|
// Core Metamethods
|
||||||
.Func(_SC("_cmp"), &Document::Cmp)
|
.Func(_SC("_cmp"), &Document::Cmp)
|
||||||
.SquirrelFunc(_SC("_typename"), &Document::Typename)
|
.SquirrelFunc(_SC("_typename"), &Document::Typename)
|
||||||
.Func(_SC("_tostring"), &Document::ToString)
|
.Func(_SC("_tostring"), &Document::ToString)
|
||||||
/* Properties */
|
// Properties
|
||||||
.Prop(_SC("Valid"), &Document::IsValid)
|
.Prop(_SC("Valid"), &Document::IsValid)
|
||||||
.Prop(_SC("Empty"), &Document::IsEmpty)
|
.Prop(_SC("Empty"), &Document::IsEmpty)
|
||||||
.Prop(_SC("References"), &Document::GetRefCount)
|
.Prop(_SC("References"), &Document::GetRefCount)
|
||||||
@ -230,7 +240,7 @@ void RegisterAPI(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("MultiKey"), &Document::GetMultiKey, &Document::SetMultiKey)
|
.Prop(_SC("MultiKey"), &Document::GetMultiKey, &Document::SetMultiKey)
|
||||||
.Prop(_SC("MultiLine"), &Document::GetMultiLine, &Document::SetMultiLine)
|
.Prop(_SC("MultiLine"), &Document::GetMultiLine, &Document::SetMultiLine)
|
||||||
.Prop(_SC("Spaces"), &Document::GetSpaces, &Document::SetSpaces)
|
.Prop(_SC("Spaces"), &Document::GetSpaces, &Document::SetSpaces)
|
||||||
/* Functions */
|
// Member Methods
|
||||||
.Func(_SC("Reset"), &Document::Reset)
|
.Func(_SC("Reset"), &Document::Reset)
|
||||||
.Func(_SC("LoadFile"), &Document::LoadFile)
|
.Func(_SC("LoadFile"), &Document::LoadFile)
|
||||||
.Overload< IniResult (Document::*)(CSStr) >(_SC("LoadString"), &Document::LoadData)
|
.Overload< IniResult (Document::*)(CSStr) >(_SC("LoadString"), &Document::LoadData)
|
||||||
@ -400,7 +410,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb
|
|||||||
_Info = info;
|
_Info = info;
|
||||||
// Assign plugin information
|
// Assign plugin information
|
||||||
_Info->uPluginVer = SQINI_VERSION;
|
_Info->uPluginVer = SQINI_VERSION;
|
||||||
strcpy(_Info->szName, SQINI_HOST_NAME);
|
std::strcpy(_Info->szName, SQINI_HOST_NAME);
|
||||||
// Bind callbacks
|
// Bind callbacks
|
||||||
BindCallbacks();
|
BindCallbacks();
|
||||||
// Notify that the plugin was successfully loaded
|
// Notify that the plugin was successfully loaded
|
||||||
|
@ -57,7 +57,7 @@ CSStr FmtStr(CSStr str, ...)
|
|||||||
// Write the requested contents
|
// Write the requested contents
|
||||||
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
|
||||||
{
|
{
|
||||||
g_Buffer[0] = 0; // make sure the string is terminated
|
g_Buffer[0] = 0; // Make sure the string is terminated
|
||||||
}
|
}
|
||||||
// Release the argument list
|
// Release the argument list
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -619,7 +619,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallb
|
|||||||
_Info = info;
|
_Info = info;
|
||||||
// Assign plugin information
|
// Assign plugin information
|
||||||
_Info->uPluginVer = SQIRC_VERSION;
|
_Info->uPluginVer = SQIRC_VERSION;
|
||||||
strcpy(_Info->szName, SQIRC_HOST_NAME);
|
std::strcpy(_Info->szName, SQIRC_HOST_NAME);
|
||||||
// Bind callbacks
|
// Bind callbacks
|
||||||
BindCallbacks();
|
BindCallbacks();
|
||||||
// Notify that the plugin was successfully loaded
|
// Notify that the plugin was successfully loaded
|
||||||
|
Loading…
Reference in New Issue
Block a user