1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-15 22:57:12 +02:00

Separated major non mandatory libraries into their onwn modules.

Consolidated and simplified the module API system.
Various other fixes and improvements.
This commit is contained in:
Sandu Liviu Catalin
2016-02-27 11:57:10 +02:00
parent fa12692490
commit f4a11ef825
82 changed files with 10509 additions and 7580 deletions

View File

@ -1,533 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Library/INI.hpp"
// ------------------------------------------------------------------------------------------------
#include <errno.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
namespace INI {
// ------------------------------------------------------------------------------------------------
Int32 Entries::Cmp(const Entries & o) const
{
if (m_Elem == o.m_Elem)
return 0;
else if (this > &o)
return 1;
else
return -1;
}
// ------------------------------------------------------------------------------------------------
CSStr Entries::ToString() const
{
return GetItem();
}
// ------------------------------------------------------------------------------------------------
void Entries::Next()
{
// Are there any other elements ahead?
if (!m_List.empty() && m_Elem != m_List.end())
++m_Elem; /* Go ahead one element */
}
// ------------------------------------------------------------------------------------------------
void Entries::Prev()
{
// Are there any other elements behind?
if (!m_List.empty() && m_Elem != m_List.begin())
--m_Elem; /* Go back one element */
}
// ------------------------------------------------------------------------------------------------
void Entries::Advance(Int32 n)
{
// Are there any other elements ahead?
if (m_List.empty() || m_Elem == m_List.end())
return;
// Jump as many elements as possible
while ((--n >= 0) && m_Elem != m_List.end()) ++m_Elem;
}
// ------------------------------------------------------------------------------------------------
void Entries::Retreat(Int32 n)
{
// Are there any other elements behind?
if (m_List.empty() || m_Elem == m_List.begin())
return;
// Jump as many elements as possible
while ((--n >= 0) && m_Elem != m_List.begin()) --m_Elem;
}
// ------------------------------------------------------------------------------------------------
CSStr Entries::GetItem() const
{
if (m_List.empty() || m_Elem == m_List.end())
SqThrow("Invalid INI entry [item]");
else
return m_Elem->pItem;
return _SC("");
}
// ------------------------------------------------------------------------------------------------
CSStr Entries::GetComment() const
{
if (m_List.empty() || m_Elem == m_List.end())
SqThrow("Invalid INI entry [comment]");
else
return m_Elem->pComment;
return _SC("");
}
// ------------------------------------------------------------------------------------------------
Int32 Entries::GetOrder() const
{
if (m_List.empty() || m_Elem == m_List.end())
SqThrow("Invalid INI entry [order]");
else
return m_Elem->nOrder;
return -1;
}
// ------------------------------------------------------------------------------------------------
Document::Document()
: m_Doc(false, false, true)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Document::Document(bool utf8, bool multikey, bool multiline)
: m_Doc(utf8, multikey, multiline)
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Document::~Document()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Int32 Document::Cmp(const Document & o) const
{
if (m_Doc == o.m_Doc)
return 0;
else if (this > &o)
return 1;
else
return -1;
}
// ------------------------------------------------------------------------------------------------
CSStr Document::ToString() const
{
return _SC("");
}
// ------------------------------------------------------------------------------------------------
void Document::LoadFile(CSStr filepath)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to load the file from disk
const SI_Error ret = m_Doc->LoadFile(filepath);
// See if the file could be loaded
if (ret < 0)
{
// Identify the error type
switch (ret)
{
case SI_FAIL:
SqThrow("Failed to load the INI file. Probably invalid");
break;
case SI_NOMEM:
SqThrow("Ran out of memory while loading the INI file");
break;
case SI_FILE:
SqThrow("Failed to load the INI file. %s", strerror(errno));
break;
default:
SqThrow("Failed to load the INI file for some unforeseen reason");
}
}
}
// ------------------------------------------------------------------------------------------------
void Document::LoadData(CSStr source, Int32 size)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to load the source from memory
const SI_Error ret = m_Doc->LoadData(source, size < 0 ? strlen(source) : size);
// See if the source could be loaded
if (ret < 0)
{
// Identify the error type
switch (ret)
{
case SI_FAIL:
SqThrow("Failed to load the INI data. Probably invalid");
break;
case SI_NOMEM:
SqThrow("Ran out of memory while loading the INI data");
break;
default:
SqThrow("Failed to load the INI data for some unforeseen reason");
}
}
}
// ------------------------------------------------------------------------------------------------
void Document::SaveFile(CSStr filepath, bool signature)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to save the file to disk
const SI_Error ret = m_Doc->SaveFile(filepath, signature);
// See if the file could be saved
if (ret == SI_FAIL)
{
SqThrow("Failed to save the INI file. Probably invalid");
}
}
// ------------------------------------------------------------------------------------------------
Object Document::SaveData(bool signature)
{
if (!Validate())
return NullObject(); /* Unable to proceed */
// The string where the content will be saved
String source;
// Attempt to save the data to string
const SI_Error ret = m_Doc->Save(source, signature);
// See if the data could be saved
if (ret == SI_FAIL)
{
SqThrow("Failed to save the INI data. Probably invalid");
return NullObject(); /* Unable to proceed */
}
// Transform it into a script object
sq_pushstring(DefaultVM::Get(), source.c_str(), source.size());
// Get the object from the stack
Var< Object & > var(DefaultVM::Get(), -1);
// Pop the created object from the stack
if (!var.value.IsNull())
{
sq_pop(DefaultVM::Get(), 1);
}
// Return the script object
return var.value;
}
// ------------------------------------------------------------------------------------------------
Entries Document::GetAllSections() const
{
if (!Validate())
return Entries(); /* Unable to proceed */
// Prepare a container to receive the entries
static Container entries;
// Obtain all sections from the INI document
m_Doc->GetAllSections(entries);
// Return the entries and take over content
return Entries(m_Doc, entries);
}
// ------------------------------------------------------------------------------------------------
Entries Document::GetAllKeys(CSStr section) const
{
if (!Validate())
return Entries(); /* Unable to proceed */
// Prepare a container to receive the entries
static Container entries;
// Obtain all sections from the INI document
m_Doc->GetAllKeys(section, entries);
// Return the entries and take over content
return Entries(m_Doc, entries);
}
// ------------------------------------------------------------------------------------------------
Entries Document::GetAllValues(CSStr section, CSStr key) const
{
if (!Validate())
return Entries(); /* Unable to proceed */
// Prepare a container to receive the entries
static Container entries;
// Obtain all sections from the INI document
m_Doc->GetAllValues(section, key, entries);
// Return the entries and take over content
return Entries(m_Doc, entries);
}
// ------------------------------------------------------------------------------------------------
Int32 Document::GetSectionSize(CSStr section) const
{
if (Validate())
// Return the requested information
return m_Doc->GetSectionSize(section);
// Return invalid size
return -1;
}
// ------------------------------------------------------------------------------------------------
bool Document::HasMultipleKeys(CSStr section, CSStr key) const
{
if (!Validate())
return false; /* Unable to proceed */
// Where to retrive whether the key has multiple instances
bool multiple = false;
// Attempt to query the information
if (m_Doc->GetValue(section, key, NULL, &multiple) == NULL)
return true; /* Doesn't exist */
return multiple;
}
// ------------------------------------------------------------------------------------------------
CCStr Document::GetValue(CSStr section, CSStr key, CSStr def) const
{
if (!Validate())
return _SC(""); /* Unable to proceed */
// Attempt to query the information and return it
return m_Doc->GetValue(section, key, def, NULL);
}
// ------------------------------------------------------------------------------------------------
SQInteger Document::GetInteger(CSStr section, CSStr key, SQInteger def) const
{
if (!Validate())
return 0; /* Unable to proceed */
// Attempt to query the information and return it
return (SQInteger)m_Doc->GetLongValue(section, key, def, NULL);
}
// ------------------------------------------------------------------------------------------------
SQFloat Document::GetFloat(CSStr section, CSStr key, SQFloat def) const
{
if (!Validate())
return 0.0; /* Unable to proceed */
// Attempt to query the information and return it
return (SQFloat)m_Doc->GetDoubleValue(section, key, def, NULL);
}
// ------------------------------------------------------------------------------------------------
bool Document::GetBoolean(CSStr section, CSStr key, bool def) const
{
if (!Validate())
return false; /* Unable to proceed */
// Attempt to query the information and return it
return m_Doc->GetBoolValue(section, key, def, NULL);
}
// ------------------------------------------------------------------------------------------------
void Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to apply the specified information
const SI_Error ret = m_Doc->SetValue(section, key, value, comment, force);
// See if the information could be applied
if (ret < 0)
{
// Identify the error type
switch (ret)
{
case SI_FAIL:
SqThrow("Failed to set the INI value. Probably invalid");
break;
case SI_NOMEM:
SqThrow("Ran out of memory while setting INI value");
break;
default:
SqThrow("Failed to set the INI value for some unforeseen reason");
}
}
}
// ------------------------------------------------------------------------------------------------
void Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to apply the specified information
const SI_Error ret = m_Doc->SetLongValue(section, key, value, comment, hex, force);
// See if the information could be applied
if (ret < 0)
{
// Identify the error type
switch (ret)
{
case SI_FAIL:
SqThrow("Failed to set the INI integer. Probably invalid");
break;
case SI_NOMEM:
SqThrow("Ran out of memory while setting INI integer");
break;
default:
SqThrow("Failed to set the INI integer for some unforeseen reason");
}
}
}
// ------------------------------------------------------------------------------------------------
void Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to apply the specified information
const SI_Error ret = m_Doc->SetDoubleValue(section, key, value, comment, force);
// See if the information could be applied
if (ret < 0)
{
// Identify the error type
switch (ret)
{
case SI_FAIL:
SqThrow("Failed to set the INI float. Probably invalid");
break;
case SI_NOMEM:
SqThrow("Ran out of memory while setting INI float");
break;
default:
SqThrow("Failed to set the INI float for some unforeseen reason");
}
}
}
// ------------------------------------------------------------------------------------------------
void Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment)
{
if (!Validate())
return; /* Unable to proceed */
// Attempt to apply the specified information
const SI_Error ret = m_Doc->SetBoolValue(section, key, value, comment, force);
// See if the information could be applied
if (ret < 0)
{
// Identify the error type
switch (ret)
{
case SI_FAIL:
SqThrow("Failed to set the INI boolean. Probably invalid");
break;
case SI_NOMEM:
SqThrow("Ran out of memory while setting INI boolean");
break;
default:
SqThrow("Failed to set the INI boolean for some unforeseen reason");
}
}
}
// ------------------------------------------------------------------------------------------------
bool Document::DeleteValue(CSStr section, CSStr key, CSStr value, bool empty)
{
if (!Validate())
return false; /* Unable to proceed */
else if (!section)
{
SqThrow("Invalid INI section");
return false; /* Unable to proceed */
}
else if (!key)
{
SqThrow("Invalid INI key");
return false; /* Unable to proceed */
}
// Attempt to remove the specified value
return m_Doc->DeleteValue(section, key, value, empty);
}
} // Namespace:: INI
// ================================================================================================
void Register_INI(HSQUIRRELVM vm)
{
using namespace INI;
Table inins(vm);
inins.Bind(_SC("Entries"), Class< Entries >(vm, _SC("SqIniEntries"))
/* Constructors */
.Ctor()
.Ctor< const Entries & >()
/* Core Metamethods */
.Func(_SC("_tostring"), &Entries::ToString)
.Func(_SC("_cmp"), &Entries::Cmp)
/* Properties */
.Prop(_SC("Valid"), &Entries::IsValid)
.Prop(_SC("Empty"), &Entries::IsEmpty)
.Prop(_SC("References"), &Entries::GetRefCount)
.Prop(_SC("Size"), &Entries::GetSize)
.Prop(_SC("Item"), &Entries::GetItem)
.Prop(_SC("Comment"), &Entries::GetComment)
.Prop(_SC("Order"), &Entries::GetOrder)
/* Functions */
.Func(_SC("Reset"), &Entries::Reset)
.Func(_SC("Next"), &Entries::Next)
.Func(_SC("Prev"), &Entries::Prev)
.Func(_SC("Advance"), &Entries::Advance)
.Func(_SC("Retreat"), &Entries::Retreat)
.Func(_SC("Sort"), &Entries::Sort)
.Func(_SC("SortByKeyOrder"), &Entries::SortByKeyOrder)
.Func(_SC("SortByLoadOrder"), &Entries::SortByLoadOrder)
.Func(_SC("SortByLoadOrderEmptyFirst"), &Entries::SortByLoadOrderEmptyFirst)
);
inins.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqIniDocument"))
/* Constructors */
.Ctor()
.Ctor< bool, bool, bool >()
/* Core Metamethods */
.Func(_SC("_tostring"), &Document::ToString)
.Func(_SC("_cmp"), &Document::Cmp)
/* Properties */
.Prop(_SC("Valid"), &Document::IsValid)
.Prop(_SC("Empty"), &Document::IsEmpty)
.Prop(_SC("References"), &Document::GetRefCount)
.Prop(_SC("Unicode"), &Document::GetUnicode, &Document::SetUnicode)
.Prop(_SC("MultiKey"), &Document::GetMultiKey, &Document::SetMultiKey)
.Prop(_SC("MultiLine"), &Document::GetMultiLine, &Document::SetMultiLine)
.Prop(_SC("Spaces"), &Document::GetSpaces, &Document::SetSpaces)
/* Functions */
.Func(_SC("Reset"), &Document::Reset)
.Func(_SC("LoadFile"), &Document::LoadFile)
.Overload< void (Document::*)(CSStr) >(_SC("LoadData"), &Document::LoadData)
.Overload< void (Document::*)(CSStr, Int32) >(_SC("LoadData"), &Document::LoadData)
.Overload< void (Document::*)(CSStr) >(_SC("SaveFile"), &Document::SaveFile)
.Overload< void (Document::*)(CSStr, bool) >(_SC("SaveFile"), &Document::SaveFile)
.Func(_SC("SaveData"), &Document::SaveData)
.Func(_SC("GetSections"), &Document::GetAllSections)
.Func(_SC("GetKeys"), &Document::GetAllKeys)
.Func(_SC("GetValues"), &Document::GetAllValues)
.Func(_SC("GetSectionSize"), &Document::GetSectionSize)
.Func(_SC("HasMultipleKeys"), &Document::HasMultipleKeys)
.Func(_SC("GetValue"), &Document::GetValue)
.Func(_SC("GetInteger"), &Document::GetInteger)
.Func(_SC("GetFloat"), &Document::GetFloat)
.Func(_SC("GetBoolean"), &Document::GetBoolean)
.Overload< void (Document::*)(CSStr, CSStr, CSStr) >(_SC("SetValue"), &Document::SetValue)
.Overload< void (Document::*)(CSStr, CSStr, CSStr, bool) >(_SC("SetValue"), &Document::SetValue)
.Overload< void (Document::*)(CSStr, CSStr, CSStr, bool, CSStr) >(_SC("SetValue"), &Document::SetValue)
.Overload< void (Document::*)(CSStr, CSStr, SQInteger) >(_SC("SetInteger"), &Document::SetInteger)
.Overload< void (Document::*)(CSStr, CSStr, SQInteger, bool) >(_SC("SetInteger"), &Document::SetInteger)
.Overload< void (Document::*)(CSStr, CSStr, SQInteger, bool, bool) >(_SC("SetInteger"), &Document::SetInteger)
.Overload< void (Document::*)(CSStr, CSStr, SQInteger, bool, bool, CSStr) >(_SC("SetInteger"), &Document::SetInteger)
.Overload< void (Document::*)(CSStr, CSStr, SQFloat) >(_SC("SetFloat"), &Document::SetFloat)
.Overload< void (Document::*)(CSStr, CSStr, SQFloat, bool) >(_SC("SetFloat"), &Document::SetFloat)
.Overload< void (Document::*)(CSStr, CSStr, SQFloat, bool, CSStr) >(_SC("SetFloat"), &Document::SetFloat)
.Overload< void (Document::*)(CSStr, CSStr, bool) >(_SC("SetBoolean"), &Document::SetBoolean)
.Overload< void (Document::*)(CSStr, CSStr, bool, bool) >(_SC("SetBoolean"), &Document::SetBoolean)
.Overload< void (Document::*)(CSStr, CSStr, bool, bool, CSStr) >(_SC("SetBoolean"), &Document::SetBoolean)
.Overload< bool (Document::*)(CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
.Overload< bool (Document::*)(CSStr, CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
.Overload< bool (Document::*)(CSStr, CSStr, CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
.Overload< bool (Document::*)(CSStr, CSStr, CSStr, bool) >(_SC("DeleteValue"), &Document::DeleteValue)
);
RootTable(vm).Bind(_SC("SqIni"), inins);
}
} // Namespace:: SqMod

View File

@ -1,736 +0,0 @@
#ifndef _LIBRARY_INI_HPP_
#define _LIBRARY_INI_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
#include <SimpleIni.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
namespace INI {
// ------------------------------------------------------------------------------------------------
class Entries;
class Document;
/* ------------------------------------------------------------------------------------------------
* Manages a reference counted INI document instance.
*/
class DocumentRef
{
// --------------------------------------------------------------------------------------------
friend class Document;
private:
// --------------------------------------------------------------------------------------------
typedef CSimpleIniA IrcDocument;
// --------------------------------------------------------------------------------------------
typedef unsigned int Counter;
// --------------------------------------------------------------------------------------------
IrcDocument* m_Ptr; /* The document reader, writer and manager instance. */
Counter* m_Ref; /* Reference count to the managed instance. */
/* --------------------------------------------------------------------------------------------
* Grab a strong reference to a document instance.
*/
void Grab()
{
if (m_Ptr)
{
++(*m_Ref);
}
}
/* --------------------------------------------------------------------------------------------
* Drop a strong reference to a document instance.
*/
void Drop()
{
if (m_Ptr && --(*m_Ref) == 0)
{
delete m_Ptr;
delete m_Ref;
m_Ptr = NULL;
m_Ref = NULL;
}
}
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
DocumentRef(bool utf8, bool multikey, bool multiline)
: m_Ptr(new IrcDocument(utf8, multikey, multiline)), m_Ref(new Counter(1))
{
/* ... */
}
public:
/* --------------------------------------------------------------------------------------------
* Default constructor (null).
*/
DocumentRef()
: m_Ptr(NULL), m_Ref(NULL)
{
/* ... */
}
/* --------------------------------------------------------------------------------------------
* Copy constructor.
*/
DocumentRef(const DocumentRef & o)
: m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
{
Grab();
}
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~DocumentRef()
{
Drop();
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator.
*/
DocumentRef & operator = (const DocumentRef & o)
{
if (m_Ptr != o.m_Ptr)
{
Drop();
m_Ptr = o.m_Ptr;
m_Ref = o.m_Ref;
Grab();
}
return *this;
}
/* --------------------------------------------------------------------------------------------
* Perform an equality comparison between two document instances.
*/
bool operator == (const DocumentRef & o) const
{
return (m_Ptr == o.m_Ptr);
}
/* --------------------------------------------------------------------------------------------
* Perform an inequality comparison between two document instances.
*/
bool operator != (const DocumentRef & o) const
{
return (m_Ptr != o.m_Ptr);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean for use in boolean operations.
*/
operator bool () const
{
return m_Ptr;
}
/* --------------------------------------------------------------------------------------------
* Member operator for dereferencing the managed pointer.
*/
IrcDocument * operator -> () const
{
assert(m_Ptr != NULL);
return m_Ptr;
}
/* --------------------------------------------------------------------------------------------
* Indirection operator for obtaining a reference of the managed pointer.
*/
IrcDocument & operator * () const
{
assert(m_Ptr != NULL);
return *m_Ptr;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the number of active references to the managed instance.
*/
Counter Count() const
{
return (m_Ptr && m_Ref) ? (*m_Ref) : 0;
}
};
/* ------------------------------------------------------------------------------------------------
* Class that can access and iterate a series of entries in the INI document.
*/
class Entries
{
// --------------------------------------------------------------------------------------------
friend class Document;
protected:
// --------------------------------------------------------------------------------------------
typedef CSimpleIniA IrcDocument;
// --------------------------------------------------------------------------------------------
typedef IrcDocument::TNamesDepend Container;
// --------------------------------------------------------------------------------------------
typedef Container::iterator Iterator;
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
Entries(const DocumentRef & ini, Container & list)
: m_Doc(ini), m_List(), m_Elem()
{
m_List.swap(list);
Reset();
}
private:
// ---------------------------------------------------------------------------------------------
DocumentRef m_Doc; /* The document that contains the elements. */
Container m_List; /* The list of elements to iterate. */
Iterator m_Elem; /* The currently processed element. */
public:
/* --------------------------------------------------------------------------------------------
* Default constructor. (null)
*/
Entries()
: m_Doc(), m_List(), m_Elem(m_List.end())
{
/* ... */
}
/* --------------------------------------------------------------------------------------------
* Copy constructor.
*/
Entries(const Entries & o)
: m_Doc(o.m_Doc), m_List(o.m_List), m_Elem()
{
Reset();
}
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~Entries()
{
/* ... */
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator.
*/
Entries & operator = (const Entries & o)
{
m_Doc = o.m_Doc;
m_List = o.m_List;
Reset();
return *this;
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type.
*/
Int32 Cmp(const Entries & o) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Return whether the current element is valid and can be accessed.
*/
bool IsValid() const
{
return !(m_List.empty() || m_Elem == m_List.end());
}
/* --------------------------------------------------------------------------------------------
* Return whether the entry list is empty.
*/
bool IsEmpty() const
{
return m_List.empty();
}
/* --------------------------------------------------------------------------------------------
* Return the number of active references to this document instance.
*/
Uint32 GetRefCount() const
{
return m_Doc.Count();
}
/* --------------------------------------------------------------------------------------------
* Return the total entries in the list.
*/
Int32 GetSize() const
{
return (Int32)m_List.size();
}
/* --------------------------------------------------------------------------------------------
* Reset the internal iterator to the first element.
*/
void Reset()
{
if (m_List.empty())
m_Elem = m_List.end();
else
m_Elem = m_List.begin();
}
/* --------------------------------------------------------------------------------------------
* Go to the next element.
*/
void Next();
/* --------------------------------------------------------------------------------------------
* Go to the previous element.
*/
void Prev();
/* --------------------------------------------------------------------------------------------
* Advance a certain number of elements.
*/
void Advance(Int32 n);
/* --------------------------------------------------------------------------------------------
* Retreat a certain number of elements.
*/
void Retreat(Int32 n);
/* --------------------------------------------------------------------------------------------
* Sort the entries using the default options.
*/
void Sort()
{
if (!m_List.empty())
m_List.sort(IrcDocument::Entry::KeyOrder());
}
/* --------------------------------------------------------------------------------------------
* Sort the entries by name of key only.
*/
void SortByKeyOrder()
{
if (!m_List.empty())
m_List.sort(IrcDocument::Entry::KeyOrder());
}
/* --------------------------------------------------------------------------------------------
* Sort the entries by their load order and then name of key.
*/
void SortByLoadOrder()
{
if (!m_List.empty())
m_List.sort(IrcDocument::Entry::LoadOrder());
}
/* --------------------------------------------------------------------------------------------
* Sort the entries by their load order but empty name always goes first.
*/
void SortByLoadOrderEmptyFirst()
{
if (!m_List.empty())
m_List.sort(IrcDocument::Entry::LoadOrderEmptyFirst());
}
/* --------------------------------------------------------------------------------------------
* Retrieve the string value of the current element item.
*/
CSStr GetItem() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the string value of the current element comment.
*/
CSStr GetComment() const;
/* --------------------------------------------------------------------------------------------
* Retrieve the order of the current element.
*/
Int32 GetOrder() const;
};
/* ------------------------------------------------------------------------------------------------
* Class that can read/write and alter the contents of INI files.
*/
class Document
{
protected:
// --------------------------------------------------------------------------------------------
typedef CSimpleIniA IrcDocument;
// --------------------------------------------------------------------------------------------
typedef IrcDocument::TNamesDepend Container;
/* --------------------------------------------------------------------------------------------
* Copy constructor. (disabled)
*/
Document(const Document & o);
/* --------------------------------------------------------------------------------------------
* Copy assignment operator. (disabled)
*/
Document & operator = (const Document & o);
/* --------------------------------------------------------------------------------------------
* Validate the document reference.
*/
bool Validate() const
{
if (m_Doc)
return true;
SqThrow("Invalid INI document reference");
return false;
}
private:
// ---------------------------------------------------------------------------------------------
DocumentRef m_Doc; /* The main INI document instance. */
public:
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
Document();
/* --------------------------------------------------------------------------------------------
* Explicit constructor.
*/
Document(bool utf8, bool multikey, bool multiline);
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~Document();
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type.
*/
Int32 Cmp(const Document & o) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* See whether this instance references a valid INI document.
*/
bool IsValid() const
{
return m_Doc;
}
/* --------------------------------------------------------------------------------------------
* See whether any data has been loaded into this document.
*/
bool IsEmpty() const
{
return m_Doc->IsEmpty();
}
/* --------------------------------------------------------------------------------------------
* Return the number of active references to this document instance.
*/
Uint32 GetRefCount() const
{
return m_Doc.Count();
}
/* --------------------------------------------------------------------------------------------
* Deallocate all memory stored by this document.
*/
void Reset() const
{
m_Doc->Reset();
}
/* --------------------------------------------------------------------------------------------
* See whether the INI data is treated as unicode.
*/
bool GetUnicode() const
{
return m_Doc->IsUnicode();
}
/* --------------------------------------------------------------------------------------------
* Set whether the INI data should be treated as unicode.
*/
void SetUnicode(bool toggle)
{
m_Doc->SetUnicode(toggle);
}
/* --------------------------------------------------------------------------------------------
* See whether multiple identical keys be permitted in the file.
*/
bool GetMultiKey() const
{
return m_Doc->IsMultiKey();
}
/* --------------------------------------------------------------------------------------------
* Set whether multiple identical keys be permitted in the file.
*/
void SetMultiKey(bool toggle)
{
m_Doc->SetMultiKey(toggle);
}
/* --------------------------------------------------------------------------------------------
* See whether data values are permitted to span multiple lines in the file.
*/
bool GetMultiLine() const
{
return m_Doc->IsMultiLine();
}
/* --------------------------------------------------------------------------------------------
* Set whether data values are permitted to span multiple lines in the file.
*/
void SetMultiLine(bool toggle)
{
m_Doc->SetMultiLine(toggle);
}
/* --------------------------------------------------------------------------------------------
* See whether spaces are added around the equals sign when writing key/value pairs out.
*/
bool GetSpaces() const
{
return m_Doc->UsingSpaces();
}
/* --------------------------------------------------------------------------------------------
* Set whether spaces are added around the equals sign when writing key/value pairs out.
*/
void SetSpaces(bool toggle)
{
m_Doc->SetSpaces(toggle);
}
/* --------------------------------------------------------------------------------------------
* Load an INI file from disk into memory.
*/
void LoadFile(CSStr filepath);
/* --------------------------------------------------------------------------------------------
* Load INI file data direct from a string.
*/
void LoadData(CSStr source)
{
LoadData(source, -1);
}
/* --------------------------------------------------------------------------------------------
* Load INI file data direct from a string.
*/
void LoadData(CSStr source, Int32 size);
/* --------------------------------------------------------------------------------------------
* Save an INI file from memory to disk.
*/
void SaveFile(CSStr filepath)
{
SaveFile(filepath, true);
}
/* --------------------------------------------------------------------------------------------
* Save an INI file from memory to disk.
*/
void SaveFile(CSStr filepath, bool signature);
/* --------------------------------------------------------------------------------------------
* Save the INI data to a string.
*/
Object SaveData(bool signature);
/* --------------------------------------------------------------------------------------------
* Retrieve all section names.
*/
Entries GetAllSections() const;
/* --------------------------------------------------------------------------------------------
* Retrieve all unique key names in a section.
*/
Entries GetAllKeys(CSStr section) const;
/* --------------------------------------------------------------------------------------------
* Retrieve all values for a specific key.
*/
Entries GetAllValues(CSStr section, CSStr key) const;
/* --------------------------------------------------------------------------------------------
* Query the number of keys in a specific section.
*/
Int32 GetSectionSize(CSStr section) const;
/* --------------------------------------------------------------------------------------------
* See whether a certain key has multiple instances.
*/
bool HasMultipleKeys(CSStr section, CSStr key) const;
/* --------------------------------------------------------------------------------------------
* Retrieve the value for a specific key.
*/
CCStr GetValue(CSStr section, CSStr key, CSStr def) const;
/* --------------------------------------------------------------------------------------------
* Retrieve a numeric value for a specific key.
*/
SQInteger GetInteger(CSStr section, CSStr key, SQInteger def) const;
/* --------------------------------------------------------------------------------------------
* Retrieve a numeric value for a specific key.
*/
SQFloat GetFloat(CSStr section, CSStr key, SQFloat def) const;
/* --------------------------------------------------------------------------------------------
* Retrieve a boolean value for a specific key.
*/
bool GetBoolean(CSStr section, CSStr key, bool def) const;
/* --------------------------------------------------------------------------------------------
* Add or update a section or value.
*/
void SetValue(CSStr section, CSStr key, CSStr value)
{
SetValue(section, key, value, false, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a section or value.
*/
void SetValue(CSStr section, CSStr key, CSStr value, bool force)
{
SetValue(section, key, value, force, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a section or value.
*/
void SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment);
/* --------------------------------------------------------------------------------------------
* Add or update a numeric value.
*/
void SetInteger(CSStr section, CSStr key, SQInteger value)
{
SetInteger(section, key, value, false, false, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a numeric value.
*/
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
{
SetInteger(section, key, value, hex, false, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a numeric value.
*/
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
{
SetInteger(section, key, value, hex, force, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a numeric value.
*/
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment);
/* --------------------------------------------------------------------------------------------
* Add or update a double value.
*/
void SetFloat(CSStr section, CSStr key, SQFloat value)
{
SetFloat(section, key, value, false, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a double value.
*/
void SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
{
SetFloat(section, key, value, force, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a double value.
*/
void SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment);
/* --------------------------------------------------------------------------------------------
* Add or update a double value.
*/
void SetBoolean(CSStr section, CSStr key, bool value)
{
SetBoolean(section, key, value, false, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a double value.
*/
void SetBoolean(CSStr section, CSStr key, bool value, bool force)
{
SetBoolean(section, key, value, force, NULL);
}
/* --------------------------------------------------------------------------------------------
* Add or update a boolean value.
*/
void SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment);
/* --------------------------------------------------------------------------------------------
* Delete an entire section, or a key from a section.
*/
bool DeleteValue(CSStr section)
{
return DeleteValue(section, NULL, NULL, false);
}
/* --------------------------------------------------------------------------------------------
* Delete an entire section, or a key from a section.
*/
bool DeleteValue(CSStr section, CSStr key)
{
return DeleteValue(section, key, NULL, false);
}
/* --------------------------------------------------------------------------------------------
* Delete an entire section, or a key from a section.
*/
bool DeleteValue(CSStr section, CSStr key, CSStr value)
{
return DeleteValue(section, key, value, false);
}
/* --------------------------------------------------------------------------------------------
* Delete an entire section, or a key from a section.
*/
bool DeleteValue(CSStr section, CSStr key, CSStr value, bool empty);
};
} // Namespace:: INI
} // Namespace:: SqMod
#endif // _LIBRARY_INI_HPP_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -78,15 +78,22 @@ void Register_Numeric(HSQUIRRELVM vm)
/* Properties */
.Prop(_SC("Str"), &SLongInt::GetCStr, &SLongInt::SetStr)
.Prop(_SC("Num"), &SLongInt::GetSNum, &SLongInt::SetNum)
/* Metamethods */
/* Core Metamethods */
.Func(_SC("_tostring"), &SLongInt::ToString)
.Func(_SC("_typename"), &SLongInt::Typename)
.Func(_SC("_cmp"), &SLongInt::Cmp)
/* Metamethods */
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_add"), &SLongInt::operator +)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_sub"), &SLongInt::operator -)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_mul"), &SLongInt::operator *)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_div"), &SLongInt::operator /)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_modulo"), &SLongInt::operator %)
.Func< SLongInt (SLongInt::*)(void) const >(_SC("_unm"), &SLongInt::operator -)
/* Functions */
.Func(_SC("GetStr"), &SLongInt::GetCStr)
.Func(_SC("SetStr"), &SLongInt::SetStr)
.Func(_SC("GetNum"), &SLongInt::GetSNum)
.Func(_SC("SetNum"), &SLongInt::SetNum)
/* Overloads */
.Overload< void (SLongInt::*)(void) >(_SC("Random"), &SLongInt::Random)
.Overload< void (SLongInt::*)(SLongInt::Type) >(_SC("Random"), &SLongInt::Random)
@ -101,15 +108,22 @@ void Register_Numeric(HSQUIRRELVM vm)
/* Properties */
.Prop(_SC("Str"), &ULongInt::GetCStr, &ULongInt::SetStr)
.Prop(_SC("Num"), &ULongInt::GetSNum, &ULongInt::SetNum)
/* Metamethods */
/* Core Metamethods */
.Func(_SC("_tostring"), &ULongInt::ToString)
.Func(_SC("_typename"), &ULongInt::Typename)
.Func(_SC("_cmp"), &ULongInt::Cmp)
/* Metamethods */
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_add"), &ULongInt::operator +)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_sub"), &ULongInt::operator -)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_mul"), &ULongInt::operator *)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_div"), &ULongInt::operator /)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_modulo"), &ULongInt::operator %)
.Func< ULongInt (ULongInt::*)(void) const >(_SC("_unm"), &ULongInt::operator -)
/* Functions */
.Func(_SC("GetStr"), &ULongInt::GetCStr)
.Func(_SC("SetStr"), &ULongInt::SetStr)
.Func(_SC("GetNum"), &ULongInt::GetSNum)
.Func(_SC("SetNum"), &ULongInt::SetNum)
/* Overloads */
.Overload< void (ULongInt::*)(void) >(_SC("Random"), &ULongInt::Random)
.Overload< void (ULongInt::*)(ULongInt::Type) >(_SC("Random"), &ULongInt::Random)

View File

@ -173,6 +173,14 @@ public:
*/
CSStr ToString();
/* --------------------------------------------------------------------------------------------
*
*/
CSStr Typename() const
{
return _SC("SLongInt");
}
/* --------------------------------------------------------------------------------------------
*
*/
@ -384,6 +392,14 @@ public:
*/
CSStr ToString();
/* --------------------------------------------------------------------------------------------
*
*/
CSStr Typename() const
{
return _SC("ULongInt");
}
/* --------------------------------------------------------------------------------------------
*
*/

View File

@ -307,7 +307,7 @@ static CSStr RandomString(Int32 len, SQChar n)
}
Buffer b(len+1);
SStr s = b.Get< SQChar >();
for (Int32 n = 0; n <= len; ++n, ++s)
for (Int32 i = 0; i <= len; ++i, ++s)
{
*s = g_RGen.Integer< SQChar >(n);
}
@ -324,7 +324,7 @@ static CSStr RandomString(Int32 len, SQChar m, SQChar n)
}
Buffer b(len+1);
SStr s = b.Get< SQChar >();
for (Int32 n = 0; n <= len; ++n, ++s)
for (Int32 i = 0; i <= len; ++i, ++s)
{
*s = g_RGen.IntegerC< SQChar >(m, n);
}

View File

@ -131,6 +131,14 @@ public:
*/
void SetNow();
/* --------------------------------------------------------------------------------------------
*
*/
Int64 GetNum() const
{
return m_Timestamp;
}
/* --------------------------------------------------------------------------------------------
*
*/

View File

@ -0,0 +1,41 @@
#ifndef _LIBRARY_UTILS_HPP_
#define _LIBRARY_UTILS_HPP_
// ------------------------------------------------------------------------------------------------
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
*
*/
class Blob
{
/* --------------------------------------------------------------------------------------------
*
*/
Blob(const Blob &);
/* --------------------------------------------------------------------------------------------
*
*/
Blob & operator = (const Blob &);
public:
/* --------------------------------------------------------------------------------------------
*
*/
Blob();
/* --------------------------------------------------------------------------------------------
*
*/
~Blob();
};
} // Namespace:: SqMod
#endif // _LIBRARY_UTILS_HPP_

View File

@ -1,325 +0,0 @@
// ------------------------------------------------------------------------------------------------
#include "Library/XML.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
namespace XML {
// ------------------------------------------------------------------------------------------------
void XmlParseResult::Check() const
{
if (m_Result.status != status_ok)
SqThrow("Xml parse error [%s]", m_Result.description());
}
// ------------------------------------------------------------------------------------------------
XmlNode XmlText::GetData() const
{
return XmlNode(m_Doc, m_Text.data());
}
// ------------------------------------------------------------------------------------------------
XmlNode XmlDocument::GetNode() const
{
if (m_Doc)
return XmlNode(m_Doc, m_Doc->document_element());
return XmlNode();
}
} // Namespace:: XML
// ================================================================================================
void Register_XML(HSQUIRRELVM vm)
{
using namespace XML;
Table xmlns(vm);
xmlns.Bind(_SC("ParseResult"), Class< XmlParseResult >(vm, _SC("SqXmlParseResult"))
/* Constructors */
.Ctor()
.Ctor< const XmlParseResult & >()
/* Core Metamethods */
.Func(_SC("_cmp"), &XmlParseResult::Cmp)
.Func(_SC("_tostring"), &XmlParseResult::ToString)
/* Properties */
.Prop(_SC("Valid"), &XmlParseResult::IsValid)
.Prop(_SC("References"), &XmlParseResult::GetRefCount)
.Prop(_SC("Ok"), &XmlParseResult::IsOk)
.Prop(_SC("Status"), &XmlParseResult::GetStatus)
.Prop(_SC("Offset"), &XmlParseResult::GetOffset)
.Prop(_SC("Encoding"), &XmlParseResult::GetEncoding)
.Prop(_SC("Description"), &XmlParseResult::GetDescription)
/* Functions */
.Func(_SC("Check"), &XmlParseResult::Check)
);
xmlns.Bind(_SC("Attribute"), Class< XmlAttribute >(vm, _SC("SqXmlAttribute"))
/* Constructors */
.Ctor()
.Ctor< const XmlAttribute & >()
/* Core Metamethods */
.Func(_SC("_cmp"), &XmlAttribute::Cmp)
.Func(_SC("_tostring"), &XmlAttribute::ToString)
/* Properties */
.Prop(_SC("Valid"), &XmlAttribute::IsValid)
.Prop(_SC("References"), &XmlAttribute::GetRefCount)
.Prop(_SC("Empty"), &XmlAttribute::IsEmpty)
.Prop(_SC("Hash"), &XmlAttribute::GetHashValue)
.Prop(_SC("Name"), &XmlAttribute::GetName, &XmlAttribute::SetName)
.Prop(_SC("Value"), &XmlAttribute::GetValue, &XmlAttribute::SetValue)
.Prop(_SC("Int"), &XmlAttribute::GetInt, &XmlAttribute::SetInt)
.Prop(_SC("Uint"), &XmlAttribute::GetUint, &XmlAttribute::SetUint)
.Prop(_SC("Float"), &XmlAttribute::GetFloat, &XmlAttribute::SetFloat)
.Prop(_SC("Double"), &XmlAttribute::GetDouble, &XmlAttribute::SetDouble)
.Prop(_SC("Long"), &XmlAttribute::GetLong, &XmlAttribute::SetLong)
.Prop(_SC("Ulong"), &XmlAttribute::GetUlong, &XmlAttribute::SetUlong)
.Prop(_SC("Bool"), &XmlAttribute::GetBool, &XmlAttribute::SetBool)
.Prop(_SC("Next"), &XmlAttribute::NextAttribute)
.Prop(_SC("Prev"), &XmlAttribute::PrevAttribute)
/* Functions */
.Func(_SC("SetName"), &XmlAttribute::ApplyName)
.Func(_SC("SetValue"), &XmlAttribute::ApplyValue)
.Func(_SC("AsString"), &XmlAttribute::AsString)
.Func(_SC("AsInt"), &XmlAttribute::AsInt)
.Func(_SC("AsUint"), &XmlAttribute::AsUint)
.Func(_SC("AsFloat"), &XmlAttribute::AsFloat)
.Func(_SC("AsDouble"), &XmlAttribute::AsDouble)
.Func(_SC("AsLong"), &XmlAttribute::AsLong)
.Func(_SC("AsUlong"), &XmlAttribute::AsUlong)
.Func(_SC("AsBool"), &XmlAttribute::AsBool)
.Func(_SC("SetString"), &XmlAttribute::ApplyString)
.Func(_SC("SetInt"), &XmlAttribute::ApplyInt)
.Func(_SC("SetUint"), &XmlAttribute::ApplyUint)
.Func(_SC("SetFloat"), &XmlAttribute::ApplyFloat)
.Func(_SC("SetDouble"), &XmlAttribute::ApplyDouble)
.Func(_SC("SetLong"), &XmlAttribute::ApplyLong)
.Func(_SC("SetUlong"), &XmlAttribute::ApplyUlong)
.Func(_SC("SetBool"), &XmlAttribute::ApplyBool)
);
xmlns.Bind(_SC("Text"), Class< XmlText >(vm, _SC("SqXmlText"))
/* Constructors */
.Ctor()
.Ctor< const XmlText & >()
/* Core Metamethods */
.Func(_SC("_cmp"), &XmlText::Cmp)
.Func(_SC("_tostring"), &XmlText::ToString)
/* Properties */
.Prop(_SC("Valid"), &XmlText::IsValid)
.Prop(_SC("References"), &XmlText::GetRefCount)
.Prop(_SC("Empty"), &XmlText::IsEmpty)
.Prop(_SC("Value"), &XmlText::GetValue)
.Prop(_SC("Int"), &XmlText::GetInt, &XmlText::SetInt)
.Prop(_SC("Uint"), &XmlText::GetUint, &XmlText::SetUint)
.Prop(_SC("Float"), &XmlText::GetFloat, &XmlText::SetFloat)
.Prop(_SC("Double"), &XmlText::GetDouble, &XmlText::SetDouble)
.Prop(_SC("Long"), &XmlText::GetLong, &XmlText::SetLong)
.Prop(_SC("Ulong"), &XmlText::GetUlong, &XmlText::SetUlong)
.Prop(_SC("Bool"), &XmlText::GetBool, &XmlText::SetBool)
.Prop(_SC("Data"), &XmlText::GetData)
/* Functions */
.Func(_SC("AsString"), &XmlText::AsString)
.Func(_SC("AsInt"), &XmlText::AsInt)
.Func(_SC("AsUint"), &XmlText::AsUint)
.Func(_SC("AsFloat"), &XmlText::AsFloat)
.Func(_SC("AsDouble"), &XmlText::AsDouble)
.Func(_SC("AsLong"), &XmlText::AsLong)
.Func(_SC("AsUlong"), &XmlText::AsUlong)
.Func(_SC("AsBool"), &XmlText::AsBool)
.Func(_SC("SetString"), &XmlText::ApplyString)
.Func(_SC("SetInt"), &XmlText::ApplyInt)
.Func(_SC("SetUint"), &XmlText::ApplyUint)
.Func(_SC("SetFloat"), &XmlText::ApplyFloat)
.Func(_SC("SetDouble"), &XmlText::ApplyDouble)
.Func(_SC("SetLong"), &XmlText::ApplyLong)
.Func(_SC("SetUlong"), &XmlText::ApplyUlong)
.Func(_SC("SetBool"), &XmlText::ApplyBool)
);
xmlns.Bind(_SC("Node"), Class< XmlNode >(vm, _SC("SqXmlNode"))
/* Constructors */
.Ctor()
.Ctor< const XmlNode & >()
/* Core Metamethods */
.Func(_SC("_cmp"), &XmlNode::Cmp)
.Func(_SC("_tostring"), &XmlNode::ToString)
/* Properties */
.Prop(_SC("Valid"), &XmlNode::IsValid)
.Prop(_SC("References"), &XmlNode::GetRefCount)
.Prop(_SC("Empty"), &XmlNode::IsEmpty)
.Prop(_SC("Hash"), &XmlNode::GetHashValue)
.Prop(_SC("OffsetDebug"), &XmlNode::GetOffsetDebug)
.Prop(_SC("Type"), &XmlNode::GetType)
.Prop(_SC("Name"), &XmlNode::GetName, &XmlNode::SetName)
.Prop(_SC("Value"), &XmlNode::GetValue, &XmlNode::SetValue)
.Prop(_SC("FirstAttr"), &XmlNode::GetFirstAttr)
.Prop(_SC("LastAttr"), &XmlNode::GetLastAttr)
.Prop(_SC("FirstChild"), &XmlNode::GetFirstChild)
.Prop(_SC("LastChild"), &XmlNode::GetLastChild)
.Prop(_SC("NextSibling"), &XmlNode::GetNextSibling)
.Prop(_SC("PrevSibling"), &XmlNode::GetPrevSibling)
.Prop(_SC("Parent"), &XmlNode::GetParent)
.Prop(_SC("Root"), &XmlNode::GetRoot)
.Prop(_SC("Text"), &XmlNode::GetText)
.Prop(_SC("ChildValue"), &XmlNode::GetChildValue)
/* Functions */
.Overload< XmlParseResult (XmlNode::*)(CSStr) >(_SC("AppendBuffer"), &XmlNode::AppendBuffer)
.Overload< XmlParseResult (XmlNode::*)(CSStr, Uint32) >(_SC("AppendBuffer"), &XmlNode::AppendBuffer)
.Overload< XmlParseResult (XmlNode::*)(CSStr, Uint32, Int32) >(_SC("AppendBuffer"), &XmlNode::AppendBuffer)
.Func(_SC("SetName"), &XmlNode::ApplyName)
.Func(_SC("SetValue"), &XmlNode::ApplyValue)
.Func(_SC("GetChild"), &XmlNode::Child)
.Func(_SC("GetAttr"), &XmlNode::Attribute)
.Func(_SC("GetAttribute"), &XmlNode::Attribute)
.Func(_SC("GetAttrFrom"), &XmlNode::AttributeFrom)
.Func(_SC("GetAttributeFrom"), &XmlNode::AttributeFrom)
.Func(_SC("GetNextSibling"), &XmlNode::NextSibling)
.Func(_SC("GetPrevSibling"), &XmlNode::PrevSibling)
.Func(_SC("GetChildValue"), &XmlNode::ChildValue)
.Func(_SC("AppendAttr"), &XmlNode::AppendAttr)
.Func(_SC("PrependAttr"), &XmlNode::PrependAttr)
.Func(_SC("InsertAttrAfter"), &XmlNode::InsertAttrAfter)
.Func(_SC("InsertAttrBefore"), &XmlNode::InsertAttrBefore)
.Func(_SC("AppendAttrCopy"), &XmlNode::AppendAttrCopy)
.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)
.Func(_SC("AppendChildNode"), &XmlNode::AppendChildNode)
.Func(_SC("PrependChildNode"), &XmlNode::PrependChildNode)
.Func(_SC("AppendChildType"), &XmlNode::AppendChildType)
.Func(_SC("PrependChildType"), &XmlNode::PrependChildType)
.Func(_SC("InsertChildAfter"), &XmlNode::InsertChildAfter)
.Func(_SC("InsertChildBefore"), &XmlNode::InsertChildBefore)
.Func(_SC("InsertChildTypeAfter"), &XmlNode::InsertChildTypeAfter)
.Func(_SC("InsertChildTypeBefore"), &XmlNode::InsertChildTypeBefore)
.Func(_SC("AppendCopy"), &XmlNode::AppendCopy)
.Func(_SC("PrependCopy"), &XmlNode::PrependCopy)
.Func(_SC("InsertCopyAfter"), &XmlNode::InsertCopyAfter)
.Func(_SC("InsertCopyBefore"), &XmlNode::InsertCopyBefore)
.Func(_SC("AppendMove"), &XmlNode::AppendMove)
.Func(_SC("PrependMove"), &XmlNode::PrependMove)
.Func(_SC("InsertMoveAfter"), &XmlNode::InsertMoveAfter)
.Func(_SC("InsertMoveBefore"), &XmlNode::InsertMoveBefore)
.Func(_SC("RemoveAttr"), &XmlNode::RemoveAttr)
.Func(_SC("RemoveAttrInst"), &XmlNode::RemoveAttrInst)
.Func(_SC("RemoveChild"), &XmlNode::RemoveChild)
.Func(_SC("RemoveChildInst"), &XmlNode::RemoveChildInst)
.Overload< XmlNode (XmlNode::*)(CSStr, CSStr) const >(_SC("FindChildByAttr"), &XmlNode::FindChildByAttr)
.Overload< XmlNode (XmlNode::*)(CSStr, CSStr, CSStr) const >(_SC("FindChildByAttr"), &XmlNode::FindChildByAttr)
.Func(_SC("FindElemByPath"), &XmlNode::FindElemByPath)
);
xmlns.Bind(_SC("Document"), Class< XmlDocument, NoCopy< XmlDocument > >(vm, _SC("SqXmlDocument"))
/* Constructors */
.Ctor()
/* Core Metamethods */
.Func(_SC("_cmp"), &XmlDocument::Cmp)
.Func(_SC("_tostring"), &XmlDocument::ToString)
/* Properties */
.Prop(_SC("Valid"), &XmlDocument::IsValid)
.Prop(_SC("References"), &XmlDocument::GetRefCount)
.Prop(_SC("Node"), &XmlDocument::GetNode)
/* Functions */
.Overload< void (XmlDocument::*)(void) >(_SC("Reset"), &XmlDocument::Reset)
.Overload< void (XmlDocument::*)(const XmlDocument &) >(_SC("Reset"), &XmlDocument::Reset)
.Overload< XmlParseResult (XmlDocument::*)(CSStr) >(_SC("LoadString"), &XmlDocument::LoadString)
.Overload< XmlParseResult (XmlDocument::*)(CSStr, Uint32) >(_SC("LoadString"), &XmlDocument::LoadString)
.Overload< XmlParseResult (XmlDocument::*)(CSStr) >(_SC("LoadFile"), &XmlDocument::LoadFile)
.Overload< XmlParseResult (XmlDocument::*)(CSStr, Uint32) >(_SC("LoadFile"), &XmlDocument::LoadFile)
.Overload< XmlParseResult (XmlDocument::*)(CSStr, Uint32, Int32) >(_SC("LoadFile"), &XmlDocument::LoadFile)
.Overload< void (XmlDocument::*)(CSStr) >(_SC("SaveFile"), &XmlDocument::SaveFile)
.Overload< void (XmlDocument::*)(CSStr, CSStr) >(_SC("SaveFile"), &XmlDocument::SaveFile)
.Overload< void (XmlDocument::*)(CSStr, CSStr, Uint32) >(_SC("SaveFile"), &XmlDocument::SaveFile)
.Overload< void (XmlDocument::*)(CSStr, CSStr, Uint32, Int32) >(_SC("SaveFile"), &XmlDocument::SaveFile)
);
RootTable(vm).Bind(_SC("SqXml"), xmlns);
ConstTable(vm).Enum(_SC("SqXmlNodeType"), Enumeration(vm)
.Const(_SC("Null"), Int32(node_null))
.Const(_SC("Document"), Int32(node_document))
.Const(_SC("Element"), Int32(node_element))
.Const(_SC("PCData"), Int32(node_pcdata))
.Const(_SC("CData"), Int32(node_cdata))
.Const(_SC("Comment"), Int32(node_comment))
.Const(_SC("Pi"), Int32(node_pi))
.Const(_SC("Declaration"), Int32(node_declaration))
.Const(_SC("Doctype"), Int32(node_doctype))
);
ConstTable(vm).Enum(_SC("SqXmlParse"), Enumeration(vm)
.Const(_SC("Minimal"), Int32(parse_minimal))
.Const(_SC("Default"), Int32(parse_default))
.Const(_SC("Full"), Int32(parse_full))
.Const(_SC("Pi"), Int32(parse_pi))
.Const(_SC("Comments"), Int32(parse_comments))
.Const(_SC("CData"), Int32(parse_cdata))
.Const(_SC("WSPCData"), Int32(parse_ws_pcdata))
.Const(_SC("Escapes"), Int32(parse_escapes))
.Const(_SC("EOL"), Int32(parse_eol))
.Const(_SC("WConvAttribute"), Int32(parse_wconv_attribute))
.Const(_SC("WNormAttribute"), Int32(parse_wnorm_attribute))
.Const(_SC("Declaration"), Int32(parse_declaration))
.Const(_SC("Doctype"), Int32(parse_doctype))
.Const(_SC("WSPCDataSingle"), Int32(parse_ws_pcdata_single))
.Const(_SC("TrimPCData"), Int32(parse_trim_pcdata))
.Const(_SC("Fragment"), Int32(parse_fragment))
.Const(_SC("EmbedPCData"), Int32(parse_embed_pcdata))
);
ConstTable(vm).Enum(_SC("SqXmlEncoding"), Enumeration(vm)
.Const(_SC("Auto"), Int32(encoding_auto))
.Const(_SC("Utf8"), Int32(encoding_utf8))
.Const(_SC("Utf16LE"), Int32(encoding_utf16_le))
.Const(_SC("Utf16BE"), Int32(encoding_utf16_be))
.Const(_SC("Utf16"), Int32(encoding_utf16))
.Const(_SC("Utf32LE"), Int32(encoding_utf32_le))
.Const(_SC("Utf32BE"), Int32(encoding_utf32_be))
.Const(_SC("Utf32"), Int32(encoding_utf32))
.Const(_SC("WChar"), Int32(encoding_wchar))
.Const(_SC("Latin1"), Int32(encoding_latin1))
);
ConstTable(vm).Enum(_SC("SqXmlFormat"), Enumeration(vm)
.Const(_SC("Indent"), Int32(format_indent))
.Const(_SC("WriteBOM"), Int32(format_write_bom))
.Const(_SC("Raw"), Int32(format_raw))
.Const(_SC("NoDeclaration"), Int32(format_no_declaration))
.Const(_SC("NoEscapes"), Int32(format_no_escapes))
.Const(_SC("SaveFileText"), Int32(format_save_file_text))
.Const(_SC("IndentAttributes"), Int32(format_indent_attributes))
.Const(_SC("Default"), Int32(format_default))
);
ConstTable(vm).Enum(_SC("SqXmlParseStatus"), Enumeration(vm)
.Const(_SC("Ok"), Int32(status_ok))
.Const(_SC("FileNotFound"), Int32(status_file_not_found))
.Const(_SC("IOError"), Int32(status_io_error))
.Const(_SC("OutOfMemory"), Int32(status_out_of_memory))
.Const(_SC("InternalError"), Int32(status_internal_error))
.Const(_SC("UnrecognizedTag"), Int32(status_unrecognized_tag))
.Const(_SC("BadPi"), Int32(status_bad_pi))
.Const(_SC("BadComment"), Int32(status_bad_comment))
.Const(_SC("BadCData"), Int32(status_bad_cdata))
.Const(_SC("BadDoctype"), Int32(status_bad_doctype))
.Const(_SC("BadPCData"), Int32(status_bad_pcdata))
.Const(_SC("BadStartElement"), Int32(status_bad_start_element))
.Const(_SC("BadAttribute"), Int32(status_bad_attribute))
.Const(_SC("BadEndElement"), Int32(status_bad_end_element))
.Const(_SC("EndElementMismatch"), Int32(status_end_element_mismatch))
.Const(_SC("AppendInvalidRoot"), Int32(status_append_invalid_root))
.Const(_SC("NoDocumentElement"), Int32(status_no_document_element))
);
ConstTable(vm).Enum(_SC("SqXmlXpathValueType"), Enumeration(vm)
.Const(_SC("None"), Int32(xpath_type_none))
.Const(_SC("NodeSet"), Int32(xpath_type_node_set))
.Const(_SC("Number"), Int32(xpath_type_number))
.Const(_SC("String"), Int32(xpath_type_string))
.Const(_SC("Boolean"), Int32(xpath_type_boolean))
);
}
} // Namespace:: SqMod

File diff suppressed because it is too large Load Diff