Utils: Remove std::initializer_list contructor

If you write

Utils::SmallStringView view;
Utils::SmallString text{view};

it selects the std::initializer_list contructor. Not the didicated
constructore. It is much to easy to get it wrong so it is better
to make it explicit.

Change-Id: I4240eaf1f39cf71d37df4480fea1ecfa3ea83cb0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2021-05-19 18:50:51 +02:00
parent 7b330d3496
commit 8603eb5ba9
15 changed files with 52 additions and 57 deletions

View File

@@ -248,9 +248,8 @@ void CreateTableSqlStatementBuilder::bindColumnDefinitionsAndTableConstraints()
columnDefinitionStrings.reserve(m_columns.size());
for (const Column &column : m_columns) {
Utils::SmallString columnDefinitionString = {column.name,
SqlStatementBuilder::columnTypeToString(
column.type)};
auto columnDefinitionString = Utils::SmallString::join(
{column.name, SqlStatementBuilder::columnTypeToString(column.type)});
ContraintsVisiter visiter{columnDefinitionString};

View File

@@ -129,7 +129,7 @@ sqlite3 *DatabaseBackend::sqliteDatabaseHandle() const
void DatabaseBackend::setPragmaValue(Utils::SmallStringView pragmaKey, Utils::SmallStringView newPragmaValue)
{
ReadWriteStatement<1>{Utils::SmallString{"PRAGMA ", pragmaKey, "='", newPragmaValue, "'"},
ReadWriteStatement<1>{Utils::SmallString::join({"PRAGMA ", pragmaKey, "='", newPragmaValue, "'"}),
m_database}
.execute();
Utils::SmallString pragmeValueInDatabase = toValue<Utils::SmallString>("PRAGMA " + pragmaKey);

View File

@@ -57,18 +57,17 @@ public:
checkTableName();
checkColumns();
return {"CREATE ",
m_indexType == IndexType::Unique ? "UNIQUE " : "",
"INDEX IF NOT EXISTS index_",
m_tableName,
"_",
m_columnNames.join("_"),
" ON ",
m_tableName,
"(",
m_columnNames.join(", "),
")"
};
return Utils::SmallString::join({"CREATE ",
m_indexType == IndexType::Unique ? "UNIQUE " : "",
"INDEX IF NOT EXISTS index_",
m_tableName,
"_",
m_columnNames.join("_"),
" ON ",
m_tableName,
"(",
m_columnNames.join(", "),
")"});
}
void checkTableName() const

View File

@@ -127,9 +127,9 @@ void Internal::SessionsBase::createSessionTable(Database &database)
void Sessions::revert()
{
ReadStatement<1> selectChangeSets{Utils::PathString{"SELECT changeset FROM ",
sessionsTableName,
" ORDER BY id DESC"},
ReadStatement<1> selectChangeSets{Utils::PathString::join({"SELECT changeset FROM ",
sessionsTableName,
" ORDER BY id DESC"}),
database};
auto changeSets = selectChangeSets.values<SessionChangeSet>(1024);
@@ -151,9 +151,9 @@ void Sessions::revert()
void Sessions::apply()
{
ReadStatement<1> selectChangeSets{Utils::PathString{"SELECT changeset FROM ",
sessionsTableName,
" ORDER BY id"},
ReadStatement<1> selectChangeSets{Utils::PathString::join({"SELECT changeset FROM ",
sessionsTableName,
" ORDER BY id"}),
database};
auto changeSets = selectChangeSets.values<SessionChangeSet>(1024);
@@ -182,14 +182,14 @@ void Sessions::applyAndUpdateSessions()
void Sessions::deleteAll()
{
WriteStatement{Utils::SmallString{"DELETE FROM ", sessionsTableName}, database}.execute();
WriteStatement{Utils::SmallString::join({"DELETE FROM ", sessionsTableName}), database}.execute();
}
SessionChangeSets Sessions::changeSets() const
{
ReadStatement<1> selectChangeSets{Utils::PathString{"SELECT changeset FROM ",
sessionsTableName,
" ORDER BY id DESC"},
ReadStatement<1> selectChangeSets{Utils::PathString::join({"SELECT changeset FROM ",
sessionsTableName,
" ORDER BY id DESC"}),
database};
return selectChangeSets.values<SessionChangeSet>(1024);

View File

@@ -62,9 +62,8 @@ public:
Utils::SmallStringView sessionsTableName)
: SessionsBase(database, sessionsTableName)
, database(database)
, insertSession{Utils::PathString{"INSERT INTO ",
sessionsTableName,
"(changeset) VALUES(?)"},
, insertSession{Utils::PathString::join(
{"INSERT INTO ", sessionsTableName, "(changeset) VALUES(?)"}),
database}
, databaseName(databaseName)
, session{nullptr, sqlite3session_delete}