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 for (
const auto &[key, value] : hash.asKeyValueRange()) {
53 if (value.userType() == qMetaTypeId<Cutelyst::Context *>()) {
56 m_cutelystContext = key;
71 QVariant pathVar = m_path.resolve(gc);
72 if (pathVar.
userType() == qMetaTypeId<Cutelee::SafeString>()) {
73 path = pathVar.
value<Cutelee::SafeString>().
get();
77 qWarning() <<
"c_uri_for PATH is not a valid type";
81 for (
const Cutelee::FilterExpression &exp : m_argsExpressions) {
83 if (var.
userType() == qMetaTypeId<Cutelee::SafeString>()) {
84 args << var.
value<Cutelee::SafeString>().
get();
92 for (
const Cutelee::FilterExpression &exp : m_queryExpressions) {
94 if (var.
userType() == qMetaTypeId<Cutelyst::ParamsMultiMap>()) {
96 queryValues.
unite(map);
97 }
else if (var.
userType() == qMetaTypeId<Cutelee::SafeString>()) {
98 auto query = splitQuery(var.
value<Cutelee::SafeString>().get());
101 auto query = splitQuery(var.
toString());
105 for (
const QString &str : queries) {
106 auto query = splitQuery(str);
115Cutelee::Node *UriForTag::getNode(
const QString &tagContent, Cutelee::Parser *p)
const
122 throw Cutelee::Exception(Cutelee::TagSyntaxError,
123 QStringLiteral(
"c_uri_for requires at least the path"));
126 return new UriFor(parts.
first(), parts.
mid(1), p);
129#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