16 for (
int i = 0; i < columnsSize.
size(); ++i) {
37 for (
const QString &header : headers) {
42 if (columnsSize.
empty()) {
43 for (
const QString &row : rows) {
46 }
else if (rows.size() != columnsSize.
size()) {
47 qFatal(
"Incomplete table");
53 if (row.size() > columnsSize.
size()) {
54 qFatal(
"Incomplete table");
58 for (
int i = 0; i < row.size(); ++i) {
59 columnsSize[i] = qMax(columnsSize[i], row[i].size());
67 QByteArray div = buildTableDivision(columnsSize);
76 if (!headers.isEmpty()) {
78 for (
int i = 0; i < headers.size(); ++i) {
81 out.setFieldWidth(columnsSize[i]);
95 for (
int i = 0; i < row.size(); ++i) {
98 out.setFieldWidth(columnsSize[i]);
101 out.setFieldWidth(0);
121 char *data = ba.
data();
122 const char *inputPtr = data;
124 const int len = ba.
length();
125 bool skipUtf8 =
true;
127 for (
int i = 0; i < len; ++i, ++outlen) {
128 const char c = inputPtr[i];
129 if (c ==
'%' && i + 2 < len) {
130 int a = inputPtr[++i];
131 int b = inputPtr[++i];
133 if (a >=
'0' && a <=
'9')
135 else if (a >=
'a' && a <=
'f')
137 else if (a >=
'A' && a <=
'F')
140 if (b >=
'0' && b <=
'9')
142 else if (b >=
'a' && b <=
'f')
144 else if (b >=
'A' && b <=
'F')
147 *data++ = (char) ((a << 4) | b);
149 }
else if (c ==
'+') {
172 const char *inputPtr = data;
175 bool skipUtf8 =
true;
178 auto processKeyPair = [&] {
180 if ((data - from) == 0) {
189 }
else if ((data - from) > 0) {
196 for (
int i = 0; i < len; ++i) {
197 const char c = inputPtr[i];
198 if (c ==
'%' && i + 2 < len) {
199 int a = inputPtr[++i];
200 int b = inputPtr[++i];
202 if (a >=
'0' && a <=
'9')
204 else if (a >=
'a' && a <=
'f')
206 else if (a >=
'A' && a <=
'F')
209 if (b >=
'0' && b <=
'9')
211 else if (b >=
'a' && b <=
'f')
213 else if (b >=
'A' && b <=
'F')
216 *data++ = (char) ((a << 4) | b);
218 }
else if (c ==
'+') {
220 }
else if (c ==
'=') {
222 :
QString::fromUtf8(from, data - from);
226 }
else if (c ==
'&') {
248 char *data = ba->
data();
249 const char *inputPtr = data;
252 bool skipUtf8 =
true;
254 for (
int i = 0; i < len; ++i, ++outlen) {
255 const char c = inputPtr[i];
256 if (c ==
'%' && i + 2 < len) {
257 int a = inputPtr[++i];
258 int b = inputPtr[++i];
260 if (a >=
'0' && a <=
'9')
262 else if (a >=
'a' && a <=
'f')
264 else if (a >=
'A' && a <=
'F')
267 if (b >=
'0' && b <=
'9')
269 else if (b >=
'a' && b <=
'f')
271 else if (b >=
'A' && b <=
'F')
274 *data++ = (char) ((a << 4) | b);
276 }
else if (c ==
'+') {
297 for (
const QChar ch : str) {
298 if (ch >= u
'0' && ch <= u
'9') {
316 }
else if ((ch >= u
'a' && ch <= u
'z') || ch == u
'M') {
340 return std::chrono::microseconds::zero();
351 return std::chrono::microseconds::zero();
354 std::chrono::microseconds ms = std::chrono::microseconds::zero();
356 for (
const std::pair<QString, QString> &p : parts) {
358 const qulonglong dur = p.first.toULongLong(&_ok);
364 if (p.second == u
"usec" || p.second == u
"us") {
365 ms += std::chrono::microseconds{dur};
366 }
else if (p.second == u
"msec" || p.second == u
"ms") {
367 ms += std::chrono::milliseconds{dur};
368 }
else if (p.second == u
"seconds" || p.second == u
"second" || p.second == u
"sec" ||
369 p.second == u
"s" || p.second.isEmpty()) {
370 ms += std::chrono::seconds{dur};
371 }
else if (p.second == u
"minutes" || p.second == u
"minute" || p.second == u
"min" ||
373 ms += std::chrono::minutes{dur};
374 }
else if (p.second == u
"hours" || p.second == u
"hour" || p.second == u
"hr" ||
376 ms += std::chrono::hours{dur};
377 }
else if (p.second == u
"days" || p.second == u
"day" || p.second == u
"d") {
378 ms += std::chrono::days{dur};
379 }
else if (p.second == u
"weeks" || p.second == u
"week" || p.second == u
"w") {
380 ms += std::chrono::weeks{dur};
381 }
else if (p.second == u
"months" || p.second == u
"month" || p.second == u
"M") {
382 ms += std::chrono::months{dur};
383 }
else if (p.second == u
"years" || p.second == u
"year" || p.second == u
"y") {
384 ms += std::chrono::years{dur};
395 return std::chrono::microseconds::zero();
QMultiMap< QString, QString > ParamsMultiMap
CUTELYST_EXPORT std::chrono::microseconds durationFromString(QStringView str, bool *ok=nullptr)
The Cutelyst namespace holds all public Cutelyst API.
QByteArray & fill(char ch, qsizetype size)
bool isEmpty() const const
qsizetype length() const const
QList< T >::reference emplace_back(Args &&... args)
bool isEmpty() const const
void push_back(QList< T >::parameter_type value)
qsizetype size() const const
QMultiMap< Key, T >::iterator insert(QMultiMap< Key, T >::const_iterator pos, const Key &key, const T &value)
QString & append(QChar ch)
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
bool isEmpty() const const
QByteArray toLatin1() const const