| 390 | } |
| 391 | |
| 392 | void 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 | |
| 439 | sqlite_resultset* SQLiteObject::GetResultSet(S32 iResultSet) |
| 440 | { |
no test coverage detected