KTextTemplate Namespace
Header: | #include <KTextTemplate/Util> |
CMake: | find_package(KF6 REQUIRED COMPONENTS TextTemplate) target_link_libraries(mytarget PRIVATE KF6::TextTemplate) |
Classes
class | AbstractLocalizer |
class | AbstractNodeFactory |
class | AbstractTemplateLoader |
class | CachingLoaderDecorator |
class | Context |
class | Engine |
class | Exception |
class | FileSystemTemplateLoader |
class | Filter |
class | FilterExpression |
class | InMemoryTemplateLoader |
class | MetaType |
class | Node |
class | NodeList |
class | OutputStream |
class | Parser |
class | QtLocalizer |
class | RenderContext |
class | SafeString |
class | TagLibraryInterface |
class | TemplateImpl |
class | Variable |
Types
enum | Error { NoError, EmptyVariableError, EmptyBlockTagError, InvalidBlockTagError, UnclosedBlockTagError, …, CompileFunctionError } |
Template |
Functions
std::pair<qreal, QString> | calcFileSize(qreal size, int unitSystem = 10, qreal multiplier = 1.0) |
bool | equals(const QVariant &lhs, const QVariant &rhs) |
KTextTemplate::SafeString | getSafeString(const QVariant &input) |
bool | isSafeString(const QVariant &input) |
KTextTemplate::SafeString | markForEscaping(const KTextTemplate::SafeString &input) |
KTextTemplate::SafeString | markSafe(const KTextTemplate::SafeString &input) |
int | registerMetaType() |
bool | supportedOutputType(const QVariant &input) |
QString | unescapeStringLiteral(const QString &input) |
bool | variantIsTrue(const QVariant &variant) |
Detailed Description
Classes
class AbstractLocalizer
Interface for implementing an internationalization system. More...
class AbstractNodeFactory
Base class for all NodeFactories. More...
class AbstractTemplateLoader
An retrieval interface to a storage location for Template objects. More...
class CachingLoaderDecorator
Implements a loader decorator which caches compiled Template objects. More...
class Context
The Context class holds the context to render a Template with. More...
class Engine
KTextTemplate::Engine is the main entry point for creating KTextTemplate Templates. More...
class Exception
An exception for use when implementing template tags. More...
class FileSystemTemplateLoader
The FileSystemTemplateLoader loads Templates from the file system. More...
class Filter
Base class for all filters. More...
class FilterExpression
A FilterExpression object represents a filter expression in a template. More...
class InMemoryTemplateLoader
The InMemoryTemplateLoader loads Templates set dynamically in memory. More...
class MetaType
The MetaType is the interface to the KTextTemplate introspection system. More...
class Node
Base class for all nodes. More...
class NodeList
A list of Nodes with some convenience API for rendering them. More...
class OutputStream
The OutputStream class is used to render templates to a QTextStream. More...
class Parser
The Parser class processes a string template into a tree of nodes. More...
class QtLocalizer
Provides internationalization based on QLocale and QTranslator. More...
class RenderContext
Provides storage facility for state while rendering a template. More...
class SafeString
A QString wrapper class for containing whether a string is safe or needs to be escaped. More...
class TagLibraryInterface
The TagLibraryInterface returns available tags and filters from libraries. More...
class TemplateImpl
The Template class is a tree of nodes which may be rendered. More...
class Variable
A container for static variables defined in Templates. More...
Type Documentation
enum KTextTemplate::Error
Types of errors that can occur while using KTextTemplate
Constant | Value |
---|---|
KTextTemplate::NoError | 0 |
KTextTemplate::EmptyVariableError | 1 |
KTextTemplate::EmptyBlockTagError | 2 |
KTextTemplate::InvalidBlockTagError | 3 |
KTextTemplate::UnclosedBlockTagError | 4 |
KTextTemplate::UnknownFilterError | 5 |
KTextTemplate::TagSyntaxError | 6 |
KTextTemplate::VariableNotInContext | 7 |
KTextTemplate::ObjectReturnTypeInvalid | 8 |
KTextTemplate::CompileFunctionError | 9 |
Template
Function Documentation
std::pair<qreal, QString> KTextTemplate::calcFileSize(qreal size, int unitSystem = 10, qreal multiplier = 1.0)
Converts size into the nearest file size unit like MB or MiB, based on the unitSystem value. Use 2
for the unitSystem to get binary units, use 10
to get decimal units - by default, decimal units will be returned. The multiplier can be used if the input size is not in pure bytes. If size is for example given in KiB, use a multiplier of 1024. The returned pair will have the converted size as first and the unit as second.
bool KTextTemplate::equals(const QVariant &lhs, const QVariant &rhs)
Compares lhs and rhs for equality. SafeStrings are compared as raw QStrings. Their safeness is not part of the comparison.
KTextTemplate::SafeString KTextTemplate::getSafeString(const QVariant &input)
Retrieves and returns a SafeString from the input.
bool KTextTemplate::isSafeString(const QVariant &input)
Returns whether input contains a SafeString.
KTextTemplate::SafeString KTextTemplate::markForEscaping(const KTextTemplate::SafeString &input)
Marks the input as requiring escaping.
KTextTemplate::SafeString KTextTemplate::markSafe(const KTextTemplate::SafeString &input)
Marks the input as safe.
template <typename RealType, typename HandleAs> int registerMetaType()
Registers the type RealType with the metatype system.
This method can take a second template parameter to specify a cast that should be invoked during registration. This is useful if a base type is already supported.
class SomeType { public: QString someProp() const; }; // define some introspectable API for SomeType KTEXTTEMPLATE_BEGIN_LOOKUP(SomeType) if (property == "someProp") return object.someProp(); KTEXTTEMPLATE_END_LOOKUP class OtherType : public SomeType { // ... }; registerMetaType<SomeType>(); // Only the introspectable API from SomeType is needed, so we can reuse that registration. registerMetaType<OtherType, SomeType>();
bool KTextTemplate::supportedOutputType(const QVariant &input)
Returns true if the type of input can be inserted into a rendered template directly.
Note that lists, hashes and QObject*s can not be.
QString KTextTemplate::unescapeStringLiteral(const QString &input)
Converts the input into its unescaped form.
Double slashes are converted to single slashes, \" is converted to " etc.
bool KTextTemplate::variantIsTrue(const QVariant &variant)
Returns whether the variant is evaluated to true.