refactor(Core): apply clang-tidy modernize-use-nodiscard (#3835)

This commit is contained in:
Francesco Borzì
2020-12-06 19:39:48 +01:00
committed by GitHub
parent d4a58700d4
commit 161302252e
82 changed files with 1565 additions and 1569 deletions

View File

@@ -199,7 +199,7 @@ public:
//! Keeps all our MySQL connections alive, prevent the server from disconnecting us.
void KeepAlive();
char const* GetDatabaseName() const
[[nodiscard]] char const* GetDatabaseName() const
{
return _connectionInfo.database.c_str();
}

View File

@@ -19,12 +19,12 @@ class Field
public:
bool GetBool() const // Wrapper, actually gets integer
[[nodiscard]] bool GetBool() const // Wrapper, actually gets integer
{
return (GetUInt8() == 1);
}
uint8 GetUInt8() const
[[nodiscard]] uint8 GetUInt8() const
{
if (!data.value)
return 0;
@@ -42,7 +42,7 @@ public:
return static_cast<uint8>(atol((char*)data.value));
}
int8 GetInt8() const
[[nodiscard]] int8 GetInt8() const
{
if (!data.value)
return 0;
@@ -67,7 +67,7 @@ public:
}
#endif
uint16 GetUInt16() const
[[nodiscard]] uint16 GetUInt16() const
{
if (!data.value)
return 0;
@@ -85,7 +85,7 @@ public:
return static_cast<uint16>(atol((char*)data.value));
}
int16 GetInt16() const
[[nodiscard]] int16 GetInt16() const
{
if (!data.value)
return 0;
@@ -103,7 +103,7 @@ public:
return static_cast<int16>(atol((char*)data.value));
}
uint32 GetUInt32() const
[[nodiscard]] uint32 GetUInt32() const
{
if (!data.value)
return 0;
@@ -121,7 +121,7 @@ public:
return static_cast<uint32>(atol((char*)data.value));
}
int32 GetInt32() const
[[nodiscard]] int32 GetInt32() const
{
if (!data.value)
return 0;
@@ -139,7 +139,7 @@ public:
return static_cast<int32>(atol((char*)data.value));
}
uint64 GetUInt64() const
[[nodiscard]] uint64 GetUInt64() const
{
if (!data.value)
return 0;
@@ -157,7 +157,7 @@ public:
return static_cast<uint64>(atol((char*)data.value));
}
int64 GetInt64() const
[[nodiscard]] int64 GetInt64() const
{
if (!data.value)
return 0;
@@ -175,7 +175,7 @@ public:
return static_cast<int64>(strtol((char*)data.value, NULL, 10));
}
float GetFloat() const
[[nodiscard]] float GetFloat() const
{
if (!data.value)
return 0.0f;
@@ -193,7 +193,7 @@ public:
return static_cast<float>(atof((char*)data.value));
}
double GetDouble() const
[[nodiscard]] double GetDouble() const
{
if (!data.value)
return 0.0f;
@@ -211,7 +211,7 @@ public:
return static_cast<double>(atof((char*)data.value));
}
char const* GetCString() const
[[nodiscard]] char const* GetCString() const
{
if (!data.value)
return NULL;
@@ -227,7 +227,7 @@ public:
}
std::string GetString() const
[[nodiscard]] std::string GetString() const
{
if (!data.value)
return "";
@@ -242,7 +242,7 @@ public:
return std::string((char*)data.value);
}
bool IsNull() const
[[nodiscard]] bool IsNull() const
{
return data.value == NULL;
}
@@ -328,12 +328,12 @@ protected:
}
}
bool IsType(enum_field_types type) const
[[nodiscard]] bool IsType(enum_field_types type) const
{
return data.type == type;
}
bool IsNumeric() const
[[nodiscard]] bool IsNumeric() const
{
return (data.type == MYSQL_TYPE_TINY ||
data.type == MYSQL_TYPE_SHORT ||

View File

@@ -124,7 +124,7 @@ protected:
PreparedStatement* m_stmt;
void ClearParameters();
bool CheckValidIndex(uint8 index);
std::string getQueryString(std::string const& sqlPattern) const;
[[nodiscard]] std::string getQueryString(std::string const& sqlPattern) const;
private:
void setValue(MYSQL_BIND* param, enum_field_types type, const void* value, uint32 len, bool isUnsigned);

View File

@@ -28,12 +28,12 @@ public:
~ResultSet();
bool NextRow();
uint64 GetRowCount() const { return _rowCount; }
uint32 GetFieldCount() const { return _fieldCount; }
[[nodiscard]] uint64 GetRowCount() const { return _rowCount; }
[[nodiscard]] uint32 GetFieldCount() const { return _fieldCount; }
#ifdef ELUNA
std::string GetFieldName(uint32 index) const;
#endif
Field* Fetch() const { return _currentRow; }
[[nodiscard]] Field* Fetch() const { return _currentRow; }
const Field& operator [] (uint32 index) const
{
ASSERT(index < _fieldCount);
@@ -60,10 +60,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
{
ASSERT(m_rowPosition < m_rowCount);
return m_rows[uint32(m_rowPosition)];

View File

@@ -29,7 +29,7 @@ public:
void Append(const char* sql);
void PAppend(const char* sql, ...);
size_t GetSize() const { return m_queries.size(); }
[[nodiscard]] size_t GetSize() const { return m_queries.size(); }
protected:
void Cleanup();