cutelyst  4.5.1
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_EXPORT QByteArray buildTable (const QVector< QStringList > &table, const QStringList &headers={}, const QString &title={})
 
CUTELYST_EXPORT ParamsMultiMap decodePercentEncoding (char *data, int len)
 
CUTELYST_EXPORT QString decodePercentEncoding (QByteArray *ba)
 
CUTELYST_EXPORT QString decodePercentEncoding (QString *s)
 
CUTELYST_EXPORT 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

◆ 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().