Cutelee  6.1.0
Public Member Functions | List of all members
Cutelee::InMemoryTemplateLoader Class Reference

The InMemoryTemplateLoader loads Templates set dynamically in memory. More...

#include <cutelee/templateloader.h>

Inheritance diagram for Cutelee::InMemoryTemplateLoader:
Inheritance graph
[legend]

Public Member Functions

bool canLoadTemplate (const QString &name) const override
 
std::pair< QString, QStringgetMediaUri (const QString &fileName) const override
 
Template loadByName (const QString &name, Engine const *engine) const override
 
void setTemplate (const QString &name, const QString &content)
 
- Public Member Functions inherited from Cutelee::AbstractTemplateLoader
virtual ~AbstractTemplateLoader ()
 

Detailed Description

This class is mostly used for testing purposes, but can also be used for simple uses of Cutelee.

Templates can be made available using the setTemplate method, and will then be retrieved by the Cutelee::Engine as appropriate.

Definition at line 193 of file templateloader.h.

Member Function Documentation

◆ canLoadTemplate()

bool InMemoryTemplateLoader::canLoadTemplate ( const QString name) const
overridevirtual

Return true if a Template identified by name exists and can be loaded.

Implements Cutelee::AbstractTemplateLoader.

Definition at line 203 of file templateloader.cpp.

◆ getMediaUri()

std::pair< QString, QString > InMemoryTemplateLoader::getMediaUri ( const QString fileName) const
overridevirtual

Return a complete URI for media identified by fileName.

Implements Cutelee::AbstractTemplateLoader.

Reimplemented in FakeTemplateLoader.

Definition at line 222 of file templateloader.cpp.

◆ loadByName()

Template InMemoryTemplateLoader::loadByName ( const QString name,
Engine const *  engine 
) const
overridevirtual

Load a Template called name. Return an invalid Template if no content by that name exists.

Implements Cutelee::AbstractTemplateLoader.

Definition at line 208 of file templateloader.cpp.

References Cutelee::Engine::newTemplate().

◆ setTemplate()

void InMemoryTemplateLoader::setTemplate ( const QString name,
const QString content 
)

Add a template content to this Loader.

Example:

auto loader = std::shared_ptr<InMemoryTemplateLoader::create();
loader->setTemplate( "name_template", "My name is {{ name }}" );
loader->setTemplate( "age_template", "My age is {{ age }}" );
engine->addTemplateLoader( loader );
// Both templates may now be retrieved by calling Engine::loadByName.

Definition at line 197 of file templateloader.cpp.