Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QQmlCustomParser Class Referenceabstract

The QQmlCustomParser class allows you to add new arbitrary types to QML. More...

#include <qqmlcustomparser_p.h>

+ Inheritance diagram for QQmlCustomParser:
+ Collaboration diagram for QQmlCustomParser:

Public Types

enum  Flag { NoFlag = 0x00000000 , AcceptsAttachedProperties = 0x00000001 , AcceptsSignalHandlers = 0x00000002 }
 

Public Member Functions

 QQmlCustomParser ()
 
 QQmlCustomParser (Flags f)
 
virtual ~QQmlCustomParser ()
 
void clearErrors ()
 
Flags flags () const
 
virtual void verifyBindings (const QQmlRefPointer< QV4::ExecutableCompilationUnit > &, const QList< const QV4::CompiledData::Binding * > &)=0
 
virtual void applyBindings (QObject *, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &, const QList< const QV4::CompiledData::Binding * > &)=0
 
QVector< QQmlErrorerrors () const
 

Protected Member Functions

void error (const QV4::CompiledData::Binding *binding, const QString &description)
 
void error (const QV4::CompiledData::Object *object, const QString &description)
 
void error (const QV4::CompiledData::Location &location, const QString &description)
 Reports an error with the given description.
 
int evaluateEnum (const QString &, bool *ok) const
 If script is a simple enumeration expression (eg.
 
const QMetaObjectresolveType (const QString &) const
 Resolves name to a type, or 0 if it is not a type.
 

Friends

class QQmlPropertyValidator
 
class QQmlObjectCreator
 

Detailed Description

The QQmlCustomParser class allows you to add new arbitrary types to QML.

By subclassing QQmlCustomParser, you can add a parser for building a particular type.

The subclass must implement compile() and setCustomData(), and register itself in the meta type system by calling the macro:

QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass)
std::list< QString >::iterator Name
Definition lalr.h:29

Definition at line 29 of file qqmlcustomparser_p.h.

Member Enumeration Documentation

◆ Flag

Enumerator
NoFlag 
AcceptsAttachedProperties 
AcceptsSignalHandlers 

Definition at line 32 of file qqmlcustomparser_p.h.

Constructor & Destructor Documentation

◆ QQmlCustomParser() [1/2]

QQmlCustomParser::QQmlCustomParser ( )
inline

Definition at line 39 of file qqmlcustomparser_p.h.

◆ QQmlCustomParser() [2/2]

QQmlCustomParser::QQmlCustomParser ( Flags  f)
inline

Definition at line 40 of file qqmlcustomparser_p.h.

◆ ~QQmlCustomParser()

virtual QQmlCustomParser::~QQmlCustomParser ( )
inlinevirtual

Definition at line 41 of file qqmlcustomparser_p.h.

Member Function Documentation

◆ applyBindings()

virtual void QQmlCustomParser::applyBindings ( QObject ,
const QQmlRefPointer< QV4::ExecutableCompilationUnit > &  ,
const QList< const QV4::CompiledData::Binding * > &   
)
pure virtual

◆ clearErrors()

void QQmlCustomParser::clearErrors ( )

Definition at line 57 of file qqmlcustomparser.cpp.

◆ error() [1/3]

void QQmlCustomParser::error ( const QV4::CompiledData::Binding binding,
const QString description 
)
inlineprotected

Definition at line 52 of file qqmlcustomparser_p.h.

References error, and QV4::CompiledData::Binding::location.

◆ error() [2/3]

void QQmlCustomParser::error ( const QV4::CompiledData::Location location,
const QString description 
)
protected

Reports an error with the given description.

An error is generated referring to the location in the source file.

Definition at line 67 of file qqmlcustomparser.cpp.

References error, and qmlConvertSourceCoordinate< quint32, int >().

+ Here is the call graph for this function:

◆ error() [3/3]

void QQmlCustomParser::error ( const QV4::CompiledData::Object object,
const QString description 
)
inlineprotected

Definition at line 54 of file qqmlcustomparser_p.h.

References error.

◆ errors()

QVector< QQmlError > QQmlCustomParser::errors ( ) const
inline

Definition at line 49 of file qqmlcustomparser_p.h.

◆ evaluateEnum()

int QQmlCustomParser::evaluateEnum ( const QString script,
bool *  ok 
) const
protected

If script is a simple enumeration expression (eg.

Text.AlignLeft), returns the integer equivalent (eg. 1), and sets ok to true.

Otherwise sets ok to false.

A valid ok must be provided, or the function will assert.

Definition at line 85 of file qqmlcustomparser.cpp.

References QQmlImport::AllowRecursion, QQmlType::AnyRegistrationType, QBiPointer< T, T2 >::asT1(), QBiPointer< T, T2 >::asT2(), QByteArray::constData(), QQmlPropertyValidator::documentSourceUrl(), dot(), i, QString::indexOf(), QString::isEmpty(), QBiPointer< T, T2 >::isNull(), QBiPointer< T, T2 >::isT1(), QUrl::isValid(), QString::left(), QString::mid(), mo, QQmlEnumData::name, ok, Q_ASSERT, Q_ASSERT_X, QQmlTypeNameCache::query(), QQmlImports::resolveType(), QQmlPropertyValidator::rootPropertyCache(), QString::size(), QString::toUtf8(), and QQmlEnumData::values.

+ Here is the call graph for this function:

◆ flags()

Flags QQmlCustomParser::flags ( ) const
inline

Definition at line 44 of file qqmlcustomparser_p.h.

◆ resolveType()

const QMetaObject * QQmlCustomParser::resolveType ( const QString name) const
protected

Resolves name to a type, or 0 if it is not a type.

This can be used to type-check object nodes.

Definition at line 197 of file qqmlcustomparser.cpp.

References QBiPointer< T, T2 >::asT1(), QBiPointer< T, T2 >::isT1(), QQmlType::metaObject(), and QQmlImports::resolveType().

+ Here is the call graph for this function:

◆ verifyBindings()

virtual void QQmlCustomParser::verifyBindings ( const QQmlRefPointer< QV4::ExecutableCompilationUnit > &  ,
const QList< const QV4::CompiledData::Binding * > &   
)
pure virtual

Friends And Related Symbol Documentation

◆ QQmlObjectCreator

friend class QQmlObjectCreator
friend

Definition at line 69 of file qqmlcustomparser_p.h.

◆ QQmlPropertyValidator

friend class QQmlPropertyValidator
friend

Definition at line 68 of file qqmlcustomparser_p.h.


The documentation for this class was generated from the following files: