From 8b26bab37d4cd1cbe63f665ea26edfbb5d5a72e5 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Wed, 23 Nov 2022 17:46:20 -0500 Subject: [PATCH] Remove unnecessary bool return types --- src/database/database-dummy.cpp | 6 ++---- src/database/database-dummy.h | 4 ++-- src/database/database-files.cpp | 12 ++++-------- src/database/database-files.h | 4 ++-- src/database/database-postgresql.cpp | 8 ++------ src/database/database-postgresql.h | 4 ++-- src/database/database-sqlite3.cpp | 8 ++------ src/database/database-sqlite3.h | 4 ++-- src/database/database.h | 4 ++-- 9 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/database/database-dummy.cpp b/src/database/database-dummy.cpp index 9fa325b93..19cb6e4fa 100644 --- a/src/database/database-dummy.cpp +++ b/src/database/database-dummy.cpp @@ -81,7 +81,7 @@ void Database_Dummy::listPlayers(std::vector &res) } } -bool Database_Dummy::getModEntries(const std::string &modname, StringMap *storage) +void Database_Dummy::getModEntries(const std::string &modname, StringMap *storage) { const auto mod_pair = m_mod_storage_database.find(modname); if (mod_pair != m_mod_storage_database.cend()) { @@ -89,10 +89,9 @@ bool Database_Dummy::getModEntries(const std::string &modname, StringMap *storag (*storage)[pair.first] = pair.second; } } - return true; } -bool Database_Dummy::getModKeys(const std::string &modname, std::vector *storage) +void Database_Dummy::getModKeys(const std::string &modname, std::vector *storage) { const auto mod_pair = m_mod_storage_database.find(modname); if (mod_pair != m_mod_storage_database.cend()) { @@ -100,7 +99,6 @@ bool Database_Dummy::getModKeys(const std::string &modname, std::vectorsecond) storage->push_back(pair.first); } - return true; } bool Database_Dummy::getModEntry(const std::string &modname, diff --git a/src/database/database-dummy.h b/src/database/database-dummy.h index 42964b5bc..ecfa82c34 100644 --- a/src/database/database-dummy.h +++ b/src/database/database-dummy.h @@ -37,8 +37,8 @@ public: bool removePlayer(const std::string &name); void listPlayers(std::vector &res); - bool getModEntries(const std::string &modname, StringMap *storage); - bool getModKeys(const std::string &modname, std::vector *storage); + void getModEntries(const std::string &modname, StringMap *storage); + void getModKeys(const std::string &modname, std::vector *storage); bool getModEntry(const std::string &modname, const std::string &key, std::string *value); bool hasModEntry(const std::string &modname, const std::string &key); diff --git a/src/database/database-files.cpp b/src/database/database-files.cpp index e90a50619..5b41f6c19 100644 --- a/src/database/database-files.cpp +++ b/src/database/database-files.cpp @@ -381,34 +381,30 @@ ModStorageDatabaseFiles::ModStorageDatabaseFiles(const std::string &savedir): { } -bool ModStorageDatabaseFiles::getModEntries(const std::string &modname, StringMap *storage) +void ModStorageDatabaseFiles::getModEntries(const std::string &modname, StringMap *storage) { Json::Value *meta = getOrCreateJson(modname); if (!meta) - return false; + return; const Json::Value::Members attr_list = meta->getMemberNames(); for (const auto &it : attr_list) { Json::Value attr_value = (*meta)[it]; (*storage)[it] = attr_value.asString(); } - - return true; } -bool ModStorageDatabaseFiles::getModKeys(const std::string &modname, +void ModStorageDatabaseFiles::getModKeys(const std::string &modname, std::vector *storage) { Json::Value *meta = getOrCreateJson(modname); if (!meta) - return false; + return; std::vector keys = meta->getMemberNames(); storage->reserve(storage->size() + keys.size()); for (std::string &key : keys) storage->push_back(std::move(key)); - - return true; } bool ModStorageDatabaseFiles::getModEntry(const std::string &modname, diff --git a/src/database/database-files.h b/src/database/database-files.h index 20b0b5896..09116b2b4 100644 --- a/src/database/database-files.h +++ b/src/database/database-files.h @@ -78,8 +78,8 @@ public: ModStorageDatabaseFiles(const std::string &savedir); virtual ~ModStorageDatabaseFiles() = default; - virtual bool getModEntries(const std::string &modname, StringMap *storage); - virtual bool getModKeys(const std::string &modname, std::vector *storage); + virtual void getModEntries(const std::string &modname, StringMap *storage); + virtual void getModKeys(const std::string &modname, std::vector *storage); virtual bool getModEntry(const std::string &modname, const std::string &key, std::string *value); virtual bool hasModEntry(const std::string &modname, const std::string &key); diff --git a/src/database/database-postgresql.cpp b/src/database/database-postgresql.cpp index 1c51a8d85..d84b26b55 100644 --- a/src/database/database-postgresql.cpp +++ b/src/database/database-postgresql.cpp @@ -866,7 +866,7 @@ void ModStorageDatabasePostgreSQL::initStatements() "SELECT DISTINCT modname FROM mod_storage"); } -bool ModStorageDatabasePostgreSQL::getModEntries(const std::string &modname, StringMap *storage) +void ModStorageDatabasePostgreSQL::getModEntries(const std::string &modname, StringMap *storage) { verifyDatabase(); @@ -882,11 +882,9 @@ bool ModStorageDatabasePostgreSQL::getModEntries(const std::string &modname, Str (*storage)[pg_to_string(results, row, 0)] = pg_to_string(results, row, 1); PQclear(results); - - return true; } -bool ModStorageDatabasePostgreSQL::getModKeys(const std::string &modname, +void ModStorageDatabasePostgreSQL::getModKeys(const std::string &modname, std::vector *storage) { verifyDatabase(); @@ -904,8 +902,6 @@ bool ModStorageDatabasePostgreSQL::getModKeys(const std::string &modname, storage->push_back(pg_to_string(results, row, 0)); PQclear(results); - - return true; } bool ModStorageDatabasePostgreSQL::getModEntry(const std::string &modname, diff --git a/src/database/database-postgresql.h b/src/database/database-postgresql.h index a587f3d9e..56b3d6b53 100644 --- a/src/database/database-postgresql.h +++ b/src/database/database-postgresql.h @@ -181,8 +181,8 @@ public: ModStorageDatabasePostgreSQL(const std::string &connect_string); ~ModStorageDatabasePostgreSQL() = default; - bool getModEntries(const std::string &modname, StringMap *storage); - bool getModKeys(const std::string &modname, std::vector *storage); + void getModEntries(const std::string &modname, StringMap *storage); + void getModKeys(const std::string &modname, std::vector *storage); bool getModEntry(const std::string &modname, const std::string &key, std::string *value); bool hasModEntry(const std::string &modname, const std::string &key); bool setModEntry(const std::string &modname, diff --git a/src/database/database-sqlite3.cpp b/src/database/database-sqlite3.cpp index 636864d82..7b4b6ddbe 100644 --- a/src/database/database-sqlite3.cpp +++ b/src/database/database-sqlite3.cpp @@ -808,7 +808,7 @@ void ModStorageDatabaseSQLite3::initStatements() PREPARE_STATEMENT(remove_all, "DELETE FROM `entries` WHERE `modname` = ?"); } -bool ModStorageDatabaseSQLite3::getModEntries(const std::string &modname, StringMap *storage) +void ModStorageDatabaseSQLite3::getModEntries(const std::string &modname, StringMap *storage) { verifyDatabase(); @@ -823,11 +823,9 @@ bool ModStorageDatabaseSQLite3::getModEntries(const std::string &modname, String sqlite3_vrfy(sqlite3_errcode(m_database), SQLITE_DONE); sqlite3_reset(m_stmt_get_all); - - return true; } -bool ModStorageDatabaseSQLite3::getModKeys(const std::string &modname, +void ModStorageDatabaseSQLite3::getModKeys(const std::string &modname, std::vector *storage) { verifyDatabase(); @@ -841,8 +839,6 @@ bool ModStorageDatabaseSQLite3::getModKeys(const std::string &modname, sqlite3_vrfy(sqlite3_errcode(m_database), SQLITE_DONE); sqlite3_reset(m_stmt_get_keys); - - return true; } bool ModStorageDatabaseSQLite3::getModEntry(const std::string &modname, diff --git a/src/database/database-sqlite3.h b/src/database/database-sqlite3.h index 3eaacbe11..a400537ff 100644 --- a/src/database/database-sqlite3.h +++ b/src/database/database-sqlite3.h @@ -239,8 +239,8 @@ public: ModStorageDatabaseSQLite3(const std::string &savedir); virtual ~ModStorageDatabaseSQLite3(); - virtual bool getModEntries(const std::string &modname, StringMap *storage); - virtual bool getModKeys(const std::string &modname, std::vector *storage); + virtual void getModEntries(const std::string &modname, StringMap *storage); + virtual void getModKeys(const std::string &modname, std::vector *storage); virtual bool getModEntry(const std::string &modname, const std::string &key, std::string *value); virtual bool hasModEntry(const std::string &modname, const std::string &key); diff --git a/src/database/database.h b/src/database/database.h index 123cdadda..84912e795 100644 --- a/src/database/database.h +++ b/src/database/database.h @@ -91,8 +91,8 @@ class ModStorageDatabase : public Database public: virtual ~ModStorageDatabase() = default; - virtual bool getModEntries(const std::string &modname, StringMap *storage) = 0; - virtual bool getModKeys(const std::string &modname, std::vector *storage) = 0; + virtual void getModEntries(const std::string &modname, StringMap *storage) = 0; + virtual void getModKeys(const std::string &modname, std::vector *storage) = 0; virtual bool hasModEntry(const std::string &modname, const std::string &key) = 0; virtual bool getModEntry(const std::string &modname, const std::string &key, std::string *value) = 0;