TrinityCore
MySQLPreparedStatement.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef MySQLPreparedStatement_h__
19#define MySQLPreparedStatement_h__
20
21#include "DatabaseEnvFwd.h"
22#include "Define.h"
23#include <string>
24#include <vector>
25
26class MySQLConnection;
28
29//- Class of which the instances are unique per MySQLConnection
30//- access to these class objects is only done when a prepared statement task
31//- is executed.
33{
34 friend class MySQLConnection;
36
37 public:
38 MySQLPreparedStatement(MySQLStmt* stmt, std::string queryString);
40
41 void BindParameters(PreparedStatementBase* stmt);
42
43 uint32 GetParameterCount() const { return m_paramCount; }
44
45 protected:
46 void SetParameter(uint8 index, std::nullptr_t);
47 void SetParameter(uint8 index, bool value);
48 template<typename T>
49 void SetParameter(uint8 index, T value);
50 void SetParameter(uint8 index, std::string const& value);
51 void SetParameter(uint8 index, std::vector<uint8> const& value);
52
53 MySQLStmt* GetSTMT() { return m_Mstmt; }
54 MySQLBind* GetBind() { return m_bind; }
56 void ClearParameters();
57 void AssertValidIndex(uint8 index);
58 std::string getQueryString() const;
59
60 private:
63 std::vector<bool> m_paramsSet;
65 std::string const m_queryString;
66
69};
70
71#endif // MySQLPreparedStatement_h__
uint8_t uint8
Definition: Define.h:144
#define TC_DATABASE_API
Definition: Define.h:111
uint32_t uint32
Definition: Define.h:142
PreparedStatementBase * m_stmt
MySQLPreparedStatement & operator=(MySQLPreparedStatement const &right)=delete
std::string const m_queryString
MySQLPreparedStatement(MySQLPreparedStatement const &right)=delete
std::vector< bool > m_paramsSet