summaryrefslogtreecommitdiff
path: root/source/fud_sqlite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/fud_sqlite.cpp')
-rw-r--r--source/fud_sqlite.cpp24
1 files changed, 17 insertions, 7 deletions
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();