From 23db0edd229a4cc37390bfc5df870d7aaf191f03 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Thu, 26 Nov 2020 10:34:59 +0100 Subject: [PATCH] Improved the code quality and TeaSpeak now builds with clang --- src/misc/strobf.h | 1 + src/query/command3.h | 5 +++-- src/sql/SqlQuery.h | 4 ++-- src/sql/mysql/MySQL.cpp | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/misc/strobf.h b/src/misc/strobf.h index f834330..a581bec 100644 --- a/src/misc/strobf.h +++ b/src/misc/strobf.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/src/query/command3.h b/src/query/command3.h index ce96e75..1c5cc7f 100644 --- a/src/query/command3.h +++ b/src/query/command3.h @@ -330,10 +330,11 @@ namespace ts { if(it + 1 != this->bulks.end()) result.append("|"); } - if(!with_empty && result.ends_with('|')) + if(!with_empty && !result.empty() && result.back() == '|') { this->builded = result.substr(0, result.length() - 1); - else + } else { this->builded = result; + } this->flag_changed = false; return this->builded.value(); } diff --git a/src/sql/SqlQuery.h b/src/sql/SqlQuery.h index ae8da15..1259c9d 100644 --- a/src/sql/SqlQuery.h +++ b/src/sql/SqlQuery.h @@ -262,7 +262,7 @@ namespace sql { friend class ::sql::command; friend class ::sql::model; public: - explicit command_base(nullptr_t) : _data{nullptr} {} + explicit command_base(std::nullptr_t) : _data{nullptr} {} command_base(SqlManager* handle, const std::string &sql, std::initializer_list values) { assert(handle); @@ -329,7 +329,7 @@ namespace sql { template model(SqlManager* handle, const std::string &sql, Ts... vars) : model(handle, sql, {}) { values(vars...); } - explicit model(nullptr_t) : command_base{nullptr} {}; + explicit model(std::nullptr_t) : command_base{nullptr} {}; //model(const model& v) : command_base{v} {}; //model(model&& v) noexcept : command_base{std::forward(v)} {}; ~model() override = default; diff --git a/src/sql/mysql/MySQL.cpp b/src/sql/mysql/MySQL.cpp index 42a70c2..3b9aa4e 100644 --- a/src/sql/mysql/MySQL.cpp +++ b/src/sql/mysql/MySQL.cpp @@ -707,7 +707,7 @@ result MySQLManager::executeCommand(std::shared_ptr _ptr) { if(!sql::mysql::create_bind(bind_parameter_memory.ptr, mapped_variables)) return {ptr->sql_command, -1, "Failed to allocate bind memory!"}; - ResultBind bind_result_data{.field_count = 0, .memory = nullptr, .descriptors = nullptr}; + ResultBind bind_result_data{0, nullptr, nullptr}; auto connection = this->next_connection(); if(!connection) return {ptr->sql_command, -1, "Could not get a valid connection!"}; @@ -761,7 +761,7 @@ result MySQLManager::queryCommand(shared_ptr _ptr, const QueryCallb FreeGuard bind_parameter_memory{nullptr}; if(!sql::mysql::create_bind(bind_parameter_memory.ptr, mapped_variables)) return {ptr->sql_command, -1, "Failed to allocate bind memory!"}; - ResultBind bind_result_data{.field_count = 0, .memory = nullptr, .descriptors = nullptr}; + ResultBind bind_result_data{0, nullptr, nullptr}; auto connection = this->next_connection(); if(!connection) return {ptr->sql_command, -1, "Could not get a valid connection!"};