Remove unnecessary bool return types

This commit is contained in:
Jude Melton-Houghton 2022-11-23 17:46:20 -05:00
parent 7c21347a40
commit 8b26bab37d
9 changed files with 20 additions and 34 deletions

@ -81,7 +81,7 @@ void Database_Dummy::listPlayers(std::vector<std::string> &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); const auto mod_pair = m_mod_storage_database.find(modname);
if (mod_pair != m_mod_storage_database.cend()) { 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; (*storage)[pair.first] = pair.second;
} }
} }
return true;
} }
bool Database_Dummy::getModKeys(const std::string &modname, std::vector<std::string> *storage) void Database_Dummy::getModKeys(const std::string &modname, std::vector<std::string> *storage)
{ {
const auto mod_pair = m_mod_storage_database.find(modname); const auto mod_pair = m_mod_storage_database.find(modname);
if (mod_pair != m_mod_storage_database.cend()) { if (mod_pair != m_mod_storage_database.cend()) {
@ -100,7 +99,6 @@ bool Database_Dummy::getModKeys(const std::string &modname, std::vector<std::str
for (const auto &pair : mod_pair->second) for (const auto &pair : mod_pair->second)
storage->push_back(pair.first); storage->push_back(pair.first);
} }
return true;
} }
bool Database_Dummy::getModEntry(const std::string &modname, bool Database_Dummy::getModEntry(const std::string &modname,

@ -37,8 +37,8 @@ public:
bool removePlayer(const std::string &name); bool removePlayer(const std::string &name);
void listPlayers(std::vector<std::string> &res); void listPlayers(std::vector<std::string> &res);
bool getModEntries(const std::string &modname, StringMap *storage); void getModEntries(const std::string &modname, StringMap *storage);
bool getModKeys(const std::string &modname, std::vector<std::string> *storage); void getModKeys(const std::string &modname, std::vector<std::string> *storage);
bool getModEntry(const std::string &modname, bool getModEntry(const std::string &modname,
const std::string &key, std::string *value); const std::string &key, std::string *value);
bool hasModEntry(const std::string &modname, const std::string &key); bool hasModEntry(const std::string &modname, const std::string &key);

@ -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); Json::Value *meta = getOrCreateJson(modname);
if (!meta) if (!meta)
return false; return;
const Json::Value::Members attr_list = meta->getMemberNames(); const Json::Value::Members attr_list = meta->getMemberNames();
for (const auto &it : attr_list) { for (const auto &it : attr_list) {
Json::Value attr_value = (*meta)[it]; Json::Value attr_value = (*meta)[it];
(*storage)[it] = attr_value.asString(); (*storage)[it] = attr_value.asString();
} }
return true;
} }
bool ModStorageDatabaseFiles::getModKeys(const std::string &modname, void ModStorageDatabaseFiles::getModKeys(const std::string &modname,
std::vector<std::string> *storage) std::vector<std::string> *storage)
{ {
Json::Value *meta = getOrCreateJson(modname); Json::Value *meta = getOrCreateJson(modname);
if (!meta) if (!meta)
return false; return;
std::vector<std::string> keys = meta->getMemberNames(); std::vector<std::string> keys = meta->getMemberNames();
storage->reserve(storage->size() + keys.size()); storage->reserve(storage->size() + keys.size());
for (std::string &key : keys) for (std::string &key : keys)
storage->push_back(std::move(key)); storage->push_back(std::move(key));
return true;
} }
bool ModStorageDatabaseFiles::getModEntry(const std::string &modname, bool ModStorageDatabaseFiles::getModEntry(const std::string &modname,

@ -78,8 +78,8 @@ public:
ModStorageDatabaseFiles(const std::string &savedir); ModStorageDatabaseFiles(const std::string &savedir);
virtual ~ModStorageDatabaseFiles() = default; virtual ~ModStorageDatabaseFiles() = default;
virtual bool getModEntries(const std::string &modname, StringMap *storage); virtual void getModEntries(const std::string &modname, StringMap *storage);
virtual bool getModKeys(const std::string &modname, std::vector<std::string> *storage); virtual void getModKeys(const std::string &modname, std::vector<std::string> *storage);
virtual bool getModEntry(const std::string &modname, virtual bool getModEntry(const std::string &modname,
const std::string &key, std::string *value); const std::string &key, std::string *value);
virtual bool hasModEntry(const std::string &modname, const std::string &key); virtual bool hasModEntry(const std::string &modname, const std::string &key);

@ -866,7 +866,7 @@ void ModStorageDatabasePostgreSQL::initStatements()
"SELECT DISTINCT modname FROM mod_storage"); "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(); 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); (*storage)[pg_to_string(results, row, 0)] = pg_to_string(results, row, 1);
PQclear(results); PQclear(results);
return true;
} }
bool ModStorageDatabasePostgreSQL::getModKeys(const std::string &modname, void ModStorageDatabasePostgreSQL::getModKeys(const std::string &modname,
std::vector<std::string> *storage) std::vector<std::string> *storage)
{ {
verifyDatabase(); verifyDatabase();
@ -904,8 +902,6 @@ bool ModStorageDatabasePostgreSQL::getModKeys(const std::string &modname,
storage->push_back(pg_to_string(results, row, 0)); storage->push_back(pg_to_string(results, row, 0));
PQclear(results); PQclear(results);
return true;
} }
bool ModStorageDatabasePostgreSQL::getModEntry(const std::string &modname, bool ModStorageDatabasePostgreSQL::getModEntry(const std::string &modname,

@ -181,8 +181,8 @@ public:
ModStorageDatabasePostgreSQL(const std::string &connect_string); ModStorageDatabasePostgreSQL(const std::string &connect_string);
~ModStorageDatabasePostgreSQL() = default; ~ModStorageDatabasePostgreSQL() = default;
bool getModEntries(const std::string &modname, StringMap *storage); void getModEntries(const std::string &modname, StringMap *storage);
bool getModKeys(const std::string &modname, std::vector<std::string> *storage); void getModKeys(const std::string &modname, std::vector<std::string> *storage);
bool getModEntry(const std::string &modname, const std::string &key, std::string *value); bool getModEntry(const std::string &modname, const std::string &key, std::string *value);
bool hasModEntry(const std::string &modname, const std::string &key); bool hasModEntry(const std::string &modname, const std::string &key);
bool setModEntry(const std::string &modname, bool setModEntry(const std::string &modname,

@ -808,7 +808,7 @@ void ModStorageDatabaseSQLite3::initStatements()
PREPARE_STATEMENT(remove_all, "DELETE FROM `entries` WHERE `modname` = ?"); 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(); verifyDatabase();
@ -823,11 +823,9 @@ bool ModStorageDatabaseSQLite3::getModEntries(const std::string &modname, String
sqlite3_vrfy(sqlite3_errcode(m_database), SQLITE_DONE); sqlite3_vrfy(sqlite3_errcode(m_database), SQLITE_DONE);
sqlite3_reset(m_stmt_get_all); sqlite3_reset(m_stmt_get_all);
return true;
} }
bool ModStorageDatabaseSQLite3::getModKeys(const std::string &modname, void ModStorageDatabaseSQLite3::getModKeys(const std::string &modname,
std::vector<std::string> *storage) std::vector<std::string> *storage)
{ {
verifyDatabase(); verifyDatabase();
@ -841,8 +839,6 @@ bool ModStorageDatabaseSQLite3::getModKeys(const std::string &modname,
sqlite3_vrfy(sqlite3_errcode(m_database), SQLITE_DONE); sqlite3_vrfy(sqlite3_errcode(m_database), SQLITE_DONE);
sqlite3_reset(m_stmt_get_keys); sqlite3_reset(m_stmt_get_keys);
return true;
} }
bool ModStorageDatabaseSQLite3::getModEntry(const std::string &modname, bool ModStorageDatabaseSQLite3::getModEntry(const std::string &modname,

@ -239,8 +239,8 @@ public:
ModStorageDatabaseSQLite3(const std::string &savedir); ModStorageDatabaseSQLite3(const std::string &savedir);
virtual ~ModStorageDatabaseSQLite3(); virtual ~ModStorageDatabaseSQLite3();
virtual bool getModEntries(const std::string &modname, StringMap *storage); virtual void getModEntries(const std::string &modname, StringMap *storage);
virtual bool getModKeys(const std::string &modname, std::vector<std::string> *storage); virtual void getModKeys(const std::string &modname, std::vector<std::string> *storage);
virtual bool getModEntry(const std::string &modname, virtual bool getModEntry(const std::string &modname,
const std::string &key, std::string *value); const std::string &key, std::string *value);
virtual bool hasModEntry(const std::string &modname, const std::string &key); virtual bool hasModEntry(const std::string &modname, const std::string &key);

@ -91,8 +91,8 @@ class ModStorageDatabase : public Database
public: public:
virtual ~ModStorageDatabase() = default; virtual ~ModStorageDatabase() = default;
virtual bool getModEntries(const std::string &modname, StringMap *storage) = 0; virtual void getModEntries(const std::string &modname, StringMap *storage) = 0;
virtual bool getModKeys(const std::string &modname, std::vector<std::string> *storage) = 0; virtual void getModKeys(const std::string &modname, std::vector<std::string> *storage) = 0;
virtual bool hasModEntry(const std::string &modname, const std::string &key) = 0; virtual bool hasModEntry(const std::string &modname, const std::string &key) = 0;
virtual bool getModEntry(const std::string &modname, virtual bool getModEntry(const std::string &modname,
const std::string &key, std::string *value) = 0; const std::string &key, std::string *value) = 0;