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

Initial implementation of the MaxmindDB module.

This commit is contained in:
Sandu Liviu Catalin
2016-11-14 14:06:30 +02:00
parent 2ef75d0dce
commit 3107513350
23 changed files with 2203 additions and 776 deletions

@ -2,7 +2,7 @@
#define _SQMMDB_LOOKUPRESULT_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
#include "Handle/Database.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
@ -29,21 +29,36 @@ protected:
typedef const Type& ConstRef; // Constant reference to the managed type.
/* --------------------------------------------------------------------------------------------
* Validate the database pointer and throw an error if invalid.
* Validate the managed database handle and throw an error if invalid.
*/
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
void Validate(CCStr file, Int32 line) const;
#else
void Validate() const;
#endif // _DEBUG
private:
/* --------------------------------------------------------------------------------------------
* Validate the managed database handle and throw an error if invalid.
*/
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
const DbRef & GetValid(CCStr file, Int32 line) const;
#else
const DbRef & GetValid() const;
#endif // _DEBUG
private:
// ---------------------------------------------------------------------------------------------
DbRef m_Db; /* The database from which this result comes from. */
Type m_Result; /* The managed result structure. */
DbRef m_Handle; // The database from which this result comes from.
Type m_Result; // The managed result structure.
/* --------------------------------------------------------------------------------------------
* Construct and take ownership of a certain result.
*/
LookupResult(const DbRef & db, Reference result)
: m_Db(db), m_Result(result)
: m_Handle(db), m_Result(result)
{
/* ... */
}
@ -99,11 +114,6 @@ public:
return m_Result;
}
/* --------------------------------------------------------------------------------------------
* Used by the script engine to compare two instances of this type.
*/
Int32 Cmp(const LookupResult & o) const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to convert an instance of this type to a string.
*/
@ -122,7 +132,7 @@ public:
*/
bool IsValid() const
{
return m_Db && m_Result.found_entry;
return m_Handle && m_Result.found_entry;
}
/* --------------------------------------------------------------------------------------------
@ -131,7 +141,7 @@ public:
bool FoundEntry() const
{
// Validate the database handle
Validate();
SQMOD_VALIDATE(*this);
// Return the requested information
return m_Result.found_entry;
}
@ -142,21 +152,20 @@ public:
SQInteger GetNetMask() const
{
// Validate the database handle
Validate();
SQMOD_VALIDATE(*this);
// Return the requested information
return static_cast< SQInteger >(m_Result.netmask);
}
/* --------------------------------------------------------------------------------------------
* Lookup data in the associated result using an array as the path.
* Retrieve the entire entry data list.
*/
EntryDataList GetValueA(CSStr path, Array & arr) const;
Object GetEntryDataList();
/* --------------------------------------------------------------------------------------------
* Lookup data in the associated result using a table as the path.
* Lookup data in the associated result using the specified path.
*/
EntryDataList GetValueT(CSStr path, Table & tbl) const;
static SQInteger GetValue(HSQUIRRELVM vm);
};
} // Namespace:: SqMod