2016-02-27 10:57:10 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Entries.hpp"
|
|
|
|
#include "Module.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2016-02-28 15:16:08 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger Entries::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
static SQChar name[] = _SC("SqIniEntries");
|
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-02-27 10:57:10 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Int32 Entries::Cmp(const Entries & o) const
|
|
|
|
{
|
|
|
|
if (m_Elem == o.m_Elem)
|
|
|
|
return 0;
|
|
|
|
else if (this > &o)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
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 within the specified distance
|
|
|
|
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 within the specified distance
|
|
|
|
while ((--n >= 0) && m_Elem != m_List.begin()) --m_Elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CSStr Entries::GetItem() const
|
|
|
|
{
|
2016-02-28 15:16:08 +01:00
|
|
|
// is the current element valid?
|
2016-02-27 10:57:10 +01:00
|
|
|
if (m_List.empty() || m_Elem == m_List.end())
|
2016-02-28 15:16:08 +01:00
|
|
|
SqThrowF("Invalid INI entry [item]");
|
|
|
|
// Return the requested information
|
|
|
|
return m_Elem->pItem;
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CSStr Entries::GetComment() const
|
|
|
|
{
|
2016-02-28 15:16:08 +01:00
|
|
|
// is the current element valid?
|
2016-02-27 10:57:10 +01:00
|
|
|
if (m_List.empty() || m_Elem == m_List.end())
|
2016-02-28 15:16:08 +01:00
|
|
|
SqThrowF("Invalid INI entry [comment]");
|
|
|
|
// Return the requested information
|
|
|
|
return m_Elem->pComment;
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Int32 Entries::GetOrder() const
|
|
|
|
{
|
2016-02-28 15:16:08 +01:00
|
|
|
// is the current element valid?
|
2016-02-27 10:57:10 +01:00
|
|
|
if (m_List.empty() || m_Elem == m_List.end())
|
2016-02-28 15:16:08 +01:00
|
|
|
SqThrowF("Invalid INI entry [order]");
|
|
|
|
// Return the requested information
|
|
|
|
return m_Elem->nOrder;
|
2016-02-27 10:57:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|