cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst::Utils Namespace Reference

Helper functions used all over Cutelyst. More...

Functions

CUTELYST_LIBRARY QByteArray buildTable (const QVector< QStringList > &table, const QStringList &headers={}, const QString &title={})
 
CUTELYST_LIBRARY ParamsMultiMap decodePercentEncoding (char *data, int len)
 
CUTELYST_LIBRARY QString decodePercentEncoding (QByteArray *ba)
 
CUTELYST_LIBRARY QString decodePercentEncoding (QString *s)
 
CUTELYST_LIBRARY std::chrono::microseconds durationFromString (QStringView str, bool *ok=nullptr)
 

Detailed Description

Helper functions used all over Cutelyst.

Include statement
#include <Cutelyst/utils.h>

Function Documentation

◆ buildTable()

QByteArray Cutelyst::Utils::buildTable ( const QVector< QStringList > &  table,
const QStringList headers = {},
const QString title = {} 
)

Definition at line 29 of file utils.cpp.

◆ decodePercentEncoding() [1/3]

ParamsMultiMap Cutelyst::Utils::decodePercentEncoding ( char *  data,
int  len 
)

Definition at line 163 of file utils.cpp.

◆ decodePercentEncoding() [2/3]

QString Cutelyst::Utils::decodePercentEncoding ( QByteArray ba)

Definition at line 243 of file utils.cpp.

◆ decodePercentEncoding() [3/3]

QString Cutelyst::Utils::decodePercentEncoding ( QString s)

Definition at line 113 of file utils.cpp.

◆ durationFromString()

std::chrono::microseconds Cutelyst::Utils::durationFromString ( QStringView  str,
bool *  ok = nullptr 
)

Reads a time span from str and parses it into a duration value.

The following time units are understood:

  • usec, us
  • msec, ms
  • seconds, second, sec, s
  • minutes, minute, min, m
  • hours, hour, hr, h
  • days, day, d
  • weeks, week, w
  • months, month, M
  • years, year, y

If no time unit is specified, seconds are assumed.

Examples for valid time span specifications:

  • 2 h
  • 2hours
  • 48hr
  • 1y 12month
  • 55s500ms
  • 300ms20s 5day

If ok is not nullptr, failure is reported by setting *ok to false, and success by setting *ok to true.

Definition at line 291 of file utils.cpp.

References QString::append(), QString::clear(), QList::emplace_back(), QList::empty(), and QString::isEmpty().

Referenced by Cutelyst::Session::setup(), Cutelyst::CSRFProtection::setup(), and Cutelyst::LangSelect::setup().