refactor(Core): apply clang-tidy modernize-* (#9975)

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Francesco Borzì
2022-01-17 14:35:07 +01:00
committed by GitHub
parent fe4899202d
commit 9dc88def35
71 changed files with 533 additions and 534 deletions

View File

@@ -57,7 +57,7 @@ public:
//! Prepares all prepared statements
bool PrepareStatements();
inline MySQLConnectionInfo const* GetConnectionInfo() const
[[nodiscard]] inline MySQLConnectionInfo const* GetConnectionInfo() const
{
return _connectionInfo.get();
}
@@ -213,7 +213,7 @@ public:
#endif
}
size_t QueueSize() const;
[[nodiscard]] size_t QueueSize() const;
private:
uint32 OpenConnections(InternalIndex type, uint8 numConnections);
@@ -226,7 +226,7 @@ private:
//! Caller MUST call t->Unlock() after touching the MySQL context to prevent deadlocks.
T* GetFreeConnection();
char const* GetDatabaseName() const;
[[nodiscard]] char const* GetDatabaseName() const;
//! Queue shared by async worker threads.
std::unique_ptr<ProducerConsumerQueue<SQLOperation*>> _queue;

View File

@@ -89,25 +89,25 @@ public:
Field();
~Field();
bool GetBool() const // Wrapper, actually gets integer
[[nodiscard]] bool GetBool() const // Wrapper, actually gets integer
{
return GetUInt8() == 1 ? true : false;
}
uint8 GetUInt8() const;
int8 GetInt8() const;
uint16 GetUInt16() const;
int16 GetInt16() const;
uint32 GetUInt32() const;
int32 GetInt32() const;
uint64 GetUInt64() const;
int64 GetInt64() const;
float GetFloat() const;
double GetDouble() const;
char const* GetCString() const;
std::string GetString() const;
std::string_view GetStringView() const;
std::vector<uint8> GetBinary() const;
[[nodiscard]] uint8 GetUInt8() const;
[[nodiscard]] int8 GetInt8() const;
[[nodiscard]] uint16 GetUInt16() const;
[[nodiscard]] int16 GetInt16() const;
[[nodiscard]] uint32 GetUInt32() const;
[[nodiscard]] int32 GetInt32() const;
[[nodiscard]] uint64 GetUInt64() const;
[[nodiscard]] int64 GetInt64() const;
[[nodiscard]] float GetFloat() const;
[[nodiscard]] double GetDouble() const;
[[nodiscard]] char const* GetCString() const;
[[nodiscard]] std::string GetString() const;
[[nodiscard]] std::string_view GetStringView() const;
[[nodiscard]] std::vector<uint8> GetBinary() const;
template <size_t S>
std::array<uint8, S> GetBinary() const
@@ -117,7 +117,7 @@ public:
return buf;
}
bool IsNull() const
[[nodiscard]] bool IsNull() const
{
return data.value == nullptr;
}
@@ -134,8 +134,8 @@ protected:
void SetByteValue(char const* newValue, uint32 length);
void SetStructuredValue(char const* newValue, uint32 length);
bool IsType(DatabaseFieldTypes type) const;
bool IsNumeric() const;
[[nodiscard]] bool IsType(DatabaseFieldTypes type) const;
[[nodiscard]] bool IsNumeric() const;
private:
QueryResultFieldMetadata const* meta;

View File

@@ -523,7 +523,7 @@ public:
//- Constructors for sync and async connections
CharacterDatabaseConnection(MySQLConnectionInfo& connInfo);
CharacterDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo);
~CharacterDatabaseConnection();
~CharacterDatabaseConnection() override;
//- Loads database type specific prepared statements
void DoPrepareStatements() override;

View File

@@ -128,7 +128,7 @@ public:
//- Constructors for sync and async connections
LoginDatabaseConnection(MySQLConnectionInfo& connInfo);
LoginDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo);
~LoginDatabaseConnection();
~LoginDatabaseConnection() override;
//- Loads database type specific prepared statements
void DoPrepareStatements() override;

View File

@@ -112,7 +112,7 @@ public:
//- Constructors for sync and async connections
WorldDatabaseConnection(MySQLConnectionInfo& connInfo);
WorldDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo);
~WorldDatabaseConnection();
~WorldDatabaseConnection() override;
//- Loads database type specific prepared statements
void DoPrepareStatements() override;

View File

@@ -91,7 +91,7 @@ protected:
/// Called by parent databasepool. Will let other threads access this connection
void Unlock();
uint32 GetServerVersion() const;
[[nodiscard]] uint32 GetServerVersion() const;
MySQLPreparedStatement* GetPreparedStatement(uint32 index);
void PrepareStatement(uint32 index, std::string const& sql, ConnectionFlags flags);

View File

@@ -85,8 +85,8 @@ public:
setBinary(index, vec);
}
uint32 GetIndex() const { return m_index; }
std::vector<PreparedStatementData> const& GetParameters() const { return statement_data; }
[[nodiscard]] uint32 GetIndex() const { return m_index; }
[[nodiscard]] std::vector<PreparedStatementData> const& GetParameters() const { return statement_data; }
protected:
uint32 m_index;
@@ -116,7 +116,7 @@ class AC_DATABASE_API PreparedStatementTask : public SQLOperation
{
public:
PreparedStatementTask(PreparedStatementBase* stmt, bool async = false);
~PreparedStatementTask();
~PreparedStatementTask() override;
bool Execute() override;
PreparedQueryResultFuture GetFuture() { return m_result->get_future(); }

View File

@@ -29,11 +29,11 @@ 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;
protected:
@@ -58,10 +58,10 @@ 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;
protected:

View File

@@ -47,8 +47,8 @@ class MySQLConnection;
class AC_DATABASE_API SQLOperation
{
public:
SQLOperation(): m_conn(nullptr) { }
virtual ~SQLOperation() { }
SQLOperation() = default;
virtual ~SQLOperation() = default;
virtual int call()
{
@@ -58,7 +58,7 @@ public:
virtual bool Execute() = 0;
virtual void SetConnection(MySQLConnection* con) { m_conn = con; }
MySQLConnection* m_conn;
MySQLConnection* m_conn{nullptr};
private:
SQLOperation(SQLOperation const& right) = delete;

View File

@@ -24,6 +24,7 @@
#include "StringFormat.h"
#include <functional>
#include <mutex>
#include <utility>
#include <vector>
/*! Transactions, high level class. */
@@ -36,7 +37,7 @@ template <typename T>
friend class DatabaseWorkerPool;
public:
TransactionBase() : _cleanedUp(false) { }
TransactionBase() = default;
virtual ~TransactionBase() { Cleanup(); }
void Append(char const* sql);
@@ -46,7 +47,7 @@ public:
Append(Acore::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
}
std::size_t GetSize() const { return m_queries.size(); }
[[nodiscard]] std::size_t GetSize() const { return m_queries.size(); }
protected:
void AppendPreparedStatement(PreparedStatementBase* statement);
@@ -54,7 +55,7 @@ protected:
std::vector<SQLElementData> m_queries;
private:
bool _cleanedUp;
bool _cleanedUp{false};
};
template<typename T>
@@ -76,8 +77,8 @@ friend class DatabaseWorker;
friend class TransactionCallback;
public:
TransactionTask(std::shared_ptr<TransactionBase> trans) : m_trans(trans) { }
~TransactionTask() { }
TransactionTask(std::shared_ptr<TransactionBase> trans) : m_trans(std::move(trans)) { }
~TransactionTask() override = default;
protected:
bool Execute() override;