From 1d357adfa19725ee69fb267a363f1fd217b1272f Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sat, 4 Jan 2025 12:02:45 -0600 Subject: Various style fixes. --- source/fud_sqlite.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source/fud_sqlite.cpp') diff --git a/source/fud_sqlite.cpp b/source/fud_sqlite.cpp index 735389f..4a7187f 100644 --- a/source/fud_sqlite.cpp +++ b/source/fud_sqlite.cpp @@ -26,23 +26,33 @@ SqliteDbResult SqliteDb::make(const String& name, SqliteOpenMode mode, int extra if (copyResult != FudStatus::Success) { return SqliteDbResult::error(copyResult); } - sqlDb.m_mode = mode; - sqlDb.m_extraFlags = extraFlags; - auto status = sqlDb.initialize(); - if (status != FudStatus::Success) { - return SqliteDbResult::error(status); + return finishMake(mode, extraFlags, std::move(sqlDb)); +} + +SqliteDbResult SqliteDb::make(StringView name, SqliteOpenMode mode, int extraFlags) +{ + SqliteDb sqlDb{}; + auto nameResult{String::from(name)}; + if (nameResult.isError()) { + return SqliteDbResult::error(nameResult.takeError()); } - return SqliteDbResult::okay(std::move(sqlDb)); + sqlDb.m_name = nameResult.takeOkay(); + return finishMake(mode, extraFlags, std::move(sqlDb)); } SqliteDbResult SqliteDb::make(const char* cStrName, SqliteOpenMode mode, int extraFlags) { + SqliteDb sqlDb{}; auto nameResult = String::makeFromCString(cStrName); if (nameResult.isError()) { return SqliteDbResult::error(nameResult); } - SqliteDb sqlDb{}; sqlDb.m_name = nameResult.takeOkay(); + return finishMake(mode, extraFlags, std::move(sqlDb)); +} + +SqliteDbResult SqliteDb::finishMake(SqliteOpenMode& mode, int& extraFlags, SqliteDb&& sqlDb) +{ sqlDb.m_mode = mode; sqlDb.m_extraFlags = extraFlags; auto status = sqlDb.initialize(); -- cgit v1.2.3