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 QueryResultFieldMetadata const& GetFieldMetadata(std::size_t index) const;
39
40 protected:
41 std::vector<QueryResultFieldMetadata> _fieldMetadata;
45
46 private:
47 void CleanUp();
50
51 ResultSet(ResultSet const& right) = delete;
52 ResultSet& operator=(ResultSet const& right) = delete;
53};
54
56{
57 public:
58 PreparedResultSet(MySQLStmt* stmt, MySQLResult* result, uint64 rowCount, uint32 fieldCount);
60
61 bool NextRow();
62 uint64 GetRowCount() const { return m_rowCount; }
63 uint32 GetFieldCount() const { return m_fieldCount; }
64
65 Field* Fetch() const;
66 Field const& operator[](std::size_t index) const;
67
68 QueryResultFieldMetadata const& GetFieldMetadata(std::size_t index) const;
69
70 protected:
71 std::vector<QueryResultFieldMetadata> m_fieldMetadata;
72 std::vector<Field> m_rows;
76
77 private:
81
82 void CleanUp();
83 bool _NextRow();
84
85 PreparedResultSet(PreparedResultSet const& right) = delete;
87};
88
89#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:92
std::vector< QueryResultFieldMetadata > m_fieldMetadata
Definition: QueryResult.h:71
MySQLStmt * m_stmt
Definition: QueryResult.h:79
uint64 m_rowPosition
Definition: QueryResult.h:74
PreparedResultSet(PreparedResultSet const &right)=delete
uint32 GetFieldCount() const
Definition: QueryResult.h:63
MySQLBind * m_rBind
Definition: QueryResult.h:78
std::vector< Field > m_rows
Definition: QueryResult.h:72
uint64 GetRowCount() const
Definition: QueryResult.h:62
PreparedResultSet & operator=(PreparedResultSet const &right)=delete
MySQLResult * m_metadataResult
Field metadata, returned by mysql_stmt_result_metadata.
Definition: QueryResult.h:80
uint32 _fieldCount
Definition: QueryResult.h:44
Field * _currentRow
Definition: QueryResult.h:43
uint64 _rowCount
Definition: QueryResult.h:42
uint64 GetRowCount() const
Definition: QueryResult.h:32
Field * Fetch() const
Definition: QueryResult.h:35
MySQLField * _fields
Definition: QueryResult.h:49
std::vector< QueryResultFieldMetadata > _fieldMetadata
Definition: QueryResult.h:41
uint32 GetFieldCount() const
Definition: QueryResult.h:33
MySQLResult * _result
Definition: QueryResult.h:48
ResultSet(ResultSet const &right)=delete
ResultSet & operator=(ResultSet const &right)=delete