mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-18 19:47:15 +01:00
Discarded validations already performed by the ini library as wel as a few other minor changes and fixes.
This commit is contained in:
parent
22f1bb5a0c
commit
c4f6de2afd
@ -8,7 +8,7 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 IniEntries::Cmp(const IniEntries & o)
|
Int32 IniEntries::Cmp(const IniEntries & o) const
|
||||||
{
|
{
|
||||||
if (m_Elem == o.m_Elem)
|
if (m_Elem == o.m_Elem)
|
||||||
return 0;
|
return 0;
|
||||||
@ -111,7 +111,7 @@ IniDocument::~IniDocument()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 IniDocument::Cmp(const IniDocument & o)
|
Int32 IniDocument::Cmp(const IniDocument & o) const
|
||||||
{
|
{
|
||||||
if (m_Doc == o.m_Doc)
|
if (m_Doc == o.m_Doc)
|
||||||
return 0;
|
return 0;
|
||||||
@ -132,11 +132,6 @@ void IniDocument::LoadFile(CSStr filepath)
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!filepath)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini filepath");
|
|
||||||
return; /* Nothing to load */
|
|
||||||
}
|
|
||||||
// Attempt to load the file from disk
|
// Attempt to load the file from disk
|
||||||
const SI_Error ini_ret = m_Doc->LoadFile(filepath);
|
const SI_Error ini_ret = m_Doc->LoadFile(filepath);
|
||||||
// See if the file could be loaded
|
// See if the file could be loaded
|
||||||
@ -165,11 +160,6 @@ void IniDocument::LoadData(CSStr source, Int32 size)
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!source)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini source");
|
|
||||||
return; /* Nothing to load */
|
|
||||||
}
|
|
||||||
// Attempt to load the source from memory
|
// Attempt to load the source from memory
|
||||||
const SI_Error ini_ret = m_Doc->LoadData(source, size < 0 ? strlen(source) : size);
|
const SI_Error ini_ret = m_Doc->LoadData(source, size < 0 ? strlen(source) : size);
|
||||||
// See if the source could be loaded
|
// See if the source could be loaded
|
||||||
@ -195,11 +185,6 @@ void IniDocument::SaveFile(CSStr filepath, bool signature)
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!filepath)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini filepath");
|
|
||||||
return; /* Nothing to load */
|
|
||||||
}
|
|
||||||
// Attempt to save the file to disk
|
// Attempt to save the file to disk
|
||||||
const SI_Error ini_ret = m_Doc->SaveFile(filepath, signature);
|
const SI_Error ini_ret = m_Doc->SaveFile(filepath, signature);
|
||||||
// See if the file could be saved
|
// See if the file could be saved
|
||||||
@ -244,8 +229,6 @@ IniEntries IniDocument::GetAllSections() const
|
|||||||
return IniEntries(); /* Unable to proceed */
|
return IniEntries(); /* Unable to proceed */
|
||||||
// Prepare a container to receive the entries
|
// Prepare a container to receive the entries
|
||||||
static Container entries;
|
static Container entries;
|
||||||
// Clear previous values (if any)
|
|
||||||
entries.clear();
|
|
||||||
// Obtain all sections from the ini document
|
// Obtain all sections from the ini document
|
||||||
m_Doc->GetAllSections(entries);
|
m_Doc->GetAllSections(entries);
|
||||||
// Return the entries and take over content
|
// Return the entries and take over content
|
||||||
@ -257,15 +240,8 @@ IniEntries IniDocument::GetAllKeys(CSStr section) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return IniEntries(); /* Unable to proceed */
|
return IniEntries(); /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return IniEntries(); /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// Prepare a container to receive the entries
|
// Prepare a container to receive the entries
|
||||||
static Container entries;
|
static Container entries;
|
||||||
// Clear previous values (if any)
|
|
||||||
entries.clear();
|
|
||||||
// Obtain all sections from the ini document
|
// Obtain all sections from the ini document
|
||||||
m_Doc->GetAllKeys(section, entries);
|
m_Doc->GetAllKeys(section, entries);
|
||||||
// Return the entries and take over content
|
// Return the entries and take over content
|
||||||
@ -277,20 +253,8 @@ IniEntries IniDocument::GetAllValues(CSStr section, CSStr key) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return IniEntries(); /* Unable to proceed */
|
return IniEntries(); /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return IniEntries(); /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return IniEntries(); /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// Prepare a container to receive the entries
|
// Prepare a container to receive the entries
|
||||||
static Container entries;
|
static Container entries;
|
||||||
// Clear previous values (if any)
|
|
||||||
entries.clear();
|
|
||||||
// Obtain all sections from the ini document
|
// Obtain all sections from the ini document
|
||||||
m_Doc->GetAllValues(section, key, entries);
|
m_Doc->GetAllValues(section, key, entries);
|
||||||
// Return the entries and take over content
|
// Return the entries and take over content
|
||||||
@ -300,12 +264,8 @@ IniEntries IniDocument::GetAllValues(CSStr section, CSStr key) const
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Int32 IniDocument::GetSectionSize(CSStr section) const
|
Int32 IniDocument::GetSectionSize(CSStr section) const
|
||||||
{
|
{
|
||||||
if (!Validate())
|
if (Validate())
|
||||||
(void)(section); /* Just ignore... */
|
// Return the requested information
|
||||||
else if (!section)
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
// Return the requested information
|
|
||||||
else
|
|
||||||
return m_Doc->GetSectionSize(section);
|
return m_Doc->GetSectionSize(section);
|
||||||
// Return invalid size
|
// Return invalid size
|
||||||
return -1;
|
return -1;
|
||||||
@ -316,16 +276,6 @@ bool IniDocument::HasMultipleKeys(CSStr section, CSStr key) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return false; /* Unable to proceed */
|
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 */
|
|
||||||
}
|
|
||||||
// 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
|
||||||
@ -339,16 +289,6 @@ CCStr IniDocument::GetValue(CSStr section, CSStr key, CSStr def) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return _SC(""); /* Unable to proceed */
|
return _SC(""); /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return _SC(""); /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return _SC(""); /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// 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, NULL);
|
||||||
}
|
}
|
||||||
@ -358,16 +298,6 @@ SQInteger IniDocument::GetInteger(CSStr section, CSStr key, SQInteger def) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return 0; /* Unable to proceed */
|
return 0; /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return 0; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return 0; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// 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 (SQInteger)m_Doc->GetLongValue(section, key, def, NULL);
|
||||||
}
|
}
|
||||||
@ -377,16 +307,6 @@ SQFloat IniDocument::GetFloat(CSStr section, CSStr key, SQFloat def) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return 0.0; /* Unable to proceed */
|
return 0.0; /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return 0.0; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return 0.0; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// 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 (SQFloat)m_Doc->GetDoubleValue(section, key, def, NULL);
|
||||||
}
|
}
|
||||||
@ -396,16 +316,6 @@ bool IniDocument::GetBoolean(CSStr section, CSStr key, bool def) const
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return false; /* Unable to proceed */
|
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 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, NULL);
|
||||||
}
|
}
|
||||||
@ -415,16 +325,6 @@ void IniDocument::SetValue(CSStr section, CSStr key, CSStr value, bool force, CS
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// Attempt to apply the specified information
|
// Attempt to apply the specified information
|
||||||
const SI_Error ini_ret = m_Doc->SetValue(section, key, value, comment, force);
|
const SI_Error ini_ret = m_Doc->SetValue(section, key, value, comment, force);
|
||||||
// See if the information could be applied
|
// See if the information could be applied
|
||||||
@ -450,16 +350,6 @@ void IniDocument::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// Attempt to apply the specified information
|
// Attempt to apply the specified information
|
||||||
const SI_Error ini_ret = m_Doc->SetLongValue(section, key, value, comment, hex, force);
|
const SI_Error ini_ret = m_Doc->SetLongValue(section, key, value, comment, hex, force);
|
||||||
// See if the information could be applied
|
// See if the information could be applied
|
||||||
@ -485,16 +375,6 @@ void IniDocument::SetFloat(CSStr section, CSStr key, SQFloat value, bool force,
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// Attempt to apply the specified information
|
// Attempt to apply the specified information
|
||||||
const SI_Error ini_ret = m_Doc->SetDoubleValue(section, key, value, comment, force);
|
const SI_Error ini_ret = m_Doc->SetDoubleValue(section, key, value, comment, force);
|
||||||
// See if the information could be applied
|
// See if the information could be applied
|
||||||
@ -520,16 +400,6 @@ void IniDocument::SetBoolean(CSStr section, CSStr key, bool value, bool force, C
|
|||||||
{
|
{
|
||||||
if (!Validate())
|
if (!Validate())
|
||||||
return; /* Unable to proceed */
|
return; /* Unable to proceed */
|
||||||
else if (!section)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini section");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
else if (!key)
|
|
||||||
{
|
|
||||||
SqThrow("Invalid ini key");
|
|
||||||
return; /* Unable to proceed */
|
|
||||||
}
|
|
||||||
// Attempt to apply the specified information
|
// Attempt to apply the specified information
|
||||||
const SI_Error ini_ret = m_Doc->SetBoolValue(section, key, value, comment, force);
|
const SI_Error ini_ret = m_Doc->SetBoolValue(section, key, value, comment, force);
|
||||||
// See if the information could be applied
|
// See if the information could be applied
|
||||||
@ -584,6 +454,7 @@ void Register_INI(HSQUIRRELVM vm)
|
|||||||
/* Properties */
|
/* Properties */
|
||||||
.Prop(_SC("Valid"), &IniEntries::IsValid)
|
.Prop(_SC("Valid"), &IniEntries::IsValid)
|
||||||
.Prop(_SC("Empty"), &IniEntries::IsEmpty)
|
.Prop(_SC("Empty"), &IniEntries::IsEmpty)
|
||||||
|
.Prop(_SC("References"), &IniEntries::GetRefCount)
|
||||||
.Prop(_SC("Size"), &IniEntries::GetSize)
|
.Prop(_SC("Size"), &IniEntries::GetSize)
|
||||||
.Prop(_SC("Item"), &IniEntries::GetItem)
|
.Prop(_SC("Item"), &IniEntries::GetItem)
|
||||||
.Prop(_SC("Comment"), &IniEntries::GetComment)
|
.Prop(_SC("Comment"), &IniEntries::GetComment)
|
||||||
@ -610,6 +481,7 @@ void Register_INI(HSQUIRRELVM vm)
|
|||||||
/* Properties */
|
/* Properties */
|
||||||
.Prop(_SC("Valid"), &IniDocument::IsValid)
|
.Prop(_SC("Valid"), &IniDocument::IsValid)
|
||||||
.Prop(_SC("Empty"), &IniDocument::IsEmpty)
|
.Prop(_SC("Empty"), &IniDocument::IsEmpty)
|
||||||
|
.Prop(_SC("References"), &IniDocument::GetRefCount)
|
||||||
.Prop(_SC("Unicode"), &IniDocument::GetUnicode, &IniDocument::SetUnicode)
|
.Prop(_SC("Unicode"), &IniDocument::GetUnicode, &IniDocument::SetUnicode)
|
||||||
.Prop(_SC("MultiKey"), &IniDocument::GetMultiKey, &IniDocument::SetMultiKey)
|
.Prop(_SC("MultiKey"), &IniDocument::GetMultiKey, &IniDocument::SetMultiKey)
|
||||||
.Prop(_SC("MultiLine"), &IniDocument::GetMultiLine, &IniDocument::SetMultiLine)
|
.Prop(_SC("MultiLine"), &IniDocument::GetMultiLine, &IniDocument::SetMultiLine)
|
||||||
|
@ -15,9 +15,9 @@ class IniEntries;
|
|||||||
class IniDocument;
|
class IniDocument;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Manages a reference counted ini source instance.
|
* Manages a reference counted ini document instance.
|
||||||
*/
|
*/
|
||||||
class IniRef
|
class IniDocumentRef
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
friend class IniDocument;
|
friend class IniDocument;
|
||||||
@ -25,17 +25,17 @@ class IniRef
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef CSimpleIniA Source;
|
typedef CSimpleIniA Document;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef unsigned int Counter;
|
typedef unsigned int Counter;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
Source* m_Ptr; /* The ini reader, writer and manager instance. */
|
Document* m_Ptr; /* The document reader, writer and manager instance. */
|
||||||
Counter* m_Ref; /* Reference count to the managed instance. */
|
Counter* m_Ref; /* Reference count to the managed instance. */
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Grab a strong reference to a ini instance.
|
* Grab a strong reference to a document instance.
|
||||||
*/
|
*/
|
||||||
void Grab()
|
void Grab()
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Drop a strong reference to a ini instance.
|
* Drop a strong reference to a document instance.
|
||||||
*/
|
*/
|
||||||
void Drop()
|
void Drop()
|
||||||
{
|
{
|
||||||
@ -62,8 +62,8 @@ private:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Base constructor.
|
* Base constructor.
|
||||||
*/
|
*/
|
||||||
IniRef(bool utf8, bool multikey, bool multiline)
|
IniDocumentRef(bool utf8, bool multikey, bool multiline)
|
||||||
: m_Ptr(new Source(utf8, multikey, multiline)), m_Ref(new Counter(1))
|
: m_Ptr(new Document(utf8, multikey, multiline)), m_Ref(new Counter(1))
|
||||||
{
|
{
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor (null).
|
* Default constructor (null).
|
||||||
*/
|
*/
|
||||||
IniRef()
|
IniDocumentRef()
|
||||||
: m_Ptr(NULL), m_Ref(NULL)
|
: m_Ptr(NULL), m_Ref(NULL)
|
||||||
{
|
{
|
||||||
/* ... */
|
/* ... */
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
IniRef(const IniRef & o)
|
IniDocumentRef(const IniDocumentRef & o)
|
||||||
: m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
|
: m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~IniRef()
|
~IniDocumentRef()
|
||||||
{
|
{
|
||||||
Drop();
|
Drop();
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator.
|
* Copy assignment operator.
|
||||||
*/
|
*/
|
||||||
IniRef & operator = (const IniRef & o)
|
IniDocumentRef & operator = (const IniDocumentRef & o)
|
||||||
{
|
{
|
||||||
if (m_Ptr != o.m_Ptr)
|
if (m_Ptr != o.m_Ptr)
|
||||||
{
|
{
|
||||||
@ -113,17 +113,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Perform an equality comparison between two ini instances.
|
* Perform an equality comparison between two document instances.
|
||||||
*/
|
*/
|
||||||
bool operator == (const IniRef & o) const
|
bool operator == (const IniDocumentRef & o) const
|
||||||
{
|
{
|
||||||
return (m_Ptr == o.m_Ptr);
|
return (m_Ptr == o.m_Ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Perform an inequality comparison between two ini instances.
|
* Perform an inequality comparison between two document instances.
|
||||||
*/
|
*/
|
||||||
bool operator != (const IniRef & o) const
|
bool operator != (const IniDocumentRef & o) const
|
||||||
{
|
{
|
||||||
return (m_Ptr != o.m_Ptr);
|
return (m_Ptr != o.m_Ptr);
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Member operator for dereferencing the managed pointer.
|
* Member operator for dereferencing the managed pointer.
|
||||||
*/
|
*/
|
||||||
Source * operator -> () const
|
Document * operator -> () const
|
||||||
{
|
{
|
||||||
assert(m_Ptr != NULL);
|
assert(m_Ptr != NULL);
|
||||||
return m_Ptr;
|
return m_Ptr;
|
||||||
@ -148,11 +148,20 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Indirection operator for obtaining a reference of the managed pointer.
|
* Indirection operator for obtaining a reference of the managed pointer.
|
||||||
*/
|
*/
|
||||||
Source & operator * () const
|
Document & operator * () const
|
||||||
{
|
{
|
||||||
assert(m_Ptr != NULL);
|
assert(m_Ptr != NULL);
|
||||||
return *m_Ptr;
|
return *m_Ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of active references to the managed instance.
|
||||||
|
*/
|
||||||
|
Counter Count() const
|
||||||
|
{
|
||||||
|
return (m_Ptr && m_Ref) ? (*m_Ref) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -166,18 +175,18 @@ class IniEntries
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef CSimpleIniA Source;
|
typedef CSimpleIniA Document;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef Source::TNamesDepend Container;
|
typedef Document::TNamesDepend Container;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef Container::iterator Iterator;
|
typedef Container::iterator Iterator;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
IniEntries(const IniRef & ini, Container & list)
|
IniEntries(const IniDocumentRef & ini, Container & list)
|
||||||
: m_Doc(ini), m_List(), m_Elem()
|
: m_Doc(ini), m_List(), m_Elem()
|
||||||
{
|
{
|
||||||
m_List.swap(list);
|
m_List.swap(list);
|
||||||
@ -187,13 +196,13 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
IniRef m_Doc; /* The document that contains the elements. */
|
IniDocumentRef 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:
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor. (null)
|
* Default constructor. (null)
|
||||||
*/
|
*/
|
||||||
IniEntries()
|
IniEntries()
|
||||||
@ -202,7 +211,7 @@ public:
|
|||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
IniEntries(const IniEntries & o)
|
IniEntries(const IniEntries & o)
|
||||||
@ -211,7 +220,7 @@ public:
|
|||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~IniEntries()
|
~IniEntries()
|
||||||
@ -219,7 +228,7 @@ public:
|
|||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator.
|
* Copy assignment operator.
|
||||||
*/
|
*/
|
||||||
IniEntries & operator = (const IniEntries & o)
|
IniEntries & operator = (const IniEntries & o)
|
||||||
@ -230,17 +239,17 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Used by the script engine to compare two instances of this type.
|
* Used by the script engine to compare two instances of this type.
|
||||||
*/
|
*/
|
||||||
Int32 Cmp(const IniEntries & o);
|
Int32 Cmp(const IniEntries & o) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Used by the script engine to convert an instance of this type to a string.
|
* Used by the script engine to convert an instance of this type to a string.
|
||||||
*/
|
*/
|
||||||
CSStr ToString() const;
|
CSStr ToString() const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Return whether the current element is valid and can be accessed.
|
* Return whether the current element is valid and can be accessed.
|
||||||
*/
|
*/
|
||||||
bool IsValid() const
|
bool IsValid() const
|
||||||
@ -248,7 +257,7 @@ public:
|
|||||||
return !(m_List.empty() || m_Elem == m_List.end());
|
return !(m_List.empty() || m_Elem == m_List.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Return whether the entry list is empty.
|
* Return whether the entry list is empty.
|
||||||
*/
|
*/
|
||||||
bool IsEmpty() const
|
bool IsEmpty() const
|
||||||
@ -256,7 +265,15 @@ public:
|
|||||||
return m_List.empty();
|
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.
|
* Return the total entries in the list.
|
||||||
*/
|
*/
|
||||||
Int32 GetSize() const
|
Int32 GetSize() const
|
||||||
@ -264,7 +281,7 @@ public:
|
|||||||
return (Int32)m_List.size();
|
return (Int32)m_List.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reset the internal iterator to the first element.
|
* Reset the internal iterator to the first element.
|
||||||
*/
|
*/
|
||||||
void Reset()
|
void Reset()
|
||||||
@ -275,73 +292,73 @@ public:
|
|||||||
m_Elem = m_List.begin();
|
m_Elem = m_List.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Go to the next element.
|
* Go to the next element.
|
||||||
*/
|
*/
|
||||||
void Next();
|
void Next();
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Go to the previous element.
|
* Go to the previous element.
|
||||||
*/
|
*/
|
||||||
void Prev();
|
void Prev();
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Advance a certain number of elements.
|
* Advance a certain number of elements.
|
||||||
*/
|
*/
|
||||||
void Advance(Int32 n);
|
void Advance(Int32 n);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retreat a certain number of elements.
|
* Retreat a certain number of elements.
|
||||||
*/
|
*/
|
||||||
void Retreat(Int32 n);
|
void Retreat(Int32 n);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Sort the entries using the default options.
|
* Sort the entries using the default options.
|
||||||
*/
|
*/
|
||||||
void Sort()
|
void Sort()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
m_List.sort(Source::Entry::KeyOrder());
|
m_List.sort(Document::Entry::KeyOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Sort the entries by name of key only.
|
* Sort the entries by name of key only.
|
||||||
*/
|
*/
|
||||||
void SortByKeyOrder()
|
void SortByKeyOrder()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
m_List.sort(Source::Entry::KeyOrder());
|
m_List.sort(Document::Entry::KeyOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Sort the entries by their load order and then name of key.
|
* Sort the entries by their load order and then name of key.
|
||||||
*/
|
*/
|
||||||
void SortByLoadOrder()
|
void SortByLoadOrder()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
m_List.sort(Source::Entry::LoadOrder());
|
m_List.sort(Document::Entry::LoadOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Sort the entries by their load order but empty name always goes first.
|
* Sort the entries by their load order but empty name always goes first.
|
||||||
*/
|
*/
|
||||||
void SortByLoadOrderEmptyFirst()
|
void SortByLoadOrderEmptyFirst()
|
||||||
{
|
{
|
||||||
if (!m_List.empty())
|
if (!m_List.empty())
|
||||||
m_List.sort(Source::Entry::LoadOrderEmptyFirst());
|
m_List.sort(Document::Entry::LoadOrderEmptyFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the string value of the current element item.
|
* Retrieve the string value of the current element item.
|
||||||
*/
|
*/
|
||||||
CSStr GetItem() const;
|
CSStr GetItem() const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the string value of the current element comment.
|
* Retrieve the string value of the current element comment.
|
||||||
*/
|
*/
|
||||||
CSStr GetComment() const;
|
CSStr GetComment() const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the order of the current element.
|
* Retrieve the order of the current element.
|
||||||
*/
|
*/
|
||||||
Int32 GetOrder() const;
|
Int32 GetOrder() const;
|
||||||
@ -355,22 +372,22 @@ class IniDocument
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef CSimpleIniA Source;
|
typedef CSimpleIniA Document;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
typedef Source::TNamesDepend Container;
|
typedef Document::TNamesDepend Container;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy constructor. (disabled)
|
* Copy constructor. (disabled)
|
||||||
*/
|
*/
|
||||||
IniDocument(const IniDocument & o);
|
IniDocument(const IniDocument & o);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator. (disabled)
|
* Copy assignment operator. (disabled)
|
||||||
*/
|
*/
|
||||||
IniDocument & operator = (const IniDocument & o);
|
IniDocument & operator = (const IniDocument & o);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the document reference.
|
* Validate the document reference.
|
||||||
*/
|
*/
|
||||||
bool Validate() const
|
bool Validate() const
|
||||||
@ -384,36 +401,36 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------
|
||||||
IniRef m_Doc; /* The main ini document instance. */
|
IniDocumentRef m_Doc; /* The main ini document instance. */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
IniDocument();
|
IniDocument();
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Explicit constructor.
|
* Explicit constructor.
|
||||||
*/
|
*/
|
||||||
IniDocument(bool utf8, bool multikey, bool multiline);
|
IniDocument(bool utf8, bool multikey, bool multiline);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~IniDocument();
|
~IniDocument();
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Used by the script engine to compare two instances of this type.
|
* Used by the script engine to compare two instances of this type.
|
||||||
*/
|
*/
|
||||||
Int32 Cmp(const IniDocument & o);
|
Int32 Cmp(const IniDocument & o) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Used by the script engine to convert an instance of this type to a string.
|
* Used by the script engine to convert an instance of this type to a string.
|
||||||
*/
|
*/
|
||||||
CSStr ToString() const;
|
CSStr ToString() const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether this instance references a valid ini document.
|
* See whether this instance references a valid ini document.
|
||||||
*/
|
*/
|
||||||
bool IsValid() const
|
bool IsValid() const
|
||||||
@ -421,7 +438,7 @@ public:
|
|||||||
return m_Doc;
|
return m_Doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether any data has been loaded into this document.
|
* See whether any data has been loaded into this document.
|
||||||
*/
|
*/
|
||||||
bool IsEmpty() const
|
bool IsEmpty() const
|
||||||
@ -429,7 +446,15 @@ public:
|
|||||||
return m_Doc->IsEmpty();
|
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.
|
* Deallocate all memory stored by this document.
|
||||||
*/
|
*/
|
||||||
void Reset() const
|
void Reset() const
|
||||||
@ -437,7 +462,7 @@ public:
|
|||||||
m_Doc->Reset();
|
m_Doc->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether the ini data is treated as unicode.
|
* See whether the ini data is treated as unicode.
|
||||||
*/
|
*/
|
||||||
bool GetUnicode() const
|
bool GetUnicode() const
|
||||||
@ -445,7 +470,7 @@ public:
|
|||||||
return m_Doc->IsUnicode();
|
return m_Doc->IsUnicode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether the ini data should be treated as unicode.
|
* Set whether the ini data should be treated as unicode.
|
||||||
*/
|
*/
|
||||||
void SetUnicode(bool toggle)
|
void SetUnicode(bool toggle)
|
||||||
@ -453,7 +478,7 @@ public:
|
|||||||
m_Doc->SetUnicode(toggle);
|
m_Doc->SetUnicode(toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether multiple identical keys be permitted in the file.
|
* See whether multiple identical keys be permitted in the file.
|
||||||
*/
|
*/
|
||||||
bool GetMultiKey() const
|
bool GetMultiKey() const
|
||||||
@ -461,7 +486,7 @@ public:
|
|||||||
return m_Doc->IsMultiKey();
|
return m_Doc->IsMultiKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether multiple identical keys be permitted in the file.
|
* Set whether multiple identical keys be permitted in the file.
|
||||||
*/
|
*/
|
||||||
void SetMultiKey(bool toggle)
|
void SetMultiKey(bool toggle)
|
||||||
@ -469,7 +494,7 @@ public:
|
|||||||
m_Doc->SetMultiKey(toggle);
|
m_Doc->SetMultiKey(toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether data values are permitted to span multiple lines in the file.
|
* See whether data values are permitted to span multiple lines in the file.
|
||||||
*/
|
*/
|
||||||
bool GetMultiLine() const
|
bool GetMultiLine() const
|
||||||
@ -477,7 +502,7 @@ public:
|
|||||||
return m_Doc->IsMultiLine();
|
return m_Doc->IsMultiLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether data values are permitted to span multiple lines in the file.
|
* Set whether data values are permitted to span multiple lines in the file.
|
||||||
*/
|
*/
|
||||||
void SetMultiLine(bool toggle)
|
void SetMultiLine(bool toggle)
|
||||||
@ -485,7 +510,7 @@ public:
|
|||||||
m_Doc->SetMultiLine(toggle);
|
m_Doc->SetMultiLine(toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether spaces are added around the equals sign when writing key/value pairs out.
|
* See whether spaces are added around the equals sign when writing key/value pairs out.
|
||||||
*/
|
*/
|
||||||
bool GetSpaces() const
|
bool GetSpaces() const
|
||||||
@ -493,7 +518,7 @@ public:
|
|||||||
return m_Doc->UsingSpaces();
|
return m_Doc->UsingSpaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether spaces are added around the equals sign when writing key/value pairs out.
|
* Set whether spaces are added around the equals sign when writing key/value pairs out.
|
||||||
*/
|
*/
|
||||||
void SetSpaces(bool toggle)
|
void SetSpaces(bool toggle)
|
||||||
@ -501,12 +526,12 @@ public:
|
|||||||
m_Doc->SetSpaces(toggle);
|
m_Doc->SetSpaces(toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Load an INI file from disk into memory.
|
* Load an INI file from disk into memory.
|
||||||
*/
|
*/
|
||||||
void LoadFile(CSStr filepath);
|
void LoadFile(CSStr filepath);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Load INI file data direct from a string.
|
* Load INI file data direct from a string.
|
||||||
*/
|
*/
|
||||||
void LoadData(CSStr source)
|
void LoadData(CSStr source)
|
||||||
@ -514,12 +539,12 @@ public:
|
|||||||
LoadData(source, -1);
|
LoadData(source, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Load INI file data direct from a string.
|
* Load INI file data direct from a string.
|
||||||
*/
|
*/
|
||||||
void LoadData(CSStr source, Int32 size);
|
void LoadData(CSStr source, Int32 size);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Save an INI file from memory to disk.
|
* Save an INI file from memory to disk.
|
||||||
*/
|
*/
|
||||||
void SaveFile(CSStr filepath)
|
void SaveFile(CSStr filepath)
|
||||||
@ -527,62 +552,62 @@ public:
|
|||||||
SaveFile(filepath, true);
|
SaveFile(filepath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Save an INI file from memory to disk.
|
* Save an INI file from memory to disk.
|
||||||
*/
|
*/
|
||||||
void SaveFile(CSStr filepath, bool signature);
|
void SaveFile(CSStr filepath, bool signature);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Save the INI data to a string.
|
* Save the INI data to a string.
|
||||||
*/
|
*/
|
||||||
Object SaveData(bool signature);
|
Object SaveData(bool signature);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve all section names.
|
* Retrieve all section names.
|
||||||
*/
|
*/
|
||||||
IniEntries GetAllSections() const;
|
IniEntries GetAllSections() const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve all unique key names in a section.
|
* Retrieve all unique key names in a section.
|
||||||
*/
|
*/
|
||||||
IniEntries GetAllKeys(CSStr section) const;
|
IniEntries GetAllKeys(CSStr section) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve all values for a specific key.
|
* Retrieve all values for a specific key.
|
||||||
*/
|
*/
|
||||||
IniEntries GetAllValues(CSStr section, CSStr key) const;
|
IniEntries GetAllValues(CSStr section, CSStr key) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Query the number of keys in a specific section.
|
* Query the number of keys in a specific section.
|
||||||
*/
|
*/
|
||||||
Int32 GetSectionSize(CSStr section) const;
|
Int32 GetSectionSize(CSStr section) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* See whether a certain key has multiple instances.
|
* See whether a certain key has multiple instances.
|
||||||
*/
|
*/
|
||||||
bool HasMultipleKeys(CSStr section, CSStr key) const;
|
bool HasMultipleKeys(CSStr section, CSStr key) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value for a specific key.
|
* Retrieve the value for a specific key.
|
||||||
*/
|
*/
|
||||||
CCStr GetValue(CSStr section, CSStr key, CSStr def) const;
|
CCStr GetValue(CSStr section, CSStr key, CSStr def) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a numeric value for a specific key.
|
* Retrieve a numeric value for a specific key.
|
||||||
*/
|
*/
|
||||||
SQInteger GetInteger(CSStr section, CSStr key, SQInteger def) const;
|
SQInteger GetInteger(CSStr section, CSStr key, SQInteger def) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a numeric value for a specific key.
|
* Retrieve a numeric value for a specific key.
|
||||||
*/
|
*/
|
||||||
SQFloat GetFloat(CSStr section, CSStr key, SQFloat def) const;
|
SQFloat GetFloat(CSStr section, CSStr key, SQFloat def) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a boolean value for a specific key.
|
* Retrieve a boolean value for a specific key.
|
||||||
*/
|
*/
|
||||||
bool GetBoolean(CSStr section, CSStr key, bool def) const;
|
bool GetBoolean(CSStr section, CSStr key, bool def) const;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a section or value.
|
* Add or update a section or value.
|
||||||
*/
|
*/
|
||||||
void SetValue(CSStr section, CSStr key, CSStr value)
|
void SetValue(CSStr section, CSStr key, CSStr value)
|
||||||
@ -590,7 +615,7 @@ public:
|
|||||||
SetValue(section, key, value, false, NULL);
|
SetValue(section, key, value, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a section or value.
|
* Add or update a section or value.
|
||||||
*/
|
*/
|
||||||
void SetValue(CSStr section, CSStr key, CSStr value, bool force)
|
void SetValue(CSStr section, CSStr key, CSStr value, bool force)
|
||||||
@ -598,12 +623,12 @@ public:
|
|||||||
SetValue(section, key, value, force, NULL);
|
SetValue(section, key, value, force, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a section or value.
|
* Add or update a section or value.
|
||||||
*/
|
*/
|
||||||
void SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment);
|
void SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a numeric value.
|
* Add or update a numeric value.
|
||||||
*/
|
*/
|
||||||
void SetInteger(CSStr section, CSStr key, SQInteger value)
|
void SetInteger(CSStr section, CSStr key, SQInteger value)
|
||||||
@ -611,7 +636,7 @@ public:
|
|||||||
SetInteger(section, key, value, false, false, NULL);
|
SetInteger(section, key, value, false, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a numeric value.
|
* Add or update a numeric value.
|
||||||
*/
|
*/
|
||||||
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
|
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
|
||||||
@ -619,7 +644,7 @@ public:
|
|||||||
SetInteger(section, key, value, hex, false, NULL);
|
SetInteger(section, key, value, hex, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a numeric value.
|
* Add or update a numeric value.
|
||||||
*/
|
*/
|
||||||
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
|
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
|
||||||
@ -627,12 +652,12 @@ public:
|
|||||||
SetInteger(section, key, value, hex, force, NULL);
|
SetInteger(section, key, value, hex, force, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a numeric value.
|
* Add or update a numeric value.
|
||||||
*/
|
*/
|
||||||
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment);
|
void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a double value.
|
* Add or update a double value.
|
||||||
*/
|
*/
|
||||||
void SetFloat(CSStr section, CSStr key, SQFloat value)
|
void SetFloat(CSStr section, CSStr key, SQFloat value)
|
||||||
@ -640,7 +665,7 @@ public:
|
|||||||
SetFloat(section, key, value, false, NULL);
|
SetFloat(section, key, value, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a double value.
|
* Add or update a double value.
|
||||||
*/
|
*/
|
||||||
void SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
|
void SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
|
||||||
@ -648,12 +673,12 @@ public:
|
|||||||
SetFloat(section, key, value, force, NULL);
|
SetFloat(section, key, value, force, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a double value.
|
* Add or update a double value.
|
||||||
*/
|
*/
|
||||||
void SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment);
|
void SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a double value.
|
* Add or update a double value.
|
||||||
*/
|
*/
|
||||||
void SetBoolean(CSStr section, CSStr key, bool value)
|
void SetBoolean(CSStr section, CSStr key, bool value)
|
||||||
@ -661,7 +686,7 @@ public:
|
|||||||
SetBoolean(section, key, value, false, NULL);
|
SetBoolean(section, key, value, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a double value.
|
* Add or update a double value.
|
||||||
*/
|
*/
|
||||||
void SetBoolean(CSStr section, CSStr key, bool value, bool force)
|
void SetBoolean(CSStr section, CSStr key, bool value, bool force)
|
||||||
@ -669,12 +694,12 @@ public:
|
|||||||
SetBoolean(section, key, value, force, NULL);
|
SetBoolean(section, key, value, force, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Add or update a boolean value.
|
* Add or update a boolean value.
|
||||||
*/
|
*/
|
||||||
void SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment);
|
void SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Delete an entire section, or a key from a section.
|
* Delete an entire section, or a key from a section.
|
||||||
*/
|
*/
|
||||||
bool DeleteValue(CSStr section)
|
bool DeleteValue(CSStr section)
|
||||||
@ -682,7 +707,7 @@ public:
|
|||||||
return DeleteValue(section, NULL, NULL, false);
|
return DeleteValue(section, NULL, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Delete an entire section, or a key from a section.
|
* Delete an entire section, or a key from a section.
|
||||||
*/
|
*/
|
||||||
bool DeleteValue(CSStr section, CSStr key)
|
bool DeleteValue(CSStr section, CSStr key)
|
||||||
@ -690,7 +715,7 @@ public:
|
|||||||
return DeleteValue(section, key, NULL, false);
|
return DeleteValue(section, key, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Delete an entire section, or a key from a section.
|
* Delete an entire section, or a key from a section.
|
||||||
*/
|
*/
|
||||||
bool DeleteValue(CSStr section, CSStr key, CSStr value)
|
bool DeleteValue(CSStr section, CSStr key, CSStr value)
|
||||||
@ -698,7 +723,7 @@ public:
|
|||||||
return DeleteValue(section, key, value, false);
|
return DeleteValue(section, key, value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Delete an entire section, or a key from a section.
|
* Delete an entire section, or a key from a section.
|
||||||
*/
|
*/
|
||||||
bool DeleteValue(CSStr section, CSStr key, CSStr value, bool empty);
|
bool DeleteValue(CSStr section, CSStr key, CSStr value, bool empty);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user