mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
Big update.
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "Define.h"
|
||||
#include "Field.h"
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
class AC_DATABASE_API ResultSet
|
||||
@@ -29,13 +31,29 @@ public:
|
||||
~ResultSet();
|
||||
|
||||
bool NextRow();
|
||||
uint64 GetRowCount() const { return _rowCount; }
|
||||
uint32 GetFieldCount() const { return _fieldCount; }
|
||||
std::string GetFieldName(uint32 index) const;
|
||||
[[nodiscard]] uint64 GetRowCount() const { return _rowCount; }
|
||||
[[nodiscard]] uint32 GetFieldCount() const { return _fieldCount; }
|
||||
[[nodiscard]] std::string GetFieldName(uint32 index) const;
|
||||
|
||||
Field* Fetch() const { return _currentRow; }
|
||||
[[nodiscard]] Field* Fetch() const { return _currentRow; }
|
||||
Field const& operator[](std::size_t index) const;
|
||||
|
||||
template<typename... Ts>
|
||||
inline std::tuple<Ts...> FetchTuple()
|
||||
{
|
||||
AssertRows(sizeof...(Ts));
|
||||
|
||||
std::tuple<Ts...> theTuple = {};
|
||||
|
||||
std::apply([this](Ts&... args)
|
||||
{
|
||||
uint8 index{ 0 };
|
||||
((args = _currentRow[index].Get<Ts>(), index++), ...);
|
||||
}, theTuple);
|
||||
|
||||
return theTuple;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<QueryResultFieldMetadata> _fieldMetadata;
|
||||
uint64 _rowCount;
|
||||
@@ -44,6 +62,8 @@ protected:
|
||||
|
||||
private:
|
||||
void CleanUp();
|
||||
void AssertRows(std::size_t sizeRows);
|
||||
|
||||
MySQLResult* _result;
|
||||
MySQLField* _fields;
|
||||
|
||||
@@ -58,12 +78,28 @@ public:
|
||||
~PreparedResultSet();
|
||||
|
||||
bool NextRow();
|
||||
uint64 GetRowCount() const { return m_rowCount; }
|
||||
uint32 GetFieldCount() const { return m_fieldCount; }
|
||||
[[nodiscard]] uint64 GetRowCount() const { return m_rowCount; }
|
||||
[[nodiscard]] uint32 GetFieldCount() const { return m_fieldCount; }
|
||||
|
||||
Field* Fetch() const;
|
||||
[[nodiscard]] Field* Fetch() const;
|
||||
Field const& operator[](std::size_t index) const;
|
||||
|
||||
template<typename... Ts>
|
||||
inline std::tuple<Ts...> FetchTuple()
|
||||
{
|
||||
AssertRows(sizeof...(Ts));
|
||||
|
||||
std::tuple<Ts...> theTuple = {};
|
||||
|
||||
std::apply([this](Ts&... args)
|
||||
{
|
||||
uint8 index{ 0 };
|
||||
((args = m_rows[uint32(m_rowPosition) * m_fieldCount + index].Get<Ts>(), index++), ...);
|
||||
}, theTuple);
|
||||
|
||||
return theTuple;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<QueryResultFieldMetadata> m_fieldMetadata;
|
||||
std::vector<Field> m_rows;
|
||||
@@ -79,6 +115,8 @@ private:
|
||||
void CleanUp();
|
||||
bool _NextRow();
|
||||
|
||||
void AssertRows(std::size_t sizeRows);
|
||||
|
||||
PreparedResultSet(PreparedResultSet const& right) = delete;
|
||||
PreparedResultSet& operator=(PreparedResultSet const& right) = delete;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user