1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Updated the MaxmindDB module to include the location for C++ exceptions in source code for debug builds.

This commit is contained in:
Sandu Liviu Catalin 2016-03-23 00:27:48 +02:00
parent 3a06fe6048
commit 543f3539fb
5 changed files with 32 additions and 32 deletions

View File

@ -395,7 +395,7 @@
<Unit filename="../modules/mmdb/Module.cpp" />
<Unit filename="../modules/mmdb/Module.hpp" />
<Unit filename="../modules/mmdb/SockAddr.cpp" />
<Unit filename="../modules/mmdb/SockAddr.hpp" />
<Unit filename="../modules/mmdb/Sockaddr.hpp" />
<Unit filename="../shared/SqMod.cpp" />
<Extensions>
<code_completion />

View File

@ -23,7 +23,7 @@ void Database::Validate() const
{
// Is the document handle valid?
if (!m_Db)
SqThrowF("Invalid Maxmind database reference");
STHROWF("Invalid Maxmind database reference");
}
// ------------------------------------------------------------------------------------------------
@ -51,14 +51,14 @@ void Database::Open(CSStr filepath, Uint32 flags)
m_Db = DbRef(true); // Create a database handle
// Check if the database handle could be allocated one more time
if (!m_Db)
SqThrowF("Unable to create a Maxmind database reference");
STHROWF("Unable to create a Maxmind database reference");
// Are there any other references?
else if (m_Db.Count() > 1)
// To load new values now, would mean to cause undefined behavior in existing references
SqThrowF("Loading is disabled while database is referenced");
STHROWF("Loading is disabled while database is referenced");
// Validate the specified file path
else if (!filepath || strlen(filepath) <= 0)
SqThrowF("Invalid database file path");
STHROWF("Invalid database file path");
// Let's attempt to open the specified database
const Int32 status = MMDB_open(filepath, flags, m_Db.m_Ptr);
// Validate the result of the operation
@ -67,7 +67,7 @@ void Database::Open(CSStr filepath, Uint32 flags)
// Release the database reference
m_Db.Drop();
// Now it's safe to throw the error
SqThrowF("Unable to open the specified database [%s]", MMDB_strerror(status));
STHROWF("Unable to open the specified database [%s]", MMDB_strerror(status));
}
}
@ -78,17 +78,17 @@ LookupResult Database::LookupString(CSStr addr)
Validate();
// Validate the specified string
if (!addr || strlen(addr) <= 0)
SqThrowF("Invalid address string");
STHROWF("Invalid address string");
// Dummy variables to obtain the status codes
int gai_error, mmdb_error;
// Attempt to perform the actual lookup
MMDB_lookup_result_s result = MMDB_lookup_string(m_Db, addr, &gai_error, &mmdb_error);
// Validate the result of the getaddrinfo() function call
if (gai_error != 0)
SqThrowF("Unable to resolve address (%s) because [%s]", addr, gai_strerror(gai_error));
STHROWF("Unable to resolve address (%s) because [%s]", addr, gai_strerror(gai_error));
// Validate the lookup status code
else if (mmdb_error != MMDB_SUCCESS)
SqThrowF("Unable to lookup address (%s) because [%s]", addr, MMDB_strerror(mmdb_error));
STHROWF("Unable to lookup address (%s) because [%s]", addr, MMDB_strerror(mmdb_error));
// Now it's safe to return the lookup result
return LookupResult(m_Db, result);
}
@ -100,14 +100,14 @@ LookupResult Database::LookupSockAddr(SockAddr & addr)
Validate();
// Validate the specified socket address
if (!addr.IsValid())
SqThrowF("Invalid address instance");
STHROWF("Invalid address instance");
// Dummy variable to obtain the status codes
int mmdb_error;
// Attempt to perform the actual lookup
MMDB_lookup_result_s result = MMDB_lookup_sockaddr(m_Db, addr.GetHandle()->ai_addr, &mmdb_error);
// Validate the lookup status code
if (mmdb_error != MMDB_SUCCESS)
SqThrowF("Unable to lookup address (%s) because [%s]",
STHROWF("Unable to lookup address (%s) because [%s]",
addr.GetAddress(), MMDB_strerror(mmdb_error));
// Now it's safe to return the lookup result
return LookupResult(m_Db, result);

View File

@ -25,10 +25,10 @@ void EntryDataList::Validate() const
{
// Is the document handle valid?
if (!m_Db)
SqThrowF("Invalid Maxmind database reference");
STHROWF("Invalid Maxmind database reference");
// Do we have a valid list?
else if (!m_List)
SqThrowF("Invalid entry data list");
STHROWF("Invalid entry data list");
}
// ------------------------------------------------------------------------------------------------
@ -36,13 +36,13 @@ void EntryDataList::ValidateElem() const
{
// Is the document handle valid?
if (!m_Db)
SqThrowF("Invalid Maxmind database reference");
STHROWF("Invalid Maxmind database reference");
// Do we have a valid list?
else if (!m_List)
SqThrowF("Invalid entry data list");
STHROWF("Invalid entry data list");
// Do we have a valid element?
else if (!m_Elem)
SqThrowF("Invalid entry data element");
STHROWF("Invalid entry data element");
}
// ------------------------------------------------------------------------------------------------
@ -50,16 +50,16 @@ void EntryDataList::ValidateData() const
{
// Is the document handle valid?
if (!m_Db)
SqThrowF("Invalid Maxmind database reference");
STHROWF("Invalid Maxmind database reference");
// Do we have a valid list?
else if (!m_List)
SqThrowF("Invalid entry data list");
STHROWF("Invalid entry data list");
// Do we have a valid element?
else if (!m_Elem)
SqThrowF("Invalid entry data element");
STHROWF("Invalid entry data element");
// Do we have some valid data?
else if (!m_Elem->entry_data.has_data)
SqThrowF("Entry data element has no data");
STHROWF("Entry data element has no data");
}
// ------------------------------------------------------------------------------------------------
@ -181,7 +181,7 @@ CSStr EntryDataList::GetString() const
case MMDB_DATA_TYPE_FLOAT:
return FmtStr("%f", m_Elem->entry_data.float_value);
default:
SqThrowF("Unsupported conversion from (%s) to (string)", AsTypeStr(m_Elem->entry_data.type));
STHROWF("Unsupported conversion from (%s) to (string)", AsTypeStr(m_Elem->entry_data.type));
}
// Shouldn't really reach this point
return _SC("");
@ -213,7 +213,7 @@ SQInteger EntryDataList::GetInteger() const
case MMDB_DATA_TYPE_FLOAT:
return llround(m_Elem->entry_data.float_value);
default:
SqThrowF("Unsupported conversion from (%s) to (int32)", AsTypeStr(m_Elem->entry_data.type));
STHROWF("Unsupported conversion from (%s) to (int32)", AsTypeStr(m_Elem->entry_data.type));
#else
case MMDB_DATA_TYPE_UTF8_STRING:
return strtol(m_Elem->entry_data.utf8_string, NULL, 10);
@ -232,7 +232,7 @@ SQInteger EntryDataList::GetInteger() const
case MMDB_DATA_TYPE_FLOAT:
return lround(m_Elem->entry_data.float_value);
default:
SqThrowF("Unsupported conversion from (%s) to (int64)", AsTypeStr(m_Elem->entry_data.type));
STHROWF("Unsupported conversion from (%s) to (int64)", AsTypeStr(m_Elem->entry_data.type));
#endif // _SQ64
}
// Shouldn't really reach this point
@ -268,7 +268,7 @@ SQFloat EntryDataList::GetFloat() const
case MMDB_DATA_TYPE_FLOAT:
return static_cast< SQFloat >(m_Elem->entry_data.float_value);
default:
SqThrowF("Unsupported conversion from (%s) to (float)", AsTypeStr(m_Elem->entry_data.type));
STHROWF("Unsupported conversion from (%s) to (float)", AsTypeStr(m_Elem->entry_data.type));
}
// Shouldn't really reach this point
return 0.0;
@ -315,7 +315,7 @@ Object EntryDataList::GetLong() const
}
break;
default:
SqThrowF("Unsupported conversion from (%s) to (uint64)", AsTypeStr(m_Elem->entry_data.type));
STHROWF("Unsupported conversion from (%s) to (uint64)", AsTypeStr(m_Elem->entry_data.type));
}
// Obtain the initial stack size
const StackGuard sg(_SqVM);
@ -350,7 +350,7 @@ bool EntryDataList::GetBool() const
case MMDB_DATA_TYPE_FLOAT:
return EpsGt(m_Elem->entry_data.float_value, 0.0f);
default:
SqThrowF("Unsupported conversion from (%s) to (boolean)", AsTypeStr(m_Elem->entry_data.type));
STHROWF("Unsupported conversion from (%s) to (boolean)", AsTypeStr(m_Elem->entry_data.type));
}
// Shouldn't really reach this point
return false;
@ -363,12 +363,12 @@ void EntryDataList::DumpTo(CSStr filepath, Int32 indent) const
Validate();
// Validate the specified file path
if (!filepath || strlen(filepath) <= 0)
SqThrowF("Invalid file path");
STHROWF("Invalid file path");
// Attempt to open the specified file
FILE * fp = fopen(filepath, "w");
// Validate the file handle
if (!fp)
SqThrowF("Unable to open file %s", filepath);
STHROWF("Unable to open file %s", filepath);
// Attempt to dump the entry data list
Int32 status = MMDB_dump_entry_data_list(fp, m_List, indent);
// Close the file handle
@ -376,7 +376,7 @@ void EntryDataList::DumpTo(CSStr filepath, Int32 indent) const
// Validate the result of the operation
if (status != MMDB_SUCCESS)
// Now it's safe to throw the error
SqThrowF("Unable to dump the list [%s]", MMDB_strerror(status));
STHROWF("Unable to dump the list [%s]", MMDB_strerror(status));
}
} // Namespace:: SqMod

View File

@ -18,7 +18,7 @@ void LookupResult::Validate() const
{
// Is the document handle valid?
if (!m_Db)
SqThrowF("Invalid Maxmind database reference");
STHROWF("Invalid Maxmind database reference");
}
// ------------------------------------------------------------------------------------------------

View File

@ -18,7 +18,7 @@ void SockAddr::Validate() const
{
// Is the document handle valid?
if (!m_Handle)
SqThrowF("Invalid sockaddr structure handle");
STHROWF("Invalid sockaddr structure handle");
}
// ------------------------------------------------------------------------------------------------
@ -40,7 +40,7 @@ SockAddr::SockAddr(CSStr addr)
if (m_Handle)
freeaddrinfo(m_Handle);
// Now it's safe to throw the error
SqThrowF("Unable to query the specified address for information [%s]", gai_strerror(status));
STHROWF("Unable to query the specified address for information [%s]", gai_strerror(status));
}
// Save the specified string address
m_Addres.assign(addr ? addr : _SC(""));