6 #include "controller.h" 7 #include "dispatchtypepath_p.h" 12 #include <QRegularExpression> 19 , d_ptr(new DispatchTypePathPrivate)
36 auto keys = d->paths.keys();
40 for (
const auto &path : std::as_const(keys)) {
41 const auto paths = d->paths.
value(path);
42 for (
Action *action : paths.actions) {
51 _path.
replace(multipleSlashes, u
"/"_s);
58 table.
append({_path, privateName});
62 return Utils::buildTable(table,
67 u
"Loaded Path actions:"_s);
75 auto it = d->paths.constFind(path);
76 if (it == d->paths.constEnd()) {
81 int numberOfArgs = args.
size();
82 for (
Action *action : it->actions) {
111 const auto range = attributes.
equal_range(u
"Path"_s);
112 for (
auto i = range.first; i != range.second; ++i) {
113 if (d->registerPath(*i, action)) {
125 return !d->paths.isEmpty();
133 auto it = attributes.
constFind(u
"Path"_s);
134 if (it != attributes.constEnd()) {
135 const QString &path = it.value();
148 bool DispatchTypePathPrivate::registerPath(
const QString &path,
Action *action)
158 auto it = paths.find(_path);
159 if (it != paths.end()) {
161 auto &actions = it->actions;
162 bool conflict = std::ranges::any_of(actions, [&](
const Action *regAction) {
164 qCCritical(CUTELYST_DISPATCHER_PATH)
165 <<
"Not registering Action" << action->
name() <<
"of controller" 167 << regAction->
name() <<
"of controller" 177 actions.push_back(action);
178 std::ranges::sort(actions, [](
const Action *a,
const Action *b) ->
bool {
183 DispatchTypePathReplacement{
191 #include "moc_dispatchtypepath.cpp" Controller * controller() const noexcept
ParamsMultiMap attributes() const noexcept
QString & append(QChar ch)
const_iterator constFind(const Key &key) const const
DispatchTypePath(QObject *parent=nullptr)
QString & prepend(QChar ch)
bool registerAction(Action *action) override
void setupMatchedAction(Context *c, Action *action) const
void setMatch(const QString &match)
QString reverse() const noexcept
qsizetype size() const const
This class represents a Cutelyst Action.
T value(qsizetype i) const const
QPair< iterator, iterator > equal_range(const Key &key)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
bool isEmpty() const const
QString name() const noexcept
The Cutelyst namespace holds all public Cutelyst API.
void setArguments(const QStringList &arguments)
Describes a path dispatch type.
QByteArray list() const override
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
int compare(QChar ch) const const
void append(QList< T > &&value)
Abstract class to described a dispatch type.
QString uriForAction(Action *action, const QStringList &captures) const override
~DispatchTypePath() override
virtual qint8 numberOfArgs() const
QString attribute(const QString &name, const QString &defaultValue={}) const
MatchType match(Context *c, QStringView path, const QStringList &args) const override