2016-06-03 20:33:21 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "ResultSet.hpp"
|
|
|
|
|
2016-06-29 17:31:10 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2016-06-03 20:33:21 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger ResultSet::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
static const SQChar name[] = _SC("SqMySQLResultSet");
|
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
void ResultSet::Validate(CCStr file, Int32 line) const
|
2016-06-03 20:33:21 +02:00
|
|
|
{
|
2016-06-28 00:15:31 +02:00
|
|
|
if (!m_Handle)
|
2016-06-03 20:33:21 +02:00
|
|
|
{
|
2016-06-28 00:15:31 +02:00
|
|
|
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
2016-06-03 20:33:21 +02:00
|
|
|
}
|
2016-06-28 00:15:31 +02:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
void ResultSet::Validate() const
|
|
|
|
{
|
|
|
|
if (!m_Handle)
|
2016-06-03 20:33:21 +02:00
|
|
|
{
|
2016-06-28 00:15:31 +02:00
|
|
|
SqThrowF("Invalid MySQL result-set reference");
|
2016-06-03 20:33:21 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-28 00:15:31 +02:00
|
|
|
#endif // _DEBUG
|
2016-06-03 20:33:21 +02:00
|
|
|
|
2016-06-03 21:25:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-28 00:15:31 +02:00
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
void ResultSet::ValidateCreated(CCStr file, Int32 line) const
|
|
|
|
{
|
|
|
|
if (!m_Handle)
|
|
|
|
{
|
|
|
|
SqThrowF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
|
|
|
|
}
|
|
|
|
else if (m_Handle->mPtr == nullptr)
|
|
|
|
{
|
|
|
|
SqThrowF("Invalid MySQL result-set =>[%s:%d]", file, line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void ResultSet::ValidateCreated() const
|
2016-06-03 21:25:06 +02:00
|
|
|
{
|
2016-06-28 00:15:31 +02:00
|
|
|
if (!m_Handle)
|
|
|
|
{
|
|
|
|
SqThrowF("Invalid MySQL result-set reference");
|
|
|
|
}
|
|
|
|
else if (m_Handle->mPtr == nullptr)
|
2016-06-03 21:25:06 +02:00
|
|
|
{
|
2016-06-28 00:15:31 +02:00
|
|
|
SqThrowF("Invalid MySQL result-set");
|
2016-06-03 21:25:06 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-28 00:15:31 +02:00
|
|
|
#endif // _DEBUG
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
const ResRef & ResultSet::GetValid(CCStr file, Int32 line) const
|
|
|
|
{
|
|
|
|
Validate(file, line);
|
|
|
|
return m_Handle;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
const ResRef & ResultSet::GetValid() const
|
|
|
|
{
|
|
|
|
Validate();
|
|
|
|
return m_Handle;
|
|
|
|
}
|
|
|
|
#endif // _DEBUG
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
const ResRef & ResultSet::GetCreated(CCStr file, Int32 line) const
|
|
|
|
{
|
|
|
|
ValidateCreated(file, line);
|
|
|
|
return m_Handle;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
const ResRef & ResultSet::GetCreated() const
|
|
|
|
{
|
|
|
|
ValidateCreated();
|
|
|
|
return m_Handle;
|
|
|
|
}
|
|
|
|
#endif // _DEBUG
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
|
|
|
void ResultSet::ValidateField(Int32 idx, CCStr file, Int32 line) const
|
|
|
|
{
|
|
|
|
ValidateCreated(file, line);
|
|
|
|
m_Handle->ValidateField(idx, file, line);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void ResultSet::ValidateField(Int32 idx) const
|
|
|
|
{
|
|
|
|
ValidateCreated();
|
|
|
|
m_Handle->ValidateField(idx);
|
|
|
|
}
|
|
|
|
#endif // _DEBUG
|
2016-06-03 21:25:06 +02:00
|
|
|
|
2016-06-28 00:15:31 +02:00
|
|
|
// ================================================================================================
|
|
|
|
void Register_ResultSet(Table & sqlns)
|
|
|
|
{
|
|
|
|
sqlns.Bind(_SC("ResultSet")
|
|
|
|
, Class< ResultSet >(sqlns.GetVM(), _SC("SqMySQLResultSet"))
|
|
|
|
// Constructors
|
|
|
|
.Ctor()
|
|
|
|
.Ctor< const ResultSet & >()
|
|
|
|
// Core Meta-methods
|
|
|
|
.Func(_SC("_cmp"), &ResultSet::Cmp)
|
|
|
|
.SquirrelFunc(_SC("_typename"), &ResultSet::Typename)
|
|
|
|
.Func(_SC("_tostring"), &ResultSet::ToString)
|
|
|
|
// Properties
|
|
|
|
.Prop(_SC("IsValid"), &ResultSet::IsValid)
|
2016-06-29 17:31:10 +02:00
|
|
|
.Prop(_SC("RowIndex"), &ResultSet::RowIndex)
|
|
|
|
.Prop(_SC("RowCount"), &ResultSet::RowCount)
|
2016-06-28 00:15:31 +02:00
|
|
|
// Member Methods
|
2016-06-29 17:31:10 +02:00
|
|
|
.Func(_SC("Next"), &ResultSet::Next)
|
2016-07-19 20:42:41 +02:00
|
|
|
.Func(_SC("Step"), &ResultSet::Next)
|
2016-06-29 17:31:10 +02:00
|
|
|
.Func(_SC("SetRowIndex"), &ResultSet::SetRowIndex)
|
|
|
|
.Func(_SC("SetLongRowIndex"), &ResultSet::SetLongRowIndex)
|
2016-07-19 20:42:41 +02:00
|
|
|
.Func(_SC("Get"), &ResultSet::GetField)
|
|
|
|
.Func(_SC("GetField"), &ResultSet::GetField)
|
|
|
|
.Func(_SC("GetBool"), &ResultSet::GetBoolean)
|
|
|
|
.Func(_SC("GetBoolean"), &ResultSet::GetBoolean)
|
|
|
|
.Func(_SC("GetChar"), &ResultSet::GetChar)
|
|
|
|
.Func(_SC("GetInteger"), &ResultSet::GetInteger)
|
|
|
|
.Func(_SC("GetFloat"), &ResultSet::GetFloat)
|
2016-06-28 00:15:31 +02:00
|
|
|
.Func(_SC("GetInt8"), &ResultSet::GetInt8)
|
|
|
|
.Func(_SC("GetUint8"), &ResultSet::GetUint8)
|
|
|
|
.Func(_SC("GetInt16"), &ResultSet::GetInt16)
|
|
|
|
.Func(_SC("GetUint16"), &ResultSet::GetUint16)
|
|
|
|
.Func(_SC("GetInt32"), &ResultSet::GetInt32)
|
|
|
|
.Func(_SC("GetUint32"), &ResultSet::GetUint32)
|
|
|
|
.Func(_SC("GetInt64"), &ResultSet::GetInt64)
|
|
|
|
.Func(_SC("GetUint64"), &ResultSet::GetUint64)
|
|
|
|
.Func(_SC("GetFloat32"), &ResultSet::GetFloat32)
|
|
|
|
.Func(_SC("GetFloat64"), &ResultSet::GetFloat64)
|
2016-06-30 14:52:20 +02:00
|
|
|
.Func(_SC("GetString"), &ResultSet::GetString)
|
2016-07-19 20:42:41 +02:00
|
|
|
.Func(_SC("GetBuffer"), &ResultSet::GetBuffer)
|
|
|
|
.Func(_SC("GetBlob"), &ResultSet::GetBlob)
|
2016-06-28 00:15:31 +02:00
|
|
|
);
|
|
|
|
}
|
2016-06-03 20:33:21 +02:00
|
|
|
|
|
|
|
} // Namespace:: SqMod
|