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);
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.
count();
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;
179 auto processKeyPair = [&] {
181 if ((data - from) == 0) {
188 :
QString::fromUtf8(from, data - from));
190 }
else if ((data - from) > 0) {
192 :
QString::fromUtf8(from, data - from),
197 for (
int i = 0; i < len; ++i, ++outlen) {
198 const char c = inputPtr[i];
199 if (c ==
'%' && i + 2 < len) {
200 int a = inputPtr[++i];
201 int b = inputPtr[++i];
203 if (a >=
'0' && a <=
'9')
205 else if (a >=
'a' && a <=
'f')
207 else if (a >=
'A' && a <=
'F')
210 if (b >=
'0' && b <=
'9')
212 else if (b >=
'a' && b <=
'f')
214 else if (b >=
'A' && b <=
'F')
217 *data++ = (char) ((a << 4) | b);
219 }
else if (c ==
'+') {
221 }
else if (c ==
'=') {
223 :
QString::fromUtf8(from, data - from);
227 }
else if (c ==
'&') {
249 char *data = ba->
data();
250 const char *inputPtr = data;
252 int len = ba->
count();
253 bool skipUtf8 =
true;
255 for (
int i = 0; i < len; ++i, ++outlen) {
256 const char c = inputPtr[i];
257 if (c ==
'%' && i + 2 < len) {
258 int a = inputPtr[++i];
259 int b = inputPtr[++i];
261 if (a >=
'0' && a <=
'9')
263 else if (a >=
'a' && a <=
'f')
265 else if (a >=
'A' && a <=
'F')
268 if (b >=
'0' && b <=
'9')
270 else if (b >=
'a' && b <=
'f')
272 else if (b >=
'A' && b <=
'F')
275 *data++ = (char) ((a << 4) | b);
277 }
else if (c ==
'+') {
298 for (
const QChar ch : str) {
299 if (ch >= u
'0' && ch <= u
'9') {
317 }
else if ((ch >= u
'a' && ch <= u
'z') || ch == u
'M') {
341 return std::chrono::microseconds::zero();
352 return std::chrono::microseconds::zero();
355 std::chrono::microseconds ms = std::chrono::microseconds::zero();
357 for (
const std::pair<QString, QString> &p : parts) {
359 const qulonglong dur = p.first.toULongLong(&_ok);
365 if (p.second == u
"usec" || p.second == u
"us") {
366 ms += std::chrono::microseconds{dur};
367 }
else if (p.second == u
"msec" || p.second == u
"ms") {
368 ms += std::chrono::milliseconds{dur};
369 }
else if (p.second == u
"seconds" || p.second == u
"second" || p.second == u
"sec" ||
370 p.second == u
"s" || p.second.isEmpty()) {
371 ms += std::chrono::seconds{dur};
372 }
else if (p.second == u
"minutes" || p.second == u
"minute" || p.second == u
"min" ||
374 ms += std::chrono::minutes{dur};
375 }
else if (p.second == u
"hours" || p.second == u
"hour" || p.second == u
"hr" ||
377 ms += std::chrono::hours{dur};
378 }
else if (p.second == u
"days" || p.second == u
"day" || p.second == u
"d") {
379 ms += std::chrono::days{dur};
380 }
else if (p.second == u
"weeks" || p.second == u
"week" || p.second == u
"w") {
381 ms += std::chrono::weeks{dur};
382 }
else if (p.second == u
"months" || p.second == u
"month" || p.second == u
"M") {
383 ms += std::chrono::months{dur};
384 }
else if (p.second == u
"years" || p.second == u
"year" || p.second == u
"y") {
385 ms += std::chrono::years{dur};
396 return std::chrono::microseconds::zero();
CUTELYST_LIBRARY std::chrono::microseconds durationFromString(QStringView str, bool *ok=nullptr)
The Cutelyst namespace holds all public Cutelyst API.
qsizetype count() const const
QByteArray & fill(char ch, qsizetype size)
bool isEmpty() const const
QList::reference emplace_back(Args &&... args)
bool isEmpty() const const
void push_back(QList::parameter_type value)
qsizetype size() const const
QMultiMap::iterator insert(QMultiMap::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