2016-03-10 04:57:13 +01:00
|
|
|
#ifndef _SQMMDB_COMMON_HPP_
|
|
|
|
#define _SQMMDB_COMMON_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-03 20:29:15 +02:00
|
|
|
#include "Base/Utility.hpp"
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <maxminddb.h>
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* SOFTWARE INFORMATION
|
|
|
|
*/
|
|
|
|
#define SQMMDB_NAME "Squirrel MaxmindDB Module"
|
|
|
|
#define SQMMDB_AUTHOR "Sandu Liviu Catalin (S.L.C)"
|
2018-01-28 22:13:41 +01:00
|
|
|
#define SQMMDB_COPYRIGHT "Copyright (C) 2018 Sandu Liviu Catalin"
|
2016-03-10 04:57:13 +01:00
|
|
|
#define SQMMDB_HOST_NAME "SqModMMDBHost"
|
|
|
|
#define SQMMDB_VERSION 001
|
|
|
|
#define SQMMDB_VERSION_STR "0.0.1"
|
|
|
|
#define SQMMDB_VERSION_MAJOR 0
|
|
|
|
#define SQMMDB_VERSION_MINOR 0
|
|
|
|
#define SQMMDB_VERSION_PATCH 1
|
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Handle validation.
|
|
|
|
*/
|
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
#define SQMOD_VALIDATE(x) (x).Validate(__FILE__, __LINE__)
|
|
|
|
#define SQMOD_GET_VALID(x) (x).GetValid(__FILE__, __LINE__)
|
|
|
|
#define SQMOD_GET_VALID_ELEM(x) (x).GetValidElem(__FILE__, __LINE__)
|
2016-11-15 05:34:10 +01:00
|
|
|
#define SQMOD_GET_VALID_DATA(x) (x).GetValidData(__FILE__, __LINE__)
|
2016-11-14 13:06:30 +01:00
|
|
|
#else
|
|
|
|
#define SQMOD_VALIDATE(x) (x).Validate()
|
|
|
|
#define SQMOD_GET_VALID(x) (x).GetValid()
|
|
|
|
#define SQMOD_GET_VALID_ELEM(x) (x).GetValidElem()
|
2016-11-15 05:34:10 +01:00
|
|
|
#define SQMOD_GET_VALID_DATA(x) (x).GetValidData()
|
2016-11-14 13:06:30 +01:00
|
|
|
#endif // _DEBUG
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Forward declarations.
|
|
|
|
*/
|
|
|
|
class Database;
|
2016-11-14 13:06:30 +01:00
|
|
|
class Metadata;
|
|
|
|
class Description;
|
2016-03-10 04:57:13 +01:00
|
|
|
class SockAddr;
|
2016-11-14 13:06:30 +01:00
|
|
|
class EntryData;
|
2016-03-10 04:57:13 +01:00
|
|
|
class EntryDataList;
|
|
|
|
class LookupResult;
|
2016-11-14 13:44:01 +01:00
|
|
|
class SearchNode;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-11-14 13:44:01 +01:00
|
|
|
* Forward handle declarations.
|
2016-03-10 04:57:13 +01:00
|
|
|
*/
|
2016-11-14 13:06:30 +01:00
|
|
|
struct DbHnd;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Common typedefs.
|
|
|
|
*/
|
|
|
|
typedef SharedPtr< DbHnd > DbRef;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Used to retrieve the string representation of the specified type identifier.
|
|
|
|
*/
|
|
|
|
CSStr AsTypeStr(Uint32 id);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value from the specified entry data as a boolean.
|
|
|
|
*/
|
|
|
|
bool GetEntryAsBool(const MMDB_entry_data_s & ed);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value from the specified entry data as a native integer.
|
|
|
|
*/
|
|
|
|
SQInteger GetEntryAsInteger(const MMDB_entry_data_s & ed);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value from the specified entry data as a floating point.
|
|
|
|
*/
|
|
|
|
SQFloat GetEntryAsFloat(const MMDB_entry_data_s & ed);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value from the specified entry data as a long integer.
|
|
|
|
*/
|
|
|
|
Object GetEntryAsLong(const MMDB_entry_data_s & ed);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value from the specified entry data as a string.
|
|
|
|
*/
|
|
|
|
Object GetEntryAsString(const MMDB_entry_data_s & ed);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
2016-11-14 13:06:30 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value from the specified entry data as a stream of bytes.
|
|
|
|
*/
|
|
|
|
Object GetEntryAsBytes(const MMDB_entry_data_s & ed);
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _SQMMDB_COMMON_HPP_
|