TrinityCore
QueryResult.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 QUERYRESULT_H
19#define QUERYRESULT_H
20
21#include "Define.h"
22#include "DatabaseEnvFwd.h"
23#include <vector>
24
26{
27 public:
28 ResultSet(MySQLResult* result, MySQLField* fields, uint64 rowCount, uint32 fieldCount);
29 ~ResultSet();
30
31 bool NextRow();
32 uint64 GetRowCount() const { return _rowCount; }
33 uint32 GetFieldCount() const { return _fieldCount; }
34
35 Field* Fetch() const { return _currentRow; }
36 Field const& operator[](std::size_t index) const;
37
38 protected:
39 std::vector<QueryResultFieldMetadata> _fieldMetadata;
43
44 private:
45 void CleanUp();
48
49 ResultSet(ResultSet const& right) = delete;
50 ResultSet& operator=(ResultSet const& right) = delete;
51};
52
54{
55 public:
56 PreparedResultSet(MySQLStmt* stmt, MySQLResult* result, uint64 rowCount, uint32 fieldCount);
58
59 bool NextRow();
60 uint64 GetRowCount() const { return m_rowCount; }
61 uint32 GetFieldCount() const { return m_fieldCount; }
62
63 Field* Fetch() const;
64 Field const& operator[](std::size_t index) const;
65
66 protected:
67 std::vector<QueryResultFieldMetadata> m_fieldMetadata;
68 std::vector<Field> m_rows;
72
73 private:
77
78 void CleanUp();
79 bool _NextRow();
80
81 PreparedResultSet(PreparedResultSet const& right) = delete;
83};
84
85#endif
#define TC_DATABASE_API
Definition: Define.h:111
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
Class used to access individual fields of database query result.
Definition: Field.h:90
std::vector< QueryResultFieldMetadata > m_fieldMetadata
Definition: QueryResult.h:67
MySQLStmt * m_stmt
Definition: QueryResult.h:75
uint64 m_rowPosition
Definition: QueryResult.h:70
PreparedResultSet(PreparedResultSet const &right)=delete
uint32 GetFieldCount() const
Definition: QueryResult.h:61
MySQLBind * m_rBind
Definition: QueryResult.h:74
std::vector< Field > m_rows
Definition: QueryResult.h:68
uint64 GetRowCount() const
Definition: QueryResult.h:60
PreparedResultSet & operator=(PreparedResultSet const &right)=delete
MySQLResult * m_metadataResult
Field metadata, returned by mysql_stmt_result_metadata.
Definition: QueryResult.h:76
uint32 _fieldCount
Definition: QueryResult.h:42
Field * _currentRow
Definition: QueryResult.h:41
uint64 _rowCount
Definition: QueryResult.h:40
uint64 GetRowCount() const
Definition: QueryResult.h:32
Field * Fetch() const
Definition: QueryResult.h:35
MySQLField * _fields
Definition: QueryResult.h:47
std::vector< QueryResultFieldMetadata > _fieldMetadata
Definition: QueryResult.h:39
uint32 GetFieldCount() const
Definition: QueryResult.h:33
MySQLResult * _result
Definition: QueryResult.h:46
ResultSet(ResultSet const &right)=delete
ResultSet & operator=(ResultSet const &right)=delete