Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
QueryResult.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef QUERYRESULT_H
7#define QUERYRESULT_H
8
9#include "AutoPtr.h"
10
11#include "Field.h"
12
13#ifdef _WIN32
14#include <winsock2.h>
15#endif
16#include <mysql.h>
17
19{
20public:
21 ResultSet(MYSQL_RES* result, MYSQL_FIELD* fields, uint64 rowCount, uint32 fieldCount);
22 ~ResultSet();
23
24 bool NextRow();
25 uint64 GetRowCount() const { return _rowCount; }
26 uint32 GetFieldCount() const { return _fieldCount; }
27
28 Field* Fetch() const { return _currentRow; }
29 const Field& operator [] (uint32 index) const
30 {
31 ASSERT(index < _fieldCount);
32 return _currentRow[index];
33 }
34
35protected:
39
40private:
41 void CleanUp();
42 MYSQL_RES* _result;
43 MYSQL_FIELD* _fields;
44 ResultSet(ResultSet const& right) = delete;
45 ResultSet& operator=(ResultSet const& right) = delete;
46};
47
49
51{
52public:
53 PreparedResultSet(MYSQL_STMT* stmt, MYSQL_RES* result, uint64 rowCount, uint32 fieldCount);
55
56 bool NextRow();
57 uint64 GetRowCount() const { return m_rowCount; }
58 uint32 GetFieldCount() const { return m_fieldCount; }
59
60 Field* Fetch() const
61 {
64 }
65
66 const Field& operator [] (uint32 index) const
67 {
69 ASSERT(index < m_fieldCount);
70 return m_rows[uint32(m_rowPosition)][index];
71 }
72
73protected:
74 std::vector<Field*> m_rows;
78
79private:
80 MYSQL_BIND* m_rBind;
81 MYSQL_STMT* m_stmt;
82 MYSQL_RES* m_res;
83
84 bool* m_isNull;
85 unsigned long* m_length;
86
87 void FreeBindBuffer();
88 void CleanUp();
89 bool _NextRow();
90 PreparedResultSet(PreparedResultSet const& right) = delete;
92};
93
95
96#endif
97
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
#define ASSERT
Definition Errors.h:29
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
Definition QueryResult.h:94
Skyfire::AutoPtr< ResultSet, Skyfire::Mutex > QueryResult
Definition QueryResult.h:48
Definition Field.h:16
PreparedResultSet(PreparedResultSet const &right)=delete
uint32 GetFieldCount() const
Definition QueryResult.h:58
std::vector< Field * > m_rows
Definition QueryResult.h:74
uint64 GetRowCount() const
Definition QueryResult.h:57
Field * Fetch() const
Definition QueryResult.h:60
const Field & operator[](uint32 index) const
Definition QueryResult.h:66
MYSQL_STMT * m_stmt
Definition QueryResult.h:81
PreparedResultSet & operator=(PreparedResultSet const &right)=delete
PreparedResultSet(MYSQL_STMT *stmt, MYSQL_RES *result, uint64 rowCount, uint32 fieldCount)
MYSQL_BIND * m_rBind
Definition QueryResult.h:80
unsigned long * m_length
Definition QueryResult.h:85
MYSQL_RES * m_res
Definition QueryResult.h:82
uint32 _fieldCount
Definition QueryResult.h:38
Field * _currentRow
Definition QueryResult.h:37
uint64 _rowCount
Definition QueryResult.h:36
uint64 GetRowCount() const
Definition QueryResult.h:25
void CleanUp()
MYSQL_RES * _result
Definition QueryResult.h:42
bool NextRow()
Field * Fetch() const
Definition QueryResult.h:28
const Field & operator[](uint32 index) const
Definition QueryResult.h:29
ResultSet(MYSQL_RES *result, MYSQL_FIELD *fields, uint64 rowCount, uint32 fieldCount)
uint32 GetFieldCount() const
Definition QueryResult.h:26
MYSQL_FIELD * _fields
Definition QueryResult.h:43
ResultSet(ResultSet const &right)=delete
ResultSet & operator=(ResultSet const &right)=delete