Skip to content

Commit 0abea3f

Browse files
feature c++20
1 parent fea0455 commit 0abea3f

File tree

115 files changed

+802
-715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+802
-715
lines changed

src/corelib.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ lessThan(QT_MAJOR_VERSION, 6) {
77
CONFIG += c++14
88
windows:QMAKE_CXXFLAGS += /std:c++14
99
} else {
10-
CONFIG += c++17
11-
windows:QMAKE_CXXFLAGS += /Zc:__cplusplus /std:c++17 /permissive-
10+
CONFIG += c++20
11+
windows:QMAKE_CXXFLAGS += /Zc:__cplusplus /std:c++20 /permissive-
1212
}
1313

1414
DEFINES *= QT_USE_QSTRINGBUILDER

src/tabstractcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TAbstractController::TAbstractController() :
3030
void TAbstractController::exportVariant(const QString &name, const QVariant &value, bool overwrite)
3131
{
3232
if (!value.isValid()) {
33-
tSystemWarn("An invalid QVariant object for exportVariant(), name:%s", qUtf8Printable(name));
33+
tSystemWarn("An invalid QVariant object for exportVariant(), name:{}", qUtf8Printable(name));
3434
return;
3535
}
3636

src/tabstractwebsocket.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TAbstractWebSocket::TAbstractWebSocket(const THttpRequestHeader &header) :
3535
TAbstractWebSocket::~TAbstractWebSocket()
3636
{
3737
if (!closing.load()) {
38-
tSystemWarn("Logic warning [%s:%d]", __FILE__, __LINE__);
38+
tSystemWarn("Logic warning [{}:{}]", __FILE__, __LINE__);
3939
}
4040

4141
delete keepAliveTimer;
@@ -167,7 +167,7 @@ bool TAbstractWebSocket::searchEndpoint(const THttpRequestHeader &header)
167167

168168
int TAbstractWebSocket::parse(QByteArray &recvData)
169169
{
170-
tSystemDebug("parse enter data len:%lld sid:%lld", (int64_t)recvData.length(), socketDescriptor());
170+
tSystemDebug("parse enter data len:{} sid:{}", (int64_t)recvData.length(), socketDescriptor());
171171
if (websocketFrames().isEmpty()) {
172172
websocketFrames().append(TWebSocketFrame());
173173
} else {
@@ -214,7 +214,7 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
214214
}
215215
dshdr >> w;
216216
if (Q_UNLIKELY(w < 126)) {
217-
tSystemError("WebSocket protocol error [%s:%d]", __FILE__, __LINE__);
217+
tSystemError("WebSocket protocol error [{}:{}]", __FILE__, __LINE__);
218218
return -1;
219219
}
220220
pfrm->setPayloadLength(w);
@@ -226,7 +226,7 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
226226
}
227227
dshdr >> d;
228228
if (Q_UNLIKELY(d <= 0xFFFF)) {
229-
tSystemError("WebSocket protocol error [%s:%d]", __FILE__, __LINE__);
229+
tSystemError("WebSocket protocol error [{}:{}]", __FILE__, __LINE__);
230230
return -1;
231231
}
232232
pfrm->setPayloadLength(d);
@@ -251,15 +251,15 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
251251
} else {
252252
pfrm->setState(TWebSocketFrame::HeaderParsed);
253253
if (pfrm->payloadLength() >= 2 * 1024 * 1024 * 1024ULL) {
254-
tSystemError("Too big frame [%s:%d]", __FILE__, __LINE__);
254+
tSystemError("Too big frame [{}:{}]", __FILE__, __LINE__);
255255
pfrm->clear();
256256
} else {
257257
pfrm->payload().reserve(pfrm->payloadLength());
258258
}
259259
}
260260

261-
tSystemDebug("WebSocket parse header pos: %lld", devhdr->pos());
262-
tSystemDebug("WebSocket payload length:%lld", pfrm->payloadLength());
261+
tSystemDebug("WebSocket parse header pos: {}", devhdr->pos());
262+
tSystemDebug("WebSocket payload length:{}", pfrm->payloadLength());
263263

264264
int hdrlen = hdr.length() - devhdr->bytesAvailable();
265265
ds.skipRawData(hdrlen); // Forwards the pos
@@ -268,8 +268,8 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
268268

269269
case TWebSocketFrame::HeaderParsed: // fall through
270270
case TWebSocketFrame::MoreData: {
271-
tSystemDebug("WebSocket reading payload: available length:%lld", dev->bytesAvailable());
272-
tSystemDebug("WebSocket parsing length to read:%llu current buf len:%lld", pfrm->payloadLength(), (int64_t)pfrm->payload().size());
271+
tSystemDebug("WebSocket reading payload: available length:{}", dev->bytesAvailable());
272+
tSystemDebug("WebSocket parsing length to read:{} current buf len:{}", pfrm->payloadLength(), (int64_t)pfrm->payload().size());
273273
uint64_t size = std::min((uint64_t)(pfrm->payloadLength() - pfrm->payload().size()), (uint64_t)dev->bytesAvailable());
274274
if (Q_UNLIKELY(size == 0)) {
275275
Q_ASSERT(0);
@@ -293,14 +293,14 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
293293
}
294294
}
295295
pfrm->payload().resize(pfrm->payload().size() + size);
296-
tSystemDebug("WebSocket payload curent buf len: %lld", (int64_t)pfrm->payload().length());
296+
tSystemDebug("WebSocket payload curent buf len: {}", (int64_t)pfrm->payload().length());
297297

298298
if ((uint64_t)pfrm->payload().size() == pfrm->payloadLength()) {
299299
pfrm->setState(TWebSocketFrame::Completed);
300-
tSystemDebug("Parse Completed payload len: %lld", (int64_t)pfrm->payload().size());
300+
tSystemDebug("Parse Completed payload len: {}", (int64_t)pfrm->payload().size());
301301
} else {
302302
pfrm->setState(TWebSocketFrame::MoreData);
303-
tSystemDebug("Parse MoreData payload len: %lld", (int64_t)pfrm->payload().size());
303+
tSystemDebug("Parse MoreData payload len: {}", (int64_t)pfrm->payload().size());
304304
}
305305
break;
306306
}
@@ -323,7 +323,7 @@ int TAbstractWebSocket::parse(QByteArray &recvData)
323323
const TWebSocketFrame &before = websocketFrames()[websocketFrames().count() - 2];
324324
if (before.isFinalFrame() || before.isControlFrame()) {
325325
pfrm->clear();
326-
tSystemWarn("Invalid continuation frame detected [%s:%d]", __FILE__, __LINE__);
326+
tSystemWarn("Invalid continuation frame detected [{}:{}]", __FILE__, __LINE__);
327327
continue;
328328
}
329329
}

src/taccesslog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ QByteArray TAccessLog::toByteArray(const QByteArray &layout, const QByteArray &d
5959
message.append(remoteHost);
6060
break;
6161

62-
case 'd': // %d : timestamp
62+
case 'd': // timestamp
6363
if (!dateTimeFormat.isEmpty()) {
6464
message.append(timestamp.toString(dateTimeFormat).toLocal8Bit());
6565
} else {

src/taccessvalidator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool TAccessValidator::validate(const TAbstractUser *user, const TActionControll
149149
Q_ASSERT(controller);
150150

151151
if (accessRules.isEmpty()) {
152-
tWarn("No rule for access validation: %s", qUtf8Printable(controller->className()));
152+
Tf::warn("No rule for access validation: {}", qUtf8Printable(controller->className()));
153153
return ret;
154154
}
155155

@@ -163,9 +163,9 @@ bool TAccessValidator::validate(const TAbstractUser *user, const TActionControll
163163
}
164164
}
165165
if (ret) {
166-
tSystemDebug("Access '%s' action by an unauthenticated user : Allow", qUtf8Printable(controller->activeAction()));
166+
tSystemDebug("Access '{}' action by an unauthenticated user : Allow", qUtf8Printable(controller->activeAction()));
167167
} else {
168-
tSystemWarn("Access '%s' action by an unauthenticated user : Deny", qUtf8Printable(controller->activeAction()));
168+
tSystemWarn("Access '{}' action by an unauthenticated user : Deny", qUtf8Printable(controller->activeAction()));
169169
}
170170

171171
} else {
@@ -178,9 +178,9 @@ bool TAccessValidator::validate(const TAbstractUser *user, const TActionControll
178178
}
179179
}
180180
if (ret) {
181-
tSystemDebug("Access '%s' action by '%s' user : Allow", qUtf8Printable(controller->activeAction()), qUtf8Printable(user->identityKey()));
181+
tSystemDebug("Access '{}' action by '{}' user : Allow", qUtf8Printable(controller->activeAction()), qUtf8Printable(user->identityKey()));
182182
} else {
183-
tSystemWarn("Access '%s' action by '%s' user : Deny", qUtf8Printable(controller->activeAction()), qUtf8Printable(user->identityKey()));
183+
tSystemWarn("Access '{}' action by '{}' user : Deny", qUtf8Printable(controller->activeAction()), qUtf8Printable(user->identityKey()));
184184
}
185185
}
186186

src/tactioncontext.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ void TActionContext::execute(THttpRequest &request)
7979
accessLogger.startElapsedTimer();
8080
}
8181

82-
tSystemDebug("method : %s", reqHeader.method().data());
83-
tSystemDebug("path : %s", reqHeader.path().data());
82+
tSystemDebug("method : {}", reqHeader.method().data());
83+
tSystemDebug("path : {}", reqHeader.path().data());
8484

8585
// HTTP method
8686
Tf::HttpMethod method = _httpRequest->method();
@@ -94,7 +94,7 @@ void TActionContext::execute(THttpRequest &request)
9494
QStringList components = TUrlRoute::splitPath(path);
9595
TRouting route = TUrlRoute::instance().findRouting(method, components);
9696

97-
tSystemDebug("Routing: controller:%s action:%s", route.controller.data(),
97+
tSystemDebug("Routing: controller:{} action:{}", route.controller.data(),
9898
route.action.data());
9999

100100
if (!route.exists) {
@@ -112,7 +112,7 @@ void TActionContext::execute(THttpRequest &request)
112112
route.setRouting(c + QByteArrayLiteral("controller"), action, components.mid(2));
113113
}
114114
}
115-
tSystemDebug("Active Controller : %s", route.controller.data());
115+
tSystemDebug("Active Controller : {}", route.controller.data());
116116
}
117117
}
118118

@@ -152,7 +152,7 @@ void TActionContext::execute(THttpRequest &request)
152152
TSessionManager::instance().remove(_currController->session().sessionId); // Removes the old session
153153
// Re-generate session ID
154154
_currController->session().sessionId = TSessionManager::instance().generateId();
155-
tSystemDebug("Re-generate session ID: %s", _currController->session().sessionId.data());
155+
tSystemDebug("Re-generate session ID: {}", _currController->session().sessionId.data());
156156
}
157157

158158
if (EnableCsrfProtectionModuleFlag && _currController->csrfProtectionEnabled()) {
@@ -199,7 +199,7 @@ void TActionContext::execute(THttpRequest &request)
199199
QString canonicalPath = QUrl(QStringLiteral(".")).resolved(QUrl(path)).toString().mid(1);
200200
QFile reqPath(Tf::app()->publicPath() + canonicalPath);
201201
QFileInfo fi(reqPath);
202-
tSystemDebug("canonicalPath : %s", qUtf8Printable(canonicalPath));
202+
tSystemDebug("canonicalPath : {}", qUtf8Printable(canonicalPath));
203203

204204
if (fi.isFile() && fi.isReadable()) {
205205
// Check "If-Modified-Since" header for caching
@@ -244,20 +244,20 @@ void TActionContext::execute(THttpRequest &request)
244244
}
245245

246246
} catch (ClientErrorException &e) {
247-
tWarn("Caught %s: status code:%d", qUtf8Printable(e.className()), e.statusCode());
248-
tSystemWarn("Caught %s: status code:%d", qUtf8Printable(e.className()), e.statusCode());
247+
Tf::warn("Caught {}: status code:{}", qUtf8Printable(e.className()), e.statusCode());
248+
tSystemWarn("Caught {}: status code:{}", qUtf8Printable(e.className()), e.statusCode());
249249
int responseBytes = writeResponse(e.statusCode(), responseHeader);
250250
accessLogger.setResponseBytes(responseBytes);
251251
accessLogger.setStatusCode(e.statusCode());
252252
} catch (TfException &e) {
253-
tError("Caught %s: %s [%s:%d]", qUtf8Printable(e.className()), qUtf8Printable(e.message()), qUtf8Printable(e.fileName()), e.lineNumber());
254-
tSystemError("Caught %s: %s [%s:%d]", qUtf8Printable(e.className()), qUtf8Printable(e.message()), qUtf8Printable(e.fileName()), e.lineNumber());
253+
Tf::error("Caught {}: {} [{}:{}]", qUtf8Printable(e.className()), qUtf8Printable(e.message()), qUtf8Printable(e.fileName()), e.lineNumber());
254+
tSystemError("Caught {}: {} [{}:{}]", qUtf8Printable(e.className()), qUtf8Printable(e.message()), qUtf8Printable(e.fileName()), e.lineNumber());
255255
closeSocket();
256256
accessLogger.setResponseBytes(0);
257257
accessLogger.setStatusCode(Tf::InternalServerError);
258258
} catch (std::exception &e) {
259-
tError("Caught Exception: %s", e.what());
260-
tSystemError("Caught Exception: %s", e.what());
259+
Tf::error("Caught Exception: {}", e.what());
260+
tSystemError("Caught Exception: {}", e.what());
261261
closeSocket();
262262
accessLogger.setResponseBytes(0);
263263
accessLogger.setStatusCode(Tf::InternalServerError);
@@ -374,7 +374,7 @@ void TActionContext::flushResponse(TActionController *controller, bool immediate
374374
} break;
375375

376376
default:
377-
tSystemError("Invalid logic [%s:%d]", __FILE__, __LINE__);
377+
tSystemError("Invalid logic [{}:{}]", __FILE__, __LINE__);
378378
break;
379379
}
380380
}
@@ -463,7 +463,7 @@ int64_t TActionContext::writeResponse(THttpResponseHeader &header, QIODevice *bo
463463
{
464464

465465
header.setContentLength(length);
466-
tSystemDebug("content-length: %lld", (int64_t)header.contentLength());
466+
tSystemDebug("content-length: {}", (int64_t)header.contentLength());
467467
header.setRawHeader(QByteArrayLiteral("Server"), QByteArrayLiteral("TreeFrog server"));
468468
header.setCurrentDate();
469469

0 commit comments

Comments
 (0)