|
@@ -33,7 +33,7 @@ void FortuneTest::fortunes_raw_p(Context *c)
|
|
fortunes.emplace_back(Fortune{it[0].toInt(), it[1].toString()});
|
|
fortunes.emplace_back(Fortune{it[0].toInt(), it[1].toString()});
|
|
++it;
|
|
++it;
|
|
}
|
|
}
|
|
- fortunes.emplace_back(Fortune{0, QStringLiteral("Additional fortune added at request time.")});
|
|
|
|
|
|
+ fortunes.emplace_back(Fortune{0, u"Additional fortune added at request time."_qs});
|
|
|
|
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const Fortune &a1, const Fortune &a2) {
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const Fortune &a1, const Fortune &a2) {
|
|
return a1.message < a2.message;
|
|
return a1.message < a2.message;
|
|
@@ -46,8 +46,8 @@ void FortuneTest::fortunes_raw_p(Context *c)
|
|
void FortuneTest::fortunes_raw_postgres(Context *c)
|
|
void FortuneTest::fortunes_raw_postgres(Context *c)
|
|
{
|
|
{
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
- QLatin1String("SELECT id, message FROM fortune"),
|
|
|
|
- QStringLiteral("postgres"));
|
|
|
|
|
|
+ u"SELECT id, message FROM fortune"_qs,
|
|
|
|
+ u"postgres"_qs);
|
|
auto fortunes = processQuery(c, query);
|
|
auto fortunes = processQuery(c, query);
|
|
renderRaw(c, fortunes);
|
|
renderRaw(c, fortunes);
|
|
}
|
|
}
|
|
@@ -55,8 +55,8 @@ void FortuneTest::fortunes_raw_postgres(Context *c)
|
|
void FortuneTest::fortunes_raw_mysql(Context *c)
|
|
void FortuneTest::fortunes_raw_mysql(Context *c)
|
|
{
|
|
{
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
- QLatin1String("SELECT id, message FROM fortune"),
|
|
|
|
- QStringLiteral("mysql"));
|
|
|
|
|
|
+ u"SELECT id, message FROM fortune"_qs,
|
|
|
|
+ u"mysql"_qs);
|
|
auto fortunes = processQuery(c, query);
|
|
auto fortunes = processQuery(c, query);
|
|
renderRaw(c, fortunes);
|
|
renderRaw(c, fortunes);
|
|
}
|
|
}
|
|
@@ -82,59 +82,59 @@ void FortuneTest::fortunes_c_p(Context *c)
|
|
}
|
|
}
|
|
|
|
|
|
fortunes.append(QVariant::fromValue(QVariantList{
|
|
fortunes.append(QVariant::fromValue(QVariantList{
|
|
- {0, QStringLiteral("Additional fortune added at request time.")},
|
|
|
|
|
|
+ {0, u"Additional fortune added at request time."_qs},
|
|
}));
|
|
}));
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) {
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) {
|
|
return a1.toList()[1].toString() < a2.toList()[1].toString();
|
|
return a1.toList()[1].toString() < a2.toList()[1].toString();
|
|
});
|
|
});
|
|
|
|
|
|
- c->setStash(QStringLiteral("template"), QStringLiteral("fortunes.html"));
|
|
|
|
- c->setStash(QStringLiteral("fortunes"), fortunes);
|
|
|
|
|
|
+ c->setStash(u"template"_qs, u"fortunes.html"_qs);
|
|
|
|
+ c->setStash(u"fortunes"_qs, fortunes);
|
|
static thread_local View *view = c->view();
|
|
static thread_local View *view = c->view();
|
|
view->execute(c);
|
|
view->execute(c);
|
|
- c->response()->setContentType(QStringLiteral("text/html; charset=UTF-8"));
|
|
|
|
|
|
+ c->response()->setContentType("text/html; charset=UTF-8"_qba);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
void FortuneTest::fortunes_cutelee_postgres(Context *c)
|
|
void FortuneTest::fortunes_cutelee_postgres(Context *c)
|
|
{
|
|
{
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
- QLatin1String("SELECT id, message FROM fortune"),
|
|
|
|
- QStringLiteral("postgres"));
|
|
|
|
|
|
+ u"SELECT id, message FROM fortune"_qs,
|
|
|
|
+ u"postgres"_qs);
|
|
if (query.exec()) {
|
|
if (query.exec()) {
|
|
QVariantList fortunes = Sql::queryToList(query);
|
|
QVariantList fortunes = Sql::queryToList(query);
|
|
fortunes.append(QVariant::fromValue(QVariantList{
|
|
fortunes.append(QVariant::fromValue(QVariantList{
|
|
- {0, QStringLiteral("Additional fortune added at request time.")},
|
|
|
|
|
|
+ {0, u"Additional fortune added at request time."_qs},
|
|
}));
|
|
}));
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) {
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) {
|
|
return a1.toList()[1].toString() < a2.toList()[1].toString();
|
|
return a1.toList()[1].toString() < a2.toList()[1].toString();
|
|
});
|
|
});
|
|
- c->setStash(QStringLiteral("template"), QStringLiteral("fortunes.html"));
|
|
|
|
- c->setStash(QStringLiteral("fortunes"), fortunes);
|
|
|
|
|
|
+ c->setStash(u"template"_qs, u"fortunes.html"_qs);
|
|
|
|
+ c->setStash(u"fortunes"_qs, fortunes);
|
|
static thread_local View *view = c->view();
|
|
static thread_local View *view = c->view();
|
|
view->execute(c);
|
|
view->execute(c);
|
|
- c->response()->setContentType(QStringLiteral("text/html; charset=UTF-8"));
|
|
|
|
|
|
+ c->response()->setContentType("text/html; charset=UTF-8"_qba);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void FortuneTest::fortunes_cutelee_mysql(Context *c)
|
|
void FortuneTest::fortunes_cutelee_mysql(Context *c)
|
|
{
|
|
{
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
QSqlQuery query = CPreparedSqlQueryThreadForDB(
|
|
- QLatin1String("SELECT id, message FROM fortune"),
|
|
|
|
- QStringLiteral("mysql"));
|
|
|
|
|
|
+ u"SELECT id, message FROM fortune"_qs,
|
|
|
|
+ u"mysql"_qs);
|
|
if (query.exec()) {
|
|
if (query.exec()) {
|
|
QVariantList fortunes = Sql::queryToList(query);
|
|
QVariantList fortunes = Sql::queryToList(query);
|
|
fortunes.append(QVariant::fromValue(QVariantList{
|
|
fortunes.append(QVariant::fromValue(QVariantList{
|
|
- {0, QStringLiteral("Additional fortune added at request time.")},
|
|
|
|
|
|
+ {0, u"Additional fortune added at request time."_qs},
|
|
}));
|
|
}));
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) {
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const QVariant &a1, const QVariant &a2) {
|
|
return a1.toList()[1].toString() < a2.toList()[1].toString();
|
|
return a1.toList()[1].toString() < a2.toList()[1].toString();
|
|
});
|
|
});
|
|
- c->setStash(QStringLiteral("template"), QStringLiteral("fortunes.html"));
|
|
|
|
- c->setStash(QStringLiteral("fortunes"), fortunes);
|
|
|
|
|
|
+ c->setStash(u"template"_qs, u"fortunes.html"_qs);
|
|
|
|
+ c->setStash(u"fortunes"_qs, fortunes);
|
|
static thread_local View *view = c->view();
|
|
static thread_local View *view = c->view();
|
|
view->execute(c);
|
|
view->execute(c);
|
|
- c->response()->setContentType(QStringLiteral("text/html; charset=UTF-8"));
|
|
|
|
|
|
+ c->response()->setContentType("text/html; charset=UTF-8"_qba);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -151,7 +151,7 @@ FortuneList FortuneTest::processQuery(Context *c, QSqlQuery &query)
|
|
while (query.next()) {
|
|
while (query.next()) {
|
|
fortunes.push_back({query.value(0).toInt(), query.value(1).toString()});
|
|
fortunes.push_back({query.value(0).toInt(), query.value(1).toString()});
|
|
}
|
|
}
|
|
- fortunes.push_back({0, QStringLiteral("Additional fortune added at request time.")});
|
|
|
|
|
|
+ fortunes.push_back({0, u"Additional fortune added at request time."_qs});
|
|
|
|
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const Fortune &a1, const Fortune &a2) {
|
|
std::sort(fortunes.begin(), fortunes.end(), [] (const Fortune &a1, const Fortune &a2) {
|
|
return a1.message < a2.message;
|
|
return a1.message < a2.message;
|
|
@@ -183,5 +183,5 @@ void FortuneTest::renderRaw(Context *c, const FortuneList &fortunes) const
|
|
|
|
|
|
auto response = c->response();
|
|
auto response = c->response();
|
|
response->setBody(out);
|
|
response->setBody(out);
|
|
- response->setContentType(QStringLiteral("text/html; charset=UTF-8"));
|
|
|
|
|
|
+ response->setContentType("text/html; charset=UTF-8"_qba);
|
|
}
|
|
}
|