|
cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
The Cutelyst Context. More...
#include <Cutelyst/Context>

Public Slots | |
| void | finalize () |
| finalize the request right away this is automatically called at the end of the actions chain | |
Public Member Functions | |
| Context (Application *app) | |
| Constructs a new DUMMY Context object that is child of Application This currently is experimental to allow non network events (such as database notification) to be able to use our infrastructure. | |
| Action * | action () const noexcept |
| QString | actionName () const noexcept |
| Application * | app () const noexcept |
| void | attachAsync () |
| attachAsync | |
| QVariantMap | config () const noexcept |
| QVariant | config (const QString &key, const QVariant &defaultValue={}) const |
| Controller * | controller () const noexcept |
| Controller * | controller (const QString &name) const |
| QString | controllerName () const |
| View * | customView () const noexcept |
| void | detach (Action *action=nullptr) |
| void | detachAsync () noexcept |
| bool | detached () const noexcept |
| Dispatcher * | dispatcher () const noexcept |
| Engine * | engine () const noexcept |
| bool | error () const noexcept |
| Returns true if an error was set. | |
| void | error (const QString &error) |
| Sets an error string and try to stop. | |
| QStringList | errors () const noexcept |
| Returns a list of errors that were defined. | |
| bool | execute (Component *code) |
| bool | forward (Component *component) |
| bool | forward (const QString &action) |
| Action * | getAction (const QString &action, const QString &ns={}) const |
| QVector< Action * > | getActions (const QString &action, const QString &ns={}) const |
| QLocale | locale () const noexcept |
| QString | ns () const noexcept |
| template<typename T> | |
| T | plugin () |
Returns the registered plugin that casts to the template type T. | |
| QVector< Plugin * > | plugins () const |
| QString | qtTrId (const char *id, int n=-1) const |
| Request * | req () const noexcept |
| Request * | request () const noexcept |
| Response * | res () const noexcept |
| Response * | response () const noexcept |
| bool | setCustomView (const QString &name) |
| void | setLocale (const QLocale &locale) |
| void | setStash (const QString &key, const ParamsMultiMap &map) |
| void | setStash (const QString &key, const QVariant &value) |
| void | setState (bool state) noexcept |
| Sets the state of the current executed action, setting to false will make the dispatcher skip non processed actions. | |
| QStack< Component * > | stack () const noexcept |
| QVariantHash & | stash () |
| QVariant | stash (const QString &key) const |
| QVariant | stash (const QString &key, const QVariant &defaultValue) const |
| void | stash (const QVariantHash &unite) |
| bool | stashRemove (const QString &key) |
| QVariant | stashTake (const QString &key) |
| bool | state () const noexcept |
| QString | translate (const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const |
| QUrl | uriFor (Action *action, const ParamsMultiMap &queryValues) const |
| QUrl | uriFor (Action *action, const QStringList &captures=QStringList(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const |
| QUrl | uriFor (const QString &path, const ParamsMultiMap &queryValues) const |
| QUrl | uriFor (const QString &path=QString(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const |
| QUrl | uriForAction (const QString &path, const ParamsMultiMap &queryValues) const |
| QUrl | uriForAction (const QString &path, const QStringList &captures=QStringList(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const |
| View * | view (const QString &name) const |
| View * | view (QStringView name={}) const |
| Public Member Functions inherited from QObject | |
| QObject (QObject *parent) | |
| bool | blockSignals (bool block) |
| const QObjectList & | children () const const |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
| void | deleteLater () |
| void | destroyed (QObject *obj) |
| bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
| bool | disconnect (const QObject *receiver, const char *method) const const |
| void | dumpObjectInfo () |
| void | dumpObjectInfo () const const |
| void | dumpObjectTree () |
| void | dumpObjectTree () const const |
| QList< QByteArray > | dynamicPropertyNames () const const |
| virtual bool | event (QEvent *e) |
| virtual bool | eventFilter (QObject *watched, QEvent *event) |
| T | findChild (const QString &name, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
| QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
| bool | inherits (const char *className) const const |
| void | installEventFilter (QObject *filterObj) |
| bool | isWidgetType () const const |
| bool | isWindowType () const const |
| void | killTimer (int id) |
| virtual const QMetaObject * | metaObject () const const |
| void | moveToThread (QThread *targetThread) |
| QString | objectName () const const |
| void | objectNameChanged (const QString &objectName, QPrivateSignal) |
| QObject * | parent () const const |
| QVariant | property (const char *name) const const |
| Q_CLASSINFO (Name, Value) | |
| Q_DISABLE_COPY (Class) | |
| Q_DISABLE_COPY_MOVE (Class) | |
| Q_DISABLE_MOVE (Class) | |
| Q_EMIT Q_EMIT | |
| Q_ENUM (...) | |
| Q_ENUM_NS (...) | |
| Q_ENUMS (...) | |
| Q_FLAG (...) | |
| Q_FLAG_NS (...) | |
| Q_FLAGS (...) | |
| Q_GADGET Q_GADGET | |
| Q_INTERFACES (...) | |
| Q_INVOKABLE Q_INVOKABLE | |
| Q_NAMESPACE Q_NAMESPACE | |
| Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
| Q_OBJECT Q_OBJECT | |
| Q_PROPERTY (...) | |
| Q_REVISION Q_REVISION | |
| Q_SET_OBJECT_NAME (Object) | |
| Q_SIGNAL Q_SIGNAL | |
| Q_SIGNALS Q_SIGNALS | |
| Q_SLOT Q_SLOT | |
| Q_SLOTS Q_SLOTS | |
| T | qFindChild (const QObject *obj, const QString &name) |
| QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
| QList< T > | qFindChildren (const QObject *obj, const QString &name) |
| T | qobject_cast (const QObject *object) |
| T | qobject_cast (QObject *object) |
| QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
| void | removeEventFilter (QObject *obj) |
| void | setObjectName (const QString &name) |
| void | setParent (QObject *parent) |
| bool | setProperty (const char *name, const QVariant &value) |
| bool | signalsBlocked () const const |
| int | startTimer (int interval, Qt::TimerType timerType) |
| int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
| QThread * | thread () const const |
Protected Member Functions | |
| Context (ContextPrivate *priv) | |
| Constructs a new Context object using private implementation. | |
| Protected Member Functions inherited from QObject | |
| virtual void | childEvent (QChildEvent *event) |
| virtual void | connectNotify (const QMetaMethod &signal) |
| virtual void | customEvent (QEvent *event) |
| virtual void | disconnectNotify (const QMetaMethod &signal) |
| bool | isSignalConnected (const QMetaMethod &signal) const const |
| int | receivers (const char *signal) const const |
| QObject * | sender () const const |
| int | senderSignalIndex () const const |
| virtual void | timerEvent (QTimerEvent *event) |
Properties | |
| Action * | action |
| QString | actionName |
| QVariantMap | config |
| Controller * | controller |
| QString | controllerName |
| QString | namespace |
| QString | ns |
| Request * | req |
| Request * | request |
| bool | state |
| Properties inherited from QObject | |
| objectName | |
Friends | |
| class | Action |
| class | ActionChain |
| class | Application |
| class | Async |
| class | Controller |
| class | DispatchType |
| class | Engine |
| class | Plugin |
Additional Inherited Members | |
| Static Public Member Functions inherited from QObject | |
| QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
| QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
| bool | disconnect (const QMetaObject::Connection &connection) |
| bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
| bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
| bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
| QString | tr (const char *sourceText, const char *disambiguation, int n) |
| QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
| Public Attributes inherited from QObject | |
| typedef | QObjectList |
| Context::Context | ( | Application * | app | ) |
Definition at line 29 of file context.cpp.
References app(), dispatcher(), engine(), plugins(), and QIODevice::ReadWrite.
Referenced by action(), actionName(), app(), attachAsync(), config(), config(), controller(), controller(), controllerName(), customView(), detach(), detachAsync(), detached(), dispatcher(), engine(), error(), error(), errors(), execute(), finalize(), forward(), forward(), getAction(), getActions(), locale(), ns(), plugins(), req(), request(), res(), response(), setCustomView(), setLocale(), setStash(), setStash(), setState(), stack(), stash(), stash(), stash(), stash(), stashRemove(), stashTake(), state(), translate(), uriFor(), uriFor(), uriFor(), uriForAction(), view(), and view().
|
virtual |
Definition at line 42 of file context.cpp.
|
protected |
Definition at line 24 of file context.cpp.
|
noexcept |
Returns a pointer to the current action
Definition at line 108 of file context.cpp.
References Context().
|
noexcept |
Returns the private name of the current action
Definition at line 114 of file context.cpp.
References Context().
|
noexcept |
Returns the application instance. See Cutelyst::Application
Definition at line 90 of file context.cpp.
References Context().
Referenced by Context().
| void Context::attachAsync | ( | ) |
The scoped
Reattaches to the remaining actions
Definition at line 361 of file context.cpp.
References Context(), execute(), finalize(), and QObject::Q_EMIT().
|
noexcept |
Returns a configuration mapping for all configuration read
Definition at line 484 of file context.cpp.
References Context().
Returns a configuration value for key with an optional default value
Definition at line 478 of file context.cpp.
References Context().
|
noexcept |
| Controller * Context::controller | ( | const QString & | name | ) | const |
Returns the controller by name, or nullptr if the controller is not found
Definition at line 156 of file context.cpp.
References Context().
| QString Cutelyst::Context::controllerName | ( | ) | const |
The current controller name
Definition at line 144 of file context.cpp.
References Context(), and QString::fromLatin1().
|
noexcept |
Returns the view set to be used for rendering this request, if one is set by setView() or nullptr if none was set
Definition at line 162 of file context.cpp.
References Context().
Referenced by Cutelyst::RenderView::doExecute().
| void Context::detach | ( | Action * | action = nullptr | ) |
The same as forward(action)
When called with no arguments it escapes the processing chain entirely.
Definition at line 345 of file context.cpp.
References Context().
Referenced by Cutelyst::RoleACL::aroundExecute(), Cutelyst::Action::doExecute(), Cutelyst::LangSelect::fromPath(), and Cutelyst::LangSelect::fromUrlQuery().
|
noexcept |
Detaches the processing chain telling the Engine that the request is not finished yet.
The scoped
It's often useful to call async API's, while convenient the use of QEventLoop will only work for the first request or lead to a crash due stacking of calls.
This method, tells the Engine that this request is not finished yet, making it return to the event loop to process other requests or the task that was created prior to calling this.
Once done call attachAsync() in order to process the remaining of the action chain.
Definition at line 355 of file context.cpp.
References Context().
|
noexcept |
Returns true if the last executed Action requested that the processing be escaped.
Definition at line 339 of file context.cpp.
References Context().
Referenced by Cutelyst::Action::doExecute().
|
noexcept |
Returns the dispatcher instance. See Cutelyst::Dispatcher
Definition at line 138 of file context.cpp.
References Context().
Referenced by Context().
|
noexcept |
Returns the engine instance. See Cutelyst::Engine
Definition at line 84 of file context.cpp.
References Context().
Referenced by Context().
|
noexcept |
Definition at line 49 of file context.cpp.
References Context().
Referenced by Cutelyst::Dispatcher::dispatch(), error(), execute(), Cutelyst::ClearSilver::render(), Cutelyst::CuteleeView::render(), Cutelyst::GrantleeView::render(), and Cutelyst::ViewEmail::render().
| void Context::error | ( | const QString & | error | ) |
Definition at line 55 of file context.cpp.
|
noexcept |
Definition at line 66 of file context.cpp.
References Context().
| bool Context::execute | ( | Component * | code | ) |
Execute an action. Errors are available via error().
Definition at line 429 of file context.cpp.
References Context(), QString::arg(), error(), Cutelyst::Component::execute(), QString::isEmpty(), Cutelyst::Component::name(), QString::number(), Cutelyst::Component::reverse(), and setState().
Referenced by attachAsync(), Cutelyst::Action::dispatch(), and Cutelyst::Dispatcher::forward().
|
slot |
Definition at line 499 of file context.cpp.
References Context(), QString::fromLatin1(), QString::number(), QString::size(), and QString::truncate().
Referenced by attachAsync().
| bool Context::forward | ( | Component * | component | ) |
This is one way of calling another action (method) in the same or a different controller. You can also use directly call another method to the same or a different controller.
The main difference is that 'forward' uses some of the Cutelyst request cycle overhead, including debugging, which may be useful to you. On the other hand, there are some complications to using 'forward', restrictions on values returned from 'forward', and it may not handle errors as you prefer. Whether you use 'forward' or not is up to you; it is not considered superior to the other ways to call a method.
forward calls Component::execute.
Keep in mind that the End() method used is that of the caller action. So a c->detach() inside a forwarded action would run the End() method from the original action requested.
Definition at line 399 of file context.cpp.
References Context().
Referenced by Cutelyst::RenderView::doExecute().
| bool Context::forward | ( | const QString & | action | ) |
This is one way of calling another action (method) in the same or a different controller. You can also use directly call another method to the same or a different controller.
The main difference is that 'forward' uses some of the Cutelyst request cycle overhead, including debugging, which may be useful to you. On the other hand, there are some complications to using 'forward', restrictions on values returned from 'forward', and it may not handle errors as you prefer. Whether you use 'forward' or not is up to you; it is not considered superior to the other ways to call a method.
forward calls another action, by its private name.
Keep in mind that the End() method used is that of the caller action. So a c->detach() inside a forwarded action would run the End() method from the original action requested.
Definition at line 405 of file context.cpp.
References Context().
Gets an action in a given namespace.
Definition at line 411 of file context.cpp.
References Context().
Gets all actions of a given name in a namespace and all parent namespaces.
Definition at line 417 of file context.cpp.
References Context().
|
noexcept |
Returns the current locale to be used when processing Views or translating user messages.
If not explicity set by setLocale it will use the QLocale::setDefault(), or QLocale::system() if not set.
Definition at line 466 of file context.cpp.
References Context().
Referenced by Cutelyst::LangSelect::fromPath(), Cutelyst::ValidatorAfter::genericValidationError(), Cutelyst::ValidatorBefore::genericValidationError(), Cutelyst::ValidatorBetween::genericValidationError(), Cutelyst::ValidatorIn::genericValidationError(), Cutelyst::ValidatorInteger::genericValidationError(), Cutelyst::ValidatorMax::genericValidationError(), Cutelyst::ValidatorMin::genericValidationError(), Cutelyst::ValidatorSize::genericValidationError(), Cutelyst::ValidatorFileSize::inputPattern(), Cutelyst::CuteleeView::render(), Cutelyst::GrantleeView::render(), setLocale(), Cutelyst::ValidatorBetween::validate(), Cutelyst::ValidatorFileSize::validate(), Cutelyst::ValidatorMax::validate(), Cutelyst::ValidatorMin::validate(), and Cutelyst::ValidatorSize::validate().
|
noexcept |
Returns the namespace of the current action. i.e. the URI prefix corresponding to the controller of the current action. For example: // a class named FooBar which inherits Controller c->ns(); // returns 'foo/bar'
Definition at line 120 of file context.cpp.
References Context().
|
inline |
| QVector< Cutelyst::Plugin * > Context::plugins | ( | ) | const |
|
inline |
Finds and returns a translated string.
Returns a translated string identified by id. If no matching string is found, the id itself is returned. This can be used similar to Qt’s global qtTrId() function.
If n >= 0, all occurences of %n in the resulting string are replaced with a decimal representation of n. In addition, appending n’s value, the translation may vary.
Meta data and comments can be passed as documented for QObject::tr(). In addition, it is possible to supply a source string template like that:
//% <C string>
or
\begincomment% <C string> \endcomment
Example:
Creating QM files suitable for use with this function requires passing the -idbased option to the lrelease tool.
Definition at line 588 of file context.h.
References qtTrId(), and translate().
Referenced by qtTrId().
|
noexcept |
|
noexcept |
Returns the current Request object containing information about the client request Request
Definition at line 126 of file context.cpp.
References Context().
|
noexcept |
Returns the current Cutelyst::Response object, see there for details.
Definition at line 102 of file context.cpp.
References Context().
Referenced by Cutelyst::RenderView::doExecute(), Cutelyst::LangSelect::fromPath(), Cutelyst::CuteleeView::render(), and Cutelyst::GrantleeView::render().
|
noexcept |
Returns the current Cutelyst::Response object, see there for details.
Definition at line 96 of file context.cpp.
References Context().
Referenced by Cutelyst::ViewJson::render().
| bool Context::setCustomView | ( | const QString & | name | ) |
Defines the view to be used to render the request, it must be previously be registered by Cutelyst::Application.
Action classes like RenderView will use this value to overwrite their settings.
Returns true if a view with the given name was found
Definition at line 180 of file context.cpp.
References Context().
| void Context::setLocale | ( | const QLocale & | locale | ) |
Defines the current locale to be used when processing Views or translating user messages.
Setting a locale on a web application can be done in many ways, so it's up to the developer to decide which one to use.
For example it's possible to try to guess the user locale with the request header Accept-Language, and or use the chained dispatcher to first match the locale as in "example.com/pt-br/some_action", and or store the locale into a cookie or session.
Be sure to set it as soon as possible so that all content can be properly localized.
Definition at line 472 of file context.cpp.
References Context(), and locale().
Referenced by Cutelyst::LangSelect::fromPath().
| void Context::setStash | ( | const QString & | key, |
| const ParamsMultiMap & | map ) |
A convenient method to set a single ParamsMultiMap to the stash
Definition at line 223 of file context.cpp.
References Context(), and QVariant::fromValue().
A convenient method to set a single value to the stash
Definition at line 217 of file context.cpp.
References Context().
Referenced by Cutelyst::MemcachedSessionStore::deleteSessionData(), Cutelyst::SessionStoreFile::deleteSessionData(), Cutelyst::Session::deleteValue(), Cutelyst::Session::deleteValues(), Cutelyst::CSRFProtection::getToken(), Cutelyst::ValidatorFileSize::inputPattern(), Cutelyst::StatusMessage::load(), Cutelyst::CuteleeView::render(), Cutelyst::GrantleeView::render(), Cutelyst::ViewEmailTemplate::render(), Cutelyst::Session::setValue(), Cutelyst::MemcachedSessionStore::storeSessionData(), Cutelyst::SessionStoreFile::storeSessionData(), and Cutelyst::Validator::validate().
|
noexcept |
Definition at line 78 of file context.cpp.
References Context().
Referenced by Cutelyst::Action::doExecute(), and execute().
Returns the internal execution stack (actions that are currently executing).
Definition at line 229 of file context.cpp.
References Context().
| QVariantHash & Context::stash | ( | ) |
Returns a QVariantHash reference to the stash, which may be used to store data and pass it between components during a request.
The stash is automatically sent to the view. The stash is cleared at the end of a request; it cannot be used for persistent storage (for this you must use a session; see Cutelyst::Plugin::Session for a complete system integrated with Cutelyst).
Definition at line 187 of file context.cpp.
References Context().
A convenient method to retrieve a single value from the stash
Definition at line 193 of file context.cpp.
References Context().
A convenient method to retrieve a single value with a default value from the stash
Definition at line 199 of file context.cpp.
References Context().
| void Context::stash | ( | const QVariantHash & | unite | ) |
You can set hash keys by passing arguments, that will be united with the stash, which may be used to store data and pass it between components during a request.
The stash is automatically sent to the view. The stash is cleared at the end of a request; it cannot be used for persistent storage (for this you must use a session; see Cutelyst::Plugin::Session for a complete system integrated with Cutelyst).
If a given key is present it will be replaced
Definition at line 566 of file context.cpp.
References Context().
Referenced by Cutelyst::CSRFProtection::checkPassed(), Cutelyst::ValidatorRule::defaultValue(), Cutelyst::Session::deleteReason(), Cutelyst::Session::deleteValue(), Cutelyst::Session::deleteValues(), Cutelyst::Session::expires(), Cutelyst::CSRFProtection::getToken(), Cutelyst::Session::id(), Cutelyst::ClearSilver::render(), Cutelyst::CuteleeView::render(), Cutelyst::GrantleeView::render(), Cutelyst::ViewEmail::render(), Cutelyst::ViewEmailTemplate::render(), Cutelyst::ViewJson::render(), Cutelyst::Session::setValue(), Cutelyst::Authentication::user(), Cutelyst::Authentication::userExists(), Cutelyst::Authentication::userInRealm(), Cutelyst::ValidatorIn::validate(), Cutelyst::ValidatorPwQuality::validate(), Cutelyst::ValidatorRequiredIfStash::validate(), Cutelyst::ValidatorRequiredUnlessStash::validate(), and Cutelyst::Session::value().
| bool Context::stashRemove | ( | const QString & | key | ) |
Removes the item that has the key from the stash. Returns true if any item was removed removed.
Definition at line 211 of file context.cpp.
References Context().
Removes the item with the key from the stash and returns the value associated with it. If the item does not exist in the stash, the function simply returns a default-constructed value. If you don't use the return value, stashRemove() is more efficient.
Definition at line 205 of file context.cpp.
References Context().
|
noexcept |
Contains the return value of the last executed action.
Definition at line 72 of file context.cpp.
References Context().
| QString Context::translate | ( | const char * | context, |
| const char * | sourceText, | ||
| const char * | disambiguation = nullptr, | ||
| int | n = -1 ) const |
Translates the sourceText for the given context into the language defined by locale().
See Application::addTranslator() for information about installation of translators. Internally this function will use QTranslator::translate().
Definition at line 490 of file context.cpp.
References Context().
Referenced by Cutelyst::ValidatorEmail::categoryString(), Cutelyst::ValidatorDomain::diagnoseString(), Cutelyst::ValidatorEmail::diagnoseString(), Cutelyst::Dispatcher::dispatch(), Cutelyst::Memcached::errorString(), Cutelyst::ValidatorPwQuality::errorString(), Cutelyst::ValidatorAfter::genericParsingError(), Cutelyst::ValidatorBefore::genericParsingError(), Cutelyst::ValidatorBetween::genericParsingError(), Cutelyst::ValidatorMax::genericParsingError(), Cutelyst::ValidatorMin::genericParsingError(), Cutelyst::ValidatorRule::genericParsingError(), Cutelyst::ValidatorSize::genericParsingError(), Cutelyst::ValidatorAfter::genericValidationDataError(), Cutelyst::ValidatorBefore::genericValidationDataError(), Cutelyst::ValidatorBetween::genericValidationDataError(), Cutelyst::ValidatorCharNotAllowed::genericValidationDataError(), Cutelyst::ValidatorFileSize::genericValidationDataError(), Cutelyst::ValidatorIn::genericValidationDataError(), Cutelyst::ValidatorMax::genericValidationDataError(), Cutelyst::ValidatorMin::genericValidationDataError(), Cutelyst::ValidatorNotIn::genericValidationDataError(), Cutelyst::ValidatorRule::genericValidationDataError(), Cutelyst::ValidatorSize::genericValidationDataError(), Cutelyst::ValidatorAccepted::genericValidationError(), Cutelyst::ValidatorAfter::genericValidationError(), Cutelyst::ValidatorAlpha::genericValidationError(), Cutelyst::ValidatorAlphaDash::genericValidationError(), Cutelyst::ValidatorAlphaNum::genericValidationError(), Cutelyst::ValidatorBefore::genericValidationError(), Cutelyst::ValidatorBetween::genericValidationError(), Cutelyst::ValidatorBoolean::genericValidationError(), Cutelyst::ValidatorCharNotAllowed::genericValidationError(), Cutelyst::ValidatorConfirmed::genericValidationError(), Cutelyst::ValidatorDate::genericValidationError(), Cutelyst::ValidatorDateTime::genericValidationError(), Cutelyst::ValidatorDifferent::genericValidationError(), Cutelyst::ValidatorDigits::genericValidationError(), Cutelyst::ValidatorDigitsBetween::genericValidationError(), Cutelyst::ValidatorFileSize::genericValidationError(), Cutelyst::ValidatorFilled::genericValidationError(), Cutelyst::ValidatorIn::genericValidationError(), Cutelyst::ValidatorInteger::genericValidationError(), Cutelyst::ValidatorIp::genericValidationError(), Cutelyst::ValidatorJson::genericValidationError(), Cutelyst::ValidatorMax::genericValidationError(), Cutelyst::ValidatorMin::genericValidationError(), Cutelyst::ValidatorNotIn::genericValidationError(), Cutelyst::ValidatorNumeric::genericValidationError(), Cutelyst::ValidatorPresent::genericValidationError(), Cutelyst::ValidatorRegularExpression::genericValidationError(), Cutelyst::ValidatorRequired::genericValidationError(), Cutelyst::ValidatorRequiredIf::genericValidationError(), Cutelyst::ValidatorRequiredIfStash::genericValidationError(), Cutelyst::ValidatorRequiredUnless::genericValidationError(), Cutelyst::ValidatorRequiredUnlessStash::genericValidationError(), Cutelyst::ValidatorRequiredWith::genericValidationError(), Cutelyst::ValidatorRequiredWithAll::genericValidationError(), Cutelyst::ValidatorRequiredWithout::genericValidationError(), Cutelyst::ValidatorRequiredWithoutAll::genericValidationError(), Cutelyst::ValidatorRule::genericValidationError(), Cutelyst::ValidatorSame::genericValidationError(), Cutelyst::ValidatorSize::genericValidationError(), Cutelyst::ValidatorTime::genericValidationError(), Cutelyst::ValidatorUrl::genericValidationError(), Cutelyst::ValidatorRule::label(), Cutelyst::ValidatorRule::parsingError(), qtTrId(), Cutelyst::CuteleeView::render(), Cutelyst::GrantleeView::render(), Cutelyst::ValidatorRule::validationDataError(), and Cutelyst::ValidatorRule::validationError().
|
inline |
| QUrl Context::uriFor | ( | Action * | action, |
| const QStringList & | captures = QStringList(), | ||
| const QStringList & | args = QStringList(), | ||
| const ParamsMultiMap & | queryValues = ParamsMultiMap() ) const |
Constructs an absolute QUrl object based on the application root, the provided path, and the additional arguments and query parameters provided. When used as a string, provides a textual URI.
If no arguments are provided, the URI for the current action is returned. To return the current action and also provide args, use c->uriFor(c->action(), args).
Definition at line 283 of file context.cpp.
References Context(), QList::append(), QString::isEmpty(), Cutelyst::Action::numberOfCaptures(), QList::size(), QList::takeFirst(), and uriFor().
|
inline |
Constructs an absolute QUrl object based on the application root, the provided path, and the additional arguments and query parameters provided. When used as a string, provides a textual URI.
The first argument is taken as a public URI path relative c->ns (if it doesn't begin with a forward slash) or relative to the application root (if it does). It is then merged with c->request()->base() and any queryValues> are appended as "?foo=bar" parameters.
| QUrl Context::uriFor | ( | const QString & | path = QString(), |
| const QStringList & | args = QStringList(), | ||
| const ParamsMultiMap & | queryValues = ParamsMultiMap() ) const |
Constructs an absolute QUrl object based on the application root, the provided path, and the additional arguments and query parameters provided. When used as a string, provides a textual URI.
The first argument is taken as a public URI path relative c->ns (if it doesn't begin with a forward slash) or relative to the application root (if it does). It is then merged with c->request()->base() any args are appended as additional path components; and any queryValues> are appended as "?foo=bar" parameters.
Definition at line 235 of file context.cpp.
References Context(), QUrlQuery::addQueryItem(), QString::compare(), QUrl::DecodedMode, QList::isEmpty(), QString::isEmpty(), QStringList::join(), QString::prepend(), QUrl::setPath(), QUrl::setQuery(), and QString::startsWith().
Referenced by uriFor(), uriFor(), uriFor(), and uriForAction().
|
inline |
A convenience method for the uriForAction() without the arguments parameter
Definition at line 583 of file context.h.
References uriForAction().
| QUrl Context::uriForAction | ( | const QString & | path, |
| const QStringList & | captures = QStringList(), | ||
| const QStringList & | args = QStringList(), | ||
| const ParamsMultiMap & | queryValues = ParamsMultiMap() ) const |
A private path to the Cutelyst action you want to create a URI for.
This is a shortcut for calling c->dispatcher()->getActionByPath(path) and passing the resulting action and the remaining arguments to c->uri_for.
Note that although the path looks like a URI that dispatches to the wanted action, it is not a URI, but an internal path to that action.
For example, if the action looks like:
You can use: c->uriForAction('/users/lst'); and it will create the URI /users/the-list.
Definition at line 321 of file context.cpp.
References Context(), and uriFor().
Referenced by uriForAction().
Returns the view with name name or nullptr if not found
Definition at line 168 of file context.cpp.
References Context().
| View * Context::view | ( | QStringView | name = {} | ) | const |
Returns the view with name name or nullptr if not found
Definition at line 174 of file context.cpp.
References Context().