KTextTemplate

KTextTemplate Namespace Reference

Classes

class  AbstractLocalizer
 
class  AbstractNodeFactory
 
class  AbstractTemplateLoader
 
class  CachingLoaderDecorator
 
class  Context
 
class  Engine
 
class  Exception
 
class  FileSystemTemplateLoader
 
class  Filter
 
class  FilterExpression
 
class  InMemoryTemplateLoader
 
class  Node
 
class  NodeList
 
class  OutputStream
 
class  Parser
 
class  QtLocalizer
 
class  RenderContext
 
class  SafeString
 
class  TagLibraryInterface
 
class  Template
 
struct  Token
 
class  Variable
 

Enumerations

enum  Error {
  NoError, EmptyVariableError, EmptyBlockTagError, InvalidBlockTagError,
  UnclosedBlockTagError, UnknownFilterError, TagSyntaxError, VariableNotInContext,
  ObjectReturnTypeInvalid, CompileFunctionError
}
 
enum  TokenType { TextToken, VariableToken, BlockToken, CommentToken }
 

Functions

std::pair< qreal, QStringcalcFileSize (qreal size, int unitSystem=10, qreal multiplier=1.0)
 
bool equals (const QVariant &lhs, const QVariant &rhs)
 
static QRegularExpression getIsTitleRE ()
 
KTextTemplate::SafeString getSafeString (const QVariant &input)
 
static QRegularExpression getTitleRE ()
 
bool isSafeString (const QVariant &input)
 
KTextTemplate::SafeString markForEscaping (const KTextTemplate::SafeString &input)
 
KTextTemplate::SafeString markSafe (const KTextTemplate::SafeString &input)
 
template<typename RealType , typename HandleAs >
int registerMetaType ()
 
bool supportedOutputType (const QVariant &input)
 
QString unescapeStringLiteral (const QString &input)
 
bool variantIsTrue (const QVariant &variant)
 

Detailed Description

The KTextTemplate namespace holds all public KTextTemplate API.

Enumeration Type Documentation

◆ Error

Types of errors that can occur while using KTextTemplate.

Definition at line 36 of file exception.h.

◆ TokenType

The available token types.

Enumerator
TextToken 

The Token is a text fragment.

VariableToken 

The Token is a variable node.

BlockToken 

The Token is a block, ie, part of a tag.

CommentToken 

The Token is a comment node.

Definition at line 34 of file token.h.

Function Documentation

◆ calcFileSize()

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.

Definition at line 161 of file util.cpp.

◆ equals()

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.

See also
QVariant::operator==

Definition at line 130 of file util.cpp.

◆ getSafeString()

KTextTemplate::SafeString KTextTemplate::getSafeString ( const QVariant input)

Retrieves and returns a SafeString from the input.

Definition at line 102 of file util.cpp.

◆ isSafeString()

bool KTextTemplate::isSafeString ( const QVariant input)

Returns whether input contains a SafeString.

Definition at line 110 of file util.cpp.

◆ markForEscaping()

KTextTemplate::SafeString KTextTemplate::markForEscaping ( const KTextTemplate::SafeString input)

Marks the input as requiring escaping.

Definition at line 92 of file util.cpp.

◆ markSafe()

KTextTemplate::SafeString KTextTemplate::markSafe ( const KTextTemplate::SafeString input)

Marks the input as safe.

Definition at line 85 of file util.cpp.

◆ registerMetaType()

template<typename RealType , typename HandleAs >
int KTextTemplate::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
if (property == "someProp")
return object.someProp();
class OtherType : public SomeType
{
// ...
};
registerMetaType<SomeType>();
// Only the introspectable API from SomeType is needed, so we can reuse that
registration.
registerMetaType<OtherType, SomeType>();
See also
Generic type and template support

Definition at line 184 of file metatype.h.

◆ supportedOutputType()

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.

Definition at line 124 of file util.cpp.

◆ unescapeStringLiteral()

QString KTextTemplate::unescapeStringLiteral ( const QString input)

Converts the input into its unescaped form.

Double slashes are converted to single slashes, \&quot is converted to &quot etc.

Definition at line 27 of file util.cpp.

◆ variantIsTrue()

bool KTextTemplate::variantIsTrue ( const QVariant variant)

Returns whether the variant is evaluated to true.

See also
Truthiness

Definition at line 35 of file util.cpp.

#define KTEXTTEMPLATE_BEGIN_LOOKUP(Type)
Top boundary of a lookup function for Type.
Definition: metatype.h:216
#define KTEXTTEMPLATE_END_LOOKUP
Bottom boundary of a lookup function for Type.
Definition: metatype.h:238
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 6 2023 04:06:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.