8#include <Cutelyst/Context>
9#include <Cutelyst/ParamsMultiMap>
10#include <cutelee/exception.h>
11#include <cutelee/parser.h>
16 : Cutelee::Node(parser)
17 , m_path(path, parser)
19 bool foundQuery =
false;
20 for (
const QString &expression : args) {
22 if (expression.compare(u
"QUERY") == 0) {
28 m_queryExpressions.push_back(Cutelee::FilterExpression(expression, parser));
30 m_argsExpressions.push_back(Cutelee::FilterExpression(expression, parser));
33 std::reverse(m_queryExpressions.begin(), m_queryExpressions.end());
36std::pair<QString, QString> splitQuery(
const QString &query)
38 std::pair<QString, QString> ret;
46void UriFor::render(Cutelee::OutputStream *stream, Cutelee::Context *gc)
const
51 const QVariantHash hash = gc->stackHash(0);
52 auto it = hash.constBegin();
53 while (it != hash.constEnd()) {
54 if (it.value().userType() == qMetaTypeId<Cutelyst::Context *>()) {
57 m_cutelystContext = it.key();
73 QVariant pathVar = m_path.resolve(gc);
74 if (pathVar.
userType() == qMetaTypeId<Cutelee::SafeString>()) {
75 path = pathVar.
value<Cutelee::SafeString>().
get();
79 qWarning() <<
"c_uri_for PATH is not a valid type";
83 for (
const Cutelee::FilterExpression &exp : m_argsExpressions) {
85 if (var.
userType() == qMetaTypeId<Cutelee::SafeString>()) {
86 args << var.
value<Cutelee::SafeString>().
get();
94 for (
const Cutelee::FilterExpression &exp : m_queryExpressions) {
96 if (var.
userType() == qMetaTypeId<Cutelyst::ParamsMultiMap>()) {
98 queryValues.
unite(map);
99 }
else if (var.
userType() == qMetaTypeId<Cutelee::SafeString>()) {
100 auto query = splitQuery(var.
value<Cutelee::SafeString>().get());
103 auto query = splitQuery(var.
toString());
107 for (
const QString &str : queries) {
108 auto query = splitQuery(str);
117Cutelee::Node *UriForTag::getNode(
const QString &tagContent, Cutelee::Parser *p)
const
124 throw Cutelee::Exception(Cutelee::TagSyntaxError,
125 QStringLiteral(
"c_uri_for requires at least the path"));
128 return new UriFor(parts.
first(), parts.
mid(1), p);
131#include "moc_urifor.cpp"
CUTELYST_PLUGIN_USERAGENT_EXPORT QNetworkReply * get(const QNetworkRequest &request)
bool isEmpty() const const
QList< T > mid(qsizetype pos, qsizetype length) const const
QMultiMap::iterator insert(QMultiMap::const_iterator pos, const Key &key, const T &value)
QMultiMap< Key, T > & unite(QMultiMap< Key, T > &&other)
QString first(qsizetype n) const const
QString section(QChar sep, qsizetype start, qsizetype end, QString::SectionFlags flags) const const
QString toString() const const
QStringList toStringList() const const
int userType() const const