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

#include <PreparedStatement.h>

Public Member Functions

 PreparedStatement (uint32 index)
 
 ~PreparedStatement ()
 
void setBool (const uint8 index, const bool value)
 
void setUInt8 (const uint8 index, const uint8 value)
 
void setUInt16 (const uint8 index, const uint16 value)
 
void setUInt32 (const uint8 index, const uint32 value)
 
void setUInt64 (const uint8 index, const uint64 value)
 
void setInt8 (const uint8 index, const int8 value)
 
void setInt16 (const uint8 index, const int16 value)
 
void setInt32 (const uint8 index, const int32 value)
 
void setInt64 (const uint8 index, const int64 value)
 
void setFloat (const uint8 index, const float value)
 
void setDouble (const uint8 index, const double value)
 
void setString (const uint8 index, const std::string &value)
 
void setBinary (const uint8 index, const std::vector< uint8 > &value)
 
void setNull (const uint8 index)
 

Protected Member Functions

void BindParameters ()
 
 PreparedStatement (PreparedStatement const &right)=delete
 
PreparedStatementoperator= (PreparedStatement const &right)=delete
 

Protected Attributes

MySQLPreparedStatementm_stmt
 
uint32 m_index
 
std::vector
< PreparedStatementData
statement_data
 

Friends

class PreparedStatementTask
 
class MySQLPreparedStatement
 
class MySQLConnection
 

Constructor & Destructor Documentation

PreparedStatement::PreparedStatement ( uint32  index)
explicit
22  :
23 m_stmt(NULL),
24 m_index(index) { }
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_index
Definition: PreparedStatement.h:104
MySQLPreparedStatement * m_stmt
Definition: PreparedStatement.h:103
PreparedStatement::~PreparedStatement ( )
26 { }
PreparedStatement::PreparedStatement ( PreparedStatement const right)
protecteddelete

Member Function Documentation

void PreparedStatement::BindParameters ( )
protected
29 {
30  ASSERT (m_stmt);
31 
32  uint8 i = 0;
33  for (; i < statement_data.size(); i++)
34  {
35  switch (statement_data[i].type)
36  {
37  case TYPE_BOOL:
38  m_stmt->setBool(i, statement_data[i].data.boolean);
39  break;
40  case TYPE_UI8:
41  m_stmt->setUInt8(i, statement_data[i].data.ui8);
42  break;
43  case TYPE_UI16:
44  m_stmt->setUInt16(i, statement_data[i].data.ui16);
45  break;
46  case TYPE_UI32:
47  m_stmt->setUInt32(i, statement_data[i].data.ui32);
48  break;
49  case TYPE_I8:
50  m_stmt->setInt8(i, statement_data[i].data.i8);
51  break;
52  case TYPE_I16:
53  m_stmt->setInt16(i, statement_data[i].data.i16);
54  break;
55  case TYPE_I32:
56  m_stmt->setInt32(i, statement_data[i].data.i32);
57  break;
58  case TYPE_UI64:
59  m_stmt->setUInt64(i, statement_data[i].data.ui64);
60  break;
61  case TYPE_I64:
62  m_stmt->setInt64(i, statement_data[i].data.i64);
63  break;
64  case TYPE_FLOAT:
65  m_stmt->setFloat(i, statement_data[i].data.f);
66  break;
67  case TYPE_DOUBLE:
68  m_stmt->setDouble(i, statement_data[i].data.d);
69  break;
70  case TYPE_STRING:
71  m_stmt->setBinary(i, statement_data[i].binary, true);
72  break;
73  case TYPE_BINARY:
74  m_stmt->setBinary(i, statement_data[i].binary, false);
75  break;
76  case TYPE_NULL:
77  m_stmt->setNull(i);
78  break;
79  }
80  }
81  #ifdef _DEBUG
82  if (i < m_stmt->m_paramCount)
83  TC_LOG_WARN("sql.sql", "[WARNING]: BindParameters() for statement %u did not bind all allocated parameters", m_index);
84  #endif
85 }
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:339
Definition: PreparedStatement.h:55
void setNull(const uint8 index)
Definition: PreparedStatement.cpp:377
void setInt16(const uint8 index, const int16 value)
Definition: PreparedStatement.cpp:315
Definition: PreparedStatement.h:51
void setInt64(const uint8 index, const int64 value)
Definition: PreparedStatement.cpp:331
void setInt8(const uint8 index, const int8 value)
Definition: PreparedStatement.cpp:307
Definition: PreparedStatement.h:54
Definition: PreparedStatement.h:47
Definition: PreparedStatement.h:56
Definition: PreparedStatement.h:58
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:299
Definition: PreparedStatement.h:60
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:291
Definition: PreparedStatement.h:52
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:275
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
Definition: PreparedStatement.h:49
Definition: PreparedStatement.h:53
void setBinary(const uint8 index, const std::vector< uint8 > &value, bool isString)
Definition: PreparedStatement.cpp:355
Definition: PreparedStatement.h:48
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:283
void setDouble(const uint8 index, const double value)
Definition: PreparedStatement.cpp:347
uint32 m_index
Definition: PreparedStatement.h:104
Definition: PreparedStatement.h:50
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:323
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
Definition: PreparedStatement.h:57
Definition: PreparedStatement.h:59
MySQLPreparedStatement * m_stmt
Definition: PreparedStatement.h:103
void setBool(const uint8 index, const bool value)
Definition: PreparedStatement.cpp:270

+ Here is the call graph for this function:

PreparedStatement& PreparedStatement::operator= ( PreparedStatement const right)
protecteddelete
void PreparedStatement::setBinary ( const uint8  index,
const std::vector< uint8 > &  value 
)
198 {
199  if (index >= statement_data.size())
200  statement_data.resize(index + 1);
201 
202  statement_data[index].binary = value;
203  statement_data[index].type = TYPE_BINARY;
204 }
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: PreparedStatement.h:59

+ Here is the caller graph for this function:

void PreparedStatement::setBool ( const uint8  index,
const bool  value 
)
89 {
90  if (index >= statement_data.size())
91  statement_data.resize(index+1);
92 
93  statement_data[index].data.boolean = value;
94  statement_data[index].type = TYPE_BOOL;
95 }
Definition: PreparedStatement.h:47
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setDouble ( const uint8  index,
const double  value 
)
179 {
180  if (index >= statement_data.size())
181  statement_data.resize(index+1);
182 
183  statement_data[index].data.d = value;
184  statement_data[index].type = TYPE_DOUBLE;
185 }
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: PreparedStatement.h:57
void PreparedStatement::setFloat ( const uint8  index,
const float  value 
)
170 {
171  if (index >= statement_data.size())
172  statement_data.resize(index+1);
173 
174  statement_data[index].data.f = value;
175  statement_data[index].type = TYPE_FLOAT;
176 }
Definition: PreparedStatement.h:56
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setInt16 ( const uint8  index,
const int16  value 
)
143 {
144  if (index >= statement_data.size())
145  statement_data.resize(index+1);
146 
147  statement_data[index].data.i16 = value;
148  statement_data[index].type = TYPE_I16;
149 }
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
Definition: PreparedStatement.h:53
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setInt32 ( const uint8  index,
const int32  value 
)
152 {
153  if (index >= statement_data.size())
154  statement_data.resize(index+1);
155 
156  statement_data[index].data.i32 = value;
157  statement_data[index].type = TYPE_I32;
158 }
Definition: PreparedStatement.h:54
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setInt64 ( const uint8  index,
const int64  value 
)
161 {
162  if (index >= statement_data.size())
163  statement_data.resize(index+1);
164 
165  statement_data[index].data.i64 = value;
166  statement_data[index].type = TYPE_I64;
167 }
Definition: PreparedStatement.h:55
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setInt8 ( const uint8  index,
const int8  value 
)
134 {
135  if (index >= statement_data.size())
136  statement_data.resize(index+1);
137 
138  statement_data[index].data.i8 = value;
139  statement_data[index].type = TYPE_I8;
140 }
Definition: PreparedStatement.h:52
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setNull ( const uint8  index)
207 {
208  if (index >= statement_data.size())
209  statement_data.resize(index+1);
210 
211  statement_data[index].type = TYPE_NULL;
212 }
Definition: PreparedStatement.h:60
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105

+ Here is the caller graph for this function:

void PreparedStatement::setString ( const uint8  index,
const std::string &  value 
)
188 {
189  if (index >= statement_data.size())
190  statement_data.resize(index+1);
191 
192  statement_data[index].binary.resize(value.length() + 1);
193  memcpy(statement_data[index].binary.data(), value.c_str(), value.length() + 1);
194  statement_data[index].type = TYPE_STRING;
195 }
Definition: PreparedStatement.h:58
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522
void PreparedStatement::setUInt16 ( const uint8  index,
const uint16  value 
)
107 {
108  if (index >= statement_data.size())
109  statement_data.resize(index+1);
110 
111  statement_data[index].data.ui16 = value;
112  statement_data[index].type = TYPE_UI16;
113 }
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
Definition: PreparedStatement.h:49
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

void PreparedStatement::setUInt32 ( const uint8  index,
const uint32  value 
)
116 {
117  if (index >= statement_data.size())
118  statement_data.resize(index+1);
119 
120  statement_data[index].data.ui32 = value;
121  statement_data[index].type = TYPE_UI32;
122 }
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
Definition: PreparedStatement.h:50
const FieldDescriptor value
Definition: descriptor.h:1522
void PreparedStatement::setUInt64 ( const uint8  index,
const uint64  value 
)
125 {
126  if (index >= statement_data.size())
127  statement_data.resize(index+1);
128 
129  statement_data[index].data.ui64 = value;
130  statement_data[index].type = TYPE_UI64;
131 }
Definition: PreparedStatement.h:51
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
const FieldDescriptor value
Definition: descriptor.h:1522
void PreparedStatement::setUInt8 ( const uint8  index,
const uint8  value 
)
98 {
99  if (index >= statement_data.size())
100  statement_data.resize(index+1);
101 
102  statement_data[index].data.ui8 = value;
103  statement_data[index].type = TYPE_UI8;
104 }
std::vector< PreparedStatementData > statement_data
Definition: PreparedStatement.h:105
Definition: PreparedStatement.h:48
const FieldDescriptor value
Definition: descriptor.h:1522

Friends And Related Function Documentation

friend class MySQLConnection
friend
friend class MySQLPreparedStatement
friend
friend class PreparedStatementTask
friend

Member Data Documentation

uint32 PreparedStatement::m_index
protected
MySQLPreparedStatement* PreparedStatement::m_stmt
protected
std::vector<PreparedStatementData> PreparedStatement::statement_data
protected

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