本文整理汇总了C++中IResultRow类的典型用法代码示例。如果您正苦于以下问题:C++ IResultRow类的具体用法?C++ IResultRow怎么用?C++ IResultRow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IResultRow类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SQL_IsFieldNull
static cell_t SQL_IsFieldNull(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
IResultRow *row = rs->CurrentRow();
if (!row)
{
return pContext->ThrowNativeError("Current result set has no fetched rows");
}
if ((unsigned)params[2] >= rs->GetFieldCount())
{
return pContext->ThrowNativeError("Invalid field index %d", params[2]);
}
return row->IsNull(params[2]) ? 1 : 0;
}
示例2: SQL_ReadResult
static cell AMX_NATIVE_CALL SQL_ReadResult(AMX *amx, cell *params)
{
AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
if (!qInfo)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
return 0;
}
IResultSet *rs = qInfo->info.rs;
if (!rs || rs->IsDone())
{
MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
return 0;
}
IResultRow *row = rs->GetRow();
unsigned int col = static_cast<unsigned int>(params[2]);
if (col >= rs->FieldCount())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
return 0;
}
cell numparams = params[0] / sizeof(cell);
switch (numparams)
{
case 4:
{
const char *str = row->GetString(col);
if (!str)
str = "";
cell *len = MF_GetAmxAddr(amx, params[4]);
MF_SetAmxString(amx, params[3], str, (int)*len);
break;
}
case 3:
{
REAL num = row->GetFloat(col);
cell *addr = MF_GetAmxAddr(amx, params[3]);
*addr = amx_ftoc(num);
break;
}
case 2:
{
int num = row->GetInt(col);
return num;
break;
}
default:
{
MF_LogError(amx, AMX_ERR_NATIVE, "Bad number of arguments passed.");
break;
}
}
return 1;
}
示例3: SQL_IsNull
static cell AMX_NATIVE_CALL SQL_IsNull(AMX *amx, cell *params)
{
AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
if (!qInfo)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
return 0;
}
IResultSet *rs = qInfo->info.rs;
if (!rs || rs->IsDone())
{
MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
return 0;
}
unsigned int col = static_cast<unsigned int>(params[2]);
if (col >= rs->FieldCount())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
return 0;
}
IResultRow *rr = rs->GetRow();
return rr->IsNull(col) ? 1 : 0;
}
示例4: _InternalClear
void AtomicResult::CopyFrom(IResultSet *rs)
{
if (!m_IsFree)
{
_InternalClear();
}
m_IsFree = false;
m_FieldCount = rs->FieldCount();
m_RowCount = rs->RowCount();
m_CurRow = 1;
size_t newTotal = (m_RowCount * m_FieldCount) + m_FieldCount;
if (newTotal > m_AllocSize)
{
SourceHook::String **table = new SourceHook::String *[newTotal];
memset(table, 0, newTotal * sizeof(SourceHook::String *));
if (m_Table)
{
memcpy(table, m_Table, m_AllocSize * sizeof(SourceHook::String *));
delete [] m_Table;
}
m_Table = table;
m_AllocSize = newTotal;
}
for (unsigned int i=0; i<m_FieldCount; i++)
{
if (m_Table[i])
{
m_Table[i]->assign(rs->FieldNumToName(i));
} else {
m_Table[i] = new SourceHook::String(rs->FieldNumToName(i));
}
}
IResultRow *row;
unsigned int idx = m_FieldCount;
while (!rs->IsDone())
{
row = rs->GetRow();
for (unsigned int i=0; i<m_FieldCount; i++,idx++)
{
if (m_Table[idx])
{
m_Table[idx]->assign(row->GetString(i));
} else {
m_Table[idx] = new SourceHook::String(row->GetString(i));
}
}
rs->NextRow();
}
}
示例5: dbi_field
//native dbi_field(Result:_result, _fieldnum, {Float,_}:... );
static cell AMX_NATIVE_CALL dbi_field(AMX *amx, cell *params)
{
oldresult_s *oldrs = (oldresult_s *)GetHandle(params[1], Handle_OldResult);
if (!oldrs)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid DBI result handle %d", params[1]);
return 0;
}
IResultSet *rs = oldrs->info.rs;
if (rs->IsDone())
{
return 0;
}
IResultRow *rr = rs->GetRow();
unsigned int num = (unsigned int)params[2] - 1;
if (num >= rs->FieldCount())
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column %d", params[2]);
return 0;
}
cell stype = params[0] / sizeof(cell);
const char *data = rr->GetString(num);
if (!data)
data = "";
switch (stype)
{
case 2:
{
return atoi(data);
break;
}
case 3:
{
cell *destaddr = MF_GetAmxAddr(amx, params[3]);
REAL fdata = atof(data);
*destaddr = amx_ftoc(fdata);
return 1;
break;
}
case 4:
{
return MF_SetAmxString(amx, params[3], data, params[4]);
break;
}
}
/** never reach here */
return 0;
}
示例6: SelectIdCallback
void CookieManager::SelectIdCallback(Cookie *pCookie, IQuery *data)
{
IResultSet *results;
if (data == NULL || (results = data->GetResultSet()) == NULL)
{
return;
}
IResultRow *row = results->FetchRow();
if (row == NULL)
{
return;
}
row->GetInt(0, &pCookie->dbid);
}
示例7: SQL_FetchString
static cell_t SQL_FetchString(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
IResultRow *row = rs->CurrentRow();
if (!row)
{
return pContext->ThrowNativeError("Current result set has no fetched rows");
}
const char *str;
size_t length;
DBResult res = row->GetString(params[2], &str, &length);
if (res == DBVal_Error)
{
return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
} else if (res == DBVal_TypeMismatch) {
return pContext->ThrowNativeError("Could not fetch data in field %d as a string", params[2]);
}
pContext->StringToLocalUTF8(params[3], params[4], str, &length);
cell_t *addr;
pContext->LocalToPhysAddr(params[5], &addr);
*addr = (cell_t)res;
return (cell_t)length;
}
示例8: ClientConnectCallback
void CookieManager::ClientConnectCallback(int serial, IQuery *data)
{
int client;
/* Check validity of client */
if ((client = playerhelpers->GetClientFromSerial(serial)) == 0)
{
return;
}
statsPending[client] = false;
IResultSet *results;
/* Check validity of results */
if (data == NULL || (results = data->GetResultSet()) == NULL)
{
return;
}
CookieData *pData;
IResultRow *row;
unsigned int timestamp;
CookieAccess access;
while (results->MoreRows() && ((row = results->FetchRow()) != NULL))
{
const char *name = "";
row->GetString(0, &name, NULL);
const char *value = "";
row->GetString(1, &value, NULL);
pData = new CookieData(value);
pData->changed = false;
pData->timestamp = (row->GetInt(4, (int *)×tamp) == DBVal_Data) ? timestamp : 0;
Cookie *parent = FindCookie(name);
if (parent == NULL)
{
const char *desc = "";
row->GetString(2, &desc, NULL);
access = CookieAccess_Public;
row->GetInt(3, (int *)&access);
parent = CreateCookie(name, desc, access);
}
pData->parent = parent;
parent->data[client] = pData;
clientData[client].append(pData);
}
statsLoaded[client] = true;
cookieDataLoadedForward->PushCell(client);
cookieDataLoadedForward->Execute(NULL);
}
示例9: SQL_FetchInt
static cell_t SQL_FetchInt(IPluginContext *pContext, const cell_t *params)
{
IQuery *query;
HandleError err;
if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
}
IResultSet *rs = query->GetResultSet();
if (!rs)
{
return pContext->ThrowNativeError("No current result set");
}
IResultRow *row = rs->CurrentRow();
if (!row)
{
return pContext->ThrowNativeError("Current result set has no fetched rows");
}
int iv;
DBResult res = row->GetInt(params[2], &iv);
if (res == DBVal_Error)
{
return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
} else if (res == DBVal_TypeMismatch) {
return pContext->ThrowNativeError("Could not fetch data in field %d as an integer", params[2]);
}
cell_t *addr;
pContext->LocalToPhysAddr(params[3], &addr);
*addr = (cell_t)res;
return iv;
}
示例10: dbi_result
//native dbi_result(Result:_result, _field[], {Float,_}:... );
static cell AMX_NATIVE_CALL dbi_result(AMX *amx, cell *params)
{
oldresult_s *oldrs = (oldresult_s *)GetHandle(params[1], Handle_OldResult);
if (!oldrs)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid DBI result handle %d", params[1]);
return 0;
}
IResultSet *rs = oldrs->info.rs;
if (rs->IsDone())
{
return 0;
}
IResultRow *rr = rs->GetRow();
unsigned int num;
bool found = false;
unsigned int fields = rs->FieldCount();
int len;
char *field = MF_GetAmxString(amx, params[2], 0, &len);
for (unsigned int i=0; i<fields; i++)
{
if (strcmp(field, rs->FieldNumToName(i)) == 0)
{
num = i;
found = true;
break;
}
}
if (!found)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown column \"%s\"", field);
return 0;
}
cell stype = params[0] / sizeof(cell);
const char *data = rr->GetString(num);
if (!data)
data = "";
switch (stype)
{
case 2:
{
return atoi(data);
break;
}
case 3:
{
cell *destaddr = MF_GetAmxAddr(amx, params[3]);
REAL fdata = atof(data);
*destaddr = amx_ftoc(fdata);
return 1;
break;
}
case 4:
{
return MF_SetAmxString(amx, params[3], data, params[4]);
break;
}
}
/** never reach here */
return 0;
}
示例11: ClientConnectCallback
void CookieManager::ClientConnectCallback(int serial, IQuery *data)
{
int client;
IResultSet *results;
/* Check validity of client */
if ((client = playerhelpers->GetClientFromSerial(serial)) == 0)
{
return;
}
/* Check validity of results */
if (data == NULL || (results = data->GetResultSet()) == NULL)
{
return;
}
IResultRow *row;
do
{
if ((row = results->FetchRow()) == NULL)
{
break;
}
const char *name;
row->GetString(0, &name, NULL);
const char *value;
row->GetString(1, &value, NULL);
CookieData *pData = new CookieData(value);
pData->changed = false;
Cookie *parent = FindCookie(name);
if (parent == NULL)
{
const char *desc;
row->GetString(2, &desc, NULL);
CookieAccess access = CookieAccess_Public;
row->GetInt(3, (int *)&access);
parent = CreateCookie(name, desc, access);
cookieTrie.insert(name, parent);
cookieList.push_back(parent);
}
pData->parent = parent;
parent->data[client] = pData;
clientData[client].push_back(pData);
} while (results->MoreRows());
statsLoaded[client] = true;
cookieDataLoadedForward->PushCell(client);
cookieDataLoadedForward->Execute(NULL);
}