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 25 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 23 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 150 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 119 of file util.cpp.

◆ getIsTitleRE()

static QRegularExpression KTextTemplate::getIsTitleRE ( )
static

Definition at line 22 of file typeaccessors.cpp.

◆ getSafeString()

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

Retrieves and returns a SafeString from the input.

Definition at line 91 of file util.cpp.

◆ getTitleRE()

static QRegularExpression KTextTemplate::getTitleRE ( )
static

Definition at line 28 of file typeaccessors.cpp.

◆ isSafeString()

bool KTextTemplate::isSafeString ( const QVariant & input)

Returns whether input contains a SafeString.

Definition at line 99 of file util.cpp.

◆ markForEscaping()

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

Marks the input as requiring escaping.

Definition at line 81 of file util.cpp.

◆ markSafe()

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

Marks the input as safe.

Definition at line 74 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
{
// ...
};
// Only the introspectable API from SomeType is needed, so we can reuse that
registration.
#define KTEXTTEMPLATE_END_LOOKUP
Bottom boundary of a lookup function for Type.
Definition metatype.h:227
#define KTEXTTEMPLATE_BEGIN_LOOKUP(Type)
Top boundary of a lookup function for Type.
Definition metatype.h:205
int registerMetaType()
Registers the type RealType with the metatype system.
Definition metatype.h:173
See also
Generic type and template support

Definition at line 173 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 113 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 16 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 24 of file util.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.