AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SQLQueryHolderBase Class Reference

#include "QueryHolder.h"

Inheritance diagram for SQLQueryHolderBase:
SQLQueryHolder< T > AccountInfoQueryHolderPerRealm LoginQueryHolder PetLoadQueryHolder

Public Member Functions

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

Protected Member Functions

bool SetPreparedQueryImpl (std::size_t index, PreparedStatementBase *stmt)
 

Private Attributes

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

Friends

class SQLQueryHolderTask
 

Detailed Description

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

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:39

References m_queries.

Member Function Documentation

◆ GetPreparedResult()

PreparedQueryResult SQLQueryHolderBase::GetPreparedResult ( std::size_t  index) const
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 {} but there are only {} results",
41 index, m_queries.size());
42
43 return m_queries[index].second;
44}
#define ASSERT
Definition: Errors.h:68

References ASSERT, and m_queries.

Referenced by WorldSession::HandlePlayerLoginFromDB(), WorldSession::InitializeSessionCallback(), Player::LoadFromDB(), and Pet::LoadPetFromDB().

◆ SetPreparedQueryImpl()

bool SQLQueryHolderBase::SetPreparedQueryImpl ( std::size_t  index,
PreparedStatementBase stmt 
)
protected
26{
27 if (m_queries.size() <= index)
28 {
29 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}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
std::uint32_t uint32
Definition: Define.h:107

References LOG_ERROR, and m_queries.

Referenced by SQLQueryHolder< T >::SetPreparedQuery().

◆ SetPreparedResult()

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

store the result in the holder

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
Definition: DatabaseEnvFwd.h:45
uint64 GetRowCount() const
Definition: QueryResult.h:105

References PreparedResultSet::GetRowCount(), and m_queries.

◆ SetSize()

void SQLQueryHolderBase::SetSize ( std::size_t  size)

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

70{
72 m_queries.resize(size);
73}

References m_queries.

Referenced by LoginQueryHolder::Initialize(), and PetLoadQueryHolder::PetLoadQueryHolder().

Friends And Related Function Documentation

◆ SQLQueryHolderTask

friend class SQLQueryHolderTask
friend

Member Data Documentation

◆ m_queries

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