Cutelyst  1.11.0
Public Member Functions | List of all members
Cutelyst::View Class Referenceabstract

Cutelyst View abstract view component More...

#include <Cutelyst/View>

Inheritance diagram for Cutelyst::View:
Inheritance graph
[legend]

Public Member Functions

 View (QObject *parent, const QString &name=QString())
 
virtual Modifiers modifiers () const override
 
QString name () const
 
virtual QByteArray render (Context *c) const =0
 
- Public Member Functions inherited from Cutelyst::Component
 Component (QObject *parent=nullptr)
 
bool execute (Context *c)
 
virtual bool init (Application *application, const QVariantHash &args)
 
QString name () const
 
QString reverse () const
 
void setName (const QString &name)
 
void setReverse (const QString &reverse)
 

Additional Inherited Members

- Public Types inherited from Cutelyst::Component
enum  Modifier {
  None, OnlyExecute, BeforeExecute, AroundExecute,
  AfterExecute
}
 
- Protected Member Functions inherited from Cutelyst::Component
virtual bool afterExecute (Context *c)
 
void applyRoles (const QStack< Component * > &roles)
 
virtual bool aroundExecute (Context *c, QStack< Component * > stack)
 
virtual bool beforeExecute (Context *c)
 
virtual bool dispatcherReady (const Dispatcher *dispatch, Controller *controller)
 

Detailed Description

Definition at line 33 of file view.h.

Constructor & Destructor Documentation

View::View ( QObject *  parent,
const QString &  name = QString() 
)
explicit

The base implementation for a View class, a name for the view should be set to be found by Context->view()

Definition at line 31 of file view.cpp.

References Cutelyst::Component::setName().

Member Function Documentation

Component::Modifiers View::modifiers ( ) const
overridevirtual

The default implementation returns Component::OnlyExecute

Reimplemented from Cutelyst::Component.

Definition at line 45 of file view.cpp.

References Cutelyst::Context::error(), Cutelyst::Context::errors(), Cutelyst::Response::hasBody(), render(), Cutelyst::Context::response(), and Cutelyst::Response::setBody().

QString View::name ( ) const
virtual QByteArray Cutelyst::View::render ( Context c) const
pure virtual

All subclasses must reimplement this when doing it's rendering. If an error (c->error()) is not set c->response()->body() is defined with the returned value, this is useful if the view is not meant to be used as a body.

Implemented in Cutelyst::ViewEmail, Cutelyst::ViewJson, Cutelyst::GrantleeView, Cutelyst::ClearSilver, and Cutelyst::ViewEmailTemplate.

Referenced by modifiers(), and Cutelyst::ViewEmailTemplate::setDefaultView().