MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / ClearResultSet

Method ClearResultSet

Engine/source/sqlite/SQLiteObject.cpp:392–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392void SQLiteObject::ClearResultSet(S32 index)
393{
394 if (index <= 0)
395 return;
396
397 sqlite_resultset* resultSet;
398 S32 iResultSet;
399
400 // Get the result set specified by index
401 resultSet = GetResultSet(index);
402 iResultSet = GetResultSetIndex(index);
403 if ((!resultSet) || (!resultSet->bValid))
404 {
405 Con::warnf("Warning SQLiteObject::ClearResultSet(%i) failed to retrieve specified result set. Result set was NOT cleared.", index);
406 return;
407 }
408 // Now we have the specific result set to be cleared.
409 // What we need to do now is iterate through each "Column" in each "Row"
410 // and free the strings, then delete the entries.
411 VectorPtr<sqlite_resultrow*>::iterator iRow;
412 VectorPtr<char*>::iterator iColumnName;
413 VectorPtr<char*>::iterator iColumnValue;
414
415 for (iRow = resultSet->vRows.begin(); iRow != resultSet->vRows.end(); iRow++)
416 {
417 // Iterate through rows
418 // for each row iterate through all the column values and names
419 for (iColumnName = (*iRow)->vColumnNames.begin(); iColumnName != (*iRow)->vColumnNames.end(); iColumnName++)
420 {
421 // Iterate through column names. Free the memory.
422 delete[](*iColumnName);
423 }
424 for (iColumnValue = (*iRow)->vColumnValues.begin(); iColumnValue != (*iRow)->vColumnValues.end(); iColumnValue++)
425 {
426 // Iterate through column values. Free the memory.
427 delete[](*iColumnValue);
428 }
429 // free memory used by the row
430 delete (*iRow);
431 }
432 // empty the resultset
433 resultSet->vRows.clear();
434 resultSet->bValid = false;
435 delete resultSet;
436 m_vResultSets.erase_fast(iResultSet);
437}
438
439sqlite_resultset* SQLiteObject::GetResultSet(S32 iResultSet)
440{

Callers 1

SQLiteObject.cppFile · 0.80

Calls 5

erase_fastMethod · 0.80
warnfFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected