TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SQLQueryHolderTask Class Reference

#include <QueryHolder.h>

Public Member Functions

 SQLQueryHolderTask (SQLQueryHolder *holder)
 
 ~SQLQueryHolderTask ()
 
bool Execute () override
 
QueryResultHolderFuture GetFuture ()
 
- Public Member Functions inherited from SQLOperation
 SQLOperation ()
 
virtual ~SQLOperation ()
 
virtual int call ()
 
virtual void SetConnection (MySQLConnection *con)
 

Private Attributes

SQLQueryHolderm_holder
 
QueryResultHolderPromise m_result
 
bool m_executed
 

Additional Inherited Members

- Public Attributes inherited from SQLOperation
MySQLConnection * m_conn
 

Constructor & Destructor Documentation

SQLQueryHolderTask::SQLQueryHolderTask ( SQLQueryHolder holder)
inline
58  : m_holder(holder), m_executed(false) { }
bool m_executed
Definition: QueryHolder.h:54
SQLQueryHolder * m_holder
Definition: QueryHolder.h:52
SQLQueryHolderTask::~SQLQueryHolderTask ( )
147 {
148  if (!m_executed)
149  delete m_holder;
150 }
bool m_executed
Definition: QueryHolder.h:54
SQLQueryHolder * m_holder
Definition: QueryHolder.h:52

Member Function Documentation

bool SQLQueryHolderTask::Execute ( )
overridevirtual

we can do this, we are friends

execute all queries in the holder and pass the results

Implements SQLOperation.

153 {
154  m_executed = true;
155 
156  if (!m_holder)
157  return false;
158 
160  std::vector<SQLQueryHolder::SQLResultPair> &queries = m_holder->m_queries;
161 
162  for (size_t i = 0; i < queries.size(); i++)
163  {
165  if (SQLElementData* data = &queries[i].first)
166  {
167  switch (data->type)
168  {
169  case SQL_ELEMENT_RAW:
170  {
171  char const* sql = data->element.query;
172  if (sql)
173  m_holder->SetResult(i, m_conn->Query(sql));
174  break;
175  }
177  {
178  PreparedStatement* stmt = data->element.stmt;
179  if (stmt)
180  m_holder->SetPreparedResult(i, m_conn->Query(stmt));
181  break;
182  }
183  }
184  }
185  }
186 
187  m_result.set_value(m_holder);
188  return true;
189 }
bool m_executed
Definition: QueryHolder.h:54
Definition: SQLOperation.h:36
QueryResultHolderPromise m_result
Definition: QueryHolder.h:53
std::vector< SQLResultPair > m_queries
Definition: QueryHolder.h:28
MySQLConnection * m_conn
Definition: SQLOperation.h:70
Definition: PreparedStatement.h:74
void SetResult(size_t index, ResultSet *result)
Definition: QueryHolder.cpp:93
void SetPreparedResult(size_t index, PreparedResultSet *result)
Definition: QueryHolder.cpp:106
SQLQueryHolder * m_holder
Definition: QueryHolder.h:52
Definition: SQLOperation.h:41
Definition: SQLOperation.h:37

+ Here is the call graph for this function:

QueryResultHolderFuture SQLQueryHolderTask::GetFuture ( )
inline
63 { return m_result.get_future(); }
QueryResultHolderPromise m_result
Definition: QueryHolder.h:53

+ Here is the caller graph for this function:

Member Data Documentation

bool SQLQueryHolderTask::m_executed
private
SQLQueryHolder* SQLQueryHolderTask::m_holder
private
QueryResultHolderPromise SQLQueryHolderTask::m_result
private

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