1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-08-03 14:41:48 +02:00

Improve type conversion in the MySQL module.

Implement field wrappers and field retrieval by name.
Various other fixes and adjustments.
This commit is contained in:
Sandu Liviu Catalin
2016-07-19 21:42:41 +03:00
parent cac237c3cb
commit 7dc20fcc0c
9 changed files with 1054 additions and 194 deletions

View File

@@ -186,7 +186,7 @@ void ResHnd::ValidateField(Uint32 idx, CCStr file, Int32 line) const
// Is the handle valid?
if (mPtr == nullptr)
{
STHROWF("Invalid MySQL result-set reference =>[%s:%d]", file, line);
STHROWF("Invalid MySQL result-set =>[%s:%d]", file, line);
}
else if (idx >= mFieldCount)
{
@@ -199,7 +199,7 @@ void ResHnd::ValidateField(Uint32 idx) const
// Is the handle valid?
if (mPtr == nullptr)
{
STHROWF("Invalid MySQL result-set reference");
STHROWF("Invalid MySQL result-set");
}
else if (idx >= mFieldCount)
{
@@ -208,6 +208,25 @@ void ResHnd::ValidateField(Uint32 idx) const
}
#endif // _DEBUG
// ------------------------------------------------------------------------------------------------
Uint32 ResHnd::GetFieldIndex(CSStr name)
{
// Validate the handle
if (!mPtr)
{
STHROWF("Invalid MySQL result-set");
}
// Attempt to find the specified field
const IndexMap::iterator itr = mIndexes.find(name);
// Was there a field with the specified name?
if (itr != mIndexes.end())
{
return itr->second;
}
// No such field exists (expecting the invoker to validate the result)
return std::numeric_limits< Uint32 >::max();
}
// ------------------------------------------------------------------------------------------------
void ResHnd::Create(const ConnRef & conn)
{

View File

@@ -192,6 +192,19 @@ public:
void ValidateField(Uint32 idx) const;
#endif // _DEBUG
/* --------------------------------------------------------------------------------------------
* Check whether a specific field index is within range.
*/
bool CheckFieldIndex(Uint32 idx) const
{
return (idx < mFieldCount);
}
/* --------------------------------------------------------------------------------------------
* Retrieve the field index associated with the specified name.
*/
Uint32 GetFieldIndex(CSStr name);
/* --------------------------------------------------------------------------------------------
* Create the result-set from a Connection.
*/