TrinityCore
Loading...
Searching...
No Matches
SQLQueryHolderBase Class Reference

#include <QueryHolder.h>

Public Member Functions

 SQLQueryHolderBase ()=default
 
virtual ~SQLQueryHolderBase ()
 
void SetSize (size_t size)
 
PreparedQueryResult GetPreparedResult (size_t index) const
 
void SetPreparedResult (size_t index, PreparedResultSet *result)
 

Protected Member Functions

bool SetPreparedQueryImpl (size_t index, PreparedStatementBase *stmt)
 

Private Attributes

std::vector< std::pair< PreparedStatementBase *, PreparedQueryResult > > m_queries
 

Friends

class SQLQueryHolderTask
 

Detailed Description

Definition at line 24 of file QueryHolder.h.

Constructor & Destructor Documentation

◆ SQLQueryHolderBase()

SQLQueryHolderBase::SQLQueryHolderBase ( )
default

◆ ~SQLQueryHolderBase()

SQLQueryHolderBase::~SQLQueryHolderBase ( )
virtual

if the result was never used, free the resources results used already (getresult called) are expected to be deleted

Definition at line 59 of file QueryHolder.cpp.

60{
61 for (std::pair<PreparedStatementBase*, PreparedQueryResult>& query : m_queries)
62 {
65 delete query.first;
66 }
67}
std::vector< std::pair< PreparedStatementBase *, PreparedQueryResult > > m_queries
Definition: QueryHolder.h:28

Member Function Documentation

◆ GetPreparedResult()

PreparedQueryResult SQLQueryHolderBase::GetPreparedResult ( size_t  index) const

Definition at line 37 of file QueryHolder.cpp.

38{
39 // Don't call to this function if the index is of a prepared statement
40 ASSERT(index < m_queries.size(), "Query holder result index out of range, tried to access index " SZFMTD " but there are only " SZFMTD " results",
41 index, m_queries.size());
42
43 return m_queries[index].second;
44}
#define SZFMTD
Definition: Define.h:133
#define ASSERT
Definition: Errors.h:68
+ Here is the caller graph for this function:

◆ SetPreparedQueryImpl()

bool SQLQueryHolderBase::SetPreparedQueryImpl ( size_t  index,
PreparedStatementBase stmt 
)
protected

Definition at line 25 of file QueryHolder.cpp.

26{
27 if (m_queries.size() <= index)
28 {
29 TC_LOG_ERROR("sql.sql", "Query index ({}) out of range (size: {}) for prepared statement", uint32(index), (uint32)m_queries.size());
30 return false;
31 }
32
33 m_queries[index].first = stmt;
34 return true;
35}
uint32_t uint32
Definition: Define.h:143
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:165
+ Here is the caller graph for this function:

◆ SetPreparedResult()

void SQLQueryHolderBase::SetPreparedResult ( size_t  index,
PreparedResultSet result 
)

store the result in the holder

Definition at line 46 of file QueryHolder.cpp.

47{
48 if (result && !result->GetRowCount())
49 {
50 delete result;
51 result = nullptr;
52 }
53
55 if (index < m_queries.size())
56 m_queries[index].second = PreparedQueryResult(result);
57}
std::shared_ptr< PreparedResultSet > PreparedQueryResult
uint64 GetRowCount() const
Definition: QueryResult.h:60
+ Here is the call graph for this function:

◆ SetSize()

void SQLQueryHolderBase::SetSize ( size_t  size)

to optimize push_back, reserve the number of queries about to be executed

Definition at line 69 of file QueryHolder.cpp.

70{
72 m_queries.resize(size);
73}
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ SQLQueryHolderTask

friend class SQLQueryHolderTask
friend

Definition at line 26 of file QueryHolder.h.

Member Data Documentation

◆ m_queries

std::vector<std::pair<PreparedStatementBase*, PreparedQueryResult> > SQLQueryHolderBase::m_queries
private

Definition at line 28 of file QueryHolder.h.


The documentation for this class was generated from the following files: