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

#include <Transaction.h>

Public Member Functions

 Transaction ()
 
 ~Transaction ()
 
void Append (PreparedStatement *statement)
 
void Append (const char *sql)
 
template<typename Format , typename... Args>
void PAppend (Format &&sql, Args &&...args)
 
size_t GetSize () const
 

Protected Member Functions

void Cleanup ()
 

Protected Attributes

std::list< SQLElementDatam_queries
 

Private Attributes

bool _cleanedUp
 

Friends

class TransactionTask
 
class MySQLConnection
 
template<typename T >
class DatabaseWorkerPool
 

Detailed Description

Transactions, high level class.

Constructor & Destructor Documentation

Transaction::Transaction ( )
inline
37 : _cleanedUp(false) { }
bool _cleanedUp
Definition: Transaction.h:55
Transaction::~Transaction ( )
inline
38 { Cleanup(); }
void Cleanup()
Definition: Transaction.cpp:42

Member Function Documentation

void Transaction::Append ( PreparedStatement statement)
35 {
36  SQLElementData data;
38  data.element.stmt = stmt;
39  m_queries.push_back(data);
40 }
PreparedStatement * stmt
Definition: SQLOperation.h:29
std::list< SQLElementData > m_queries
Definition: Transaction.h:52
SQLElementDataType type
Definition: SQLOperation.h:44
Definition: SQLOperation.h:41
SQLElementUnion element
Definition: SQLOperation.h:43
Definition: SQLOperation.h:37
void Transaction::Append ( const char *  sql)
26 {
27  SQLElementData data;
28  data.type = SQL_ELEMENT_RAW;
29  data.element.query = strdup(sql);
30  m_queries.push_back(data);
31 }
Definition: SQLOperation.h:36
const char * query
Definition: SQLOperation.h:30
std::list< SQLElementData > m_queries
Definition: Transaction.h:52
SQLElementDataType type
Definition: SQLOperation.h:44
Definition: SQLOperation.h:41
SQLElementUnion element
Definition: SQLOperation.h:43
void Transaction::Cleanup ( )
protected
43 {
44  // This might be called by explicit calls to Cleanup or by the auto-destructor
45  if (_cleanedUp)
46  return;
47 
48  while (!m_queries.empty())
49  {
50  SQLElementData const &data = m_queries.front();
51  switch (data.type)
52  {
54  delete data.element.stmt;
55  break;
56  case SQL_ELEMENT_RAW:
57  free((void*)(data.element.query));
58  break;
59  }
60 
61  m_queries.pop_front();
62  }
63 
64  _cleanedUp = true;
65 }
Definition: SQLOperation.h:36
PreparedStatement * stmt
Definition: SQLOperation.h:29
bool _cleanedUp
Definition: Transaction.h:55
const char * query
Definition: SQLOperation.h:30
std::list< SQLElementData > m_queries
Definition: Transaction.h:52
SQLElementDataType type
Definition: SQLOperation.h:44
Definition: SQLOperation.h:41
SQLElementUnion element
Definition: SQLOperation.h:43
Definition: SQLOperation.h:37
size_t Transaction::GetSize ( ) const
inline
48 { return m_queries.size(); }
std::list< SQLElementData > m_queries
Definition: Transaction.h:52
template<typename Format , typename... Args>
void Transaction::PAppend ( Format &&  sql,
Args &&...  args 
)
inline
44  {
45  Append(Trinity::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
46  }
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
void Append(PreparedStatement *statement)
Definition: Transaction.cpp:34

+ Here is the call graph for this function:

Friends And Related Function Documentation

template<typename T >
friend class DatabaseWorkerPool
friend
friend class MySQLConnection
friend
friend class TransactionTask
friend

Member Data Documentation

bool Transaction::_cleanedUp
private
std::list<SQLElementData> Transaction::m_queries
protected

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