Filter Reference

In addition to the built-in Jinja filters listed here, the following additional features are implemented in the ifcodegen.

Filters

return_type(symbol)

Returns the C++ type for the passed symbol.

E.g. QString for a symbol of type "string".

parameter_type(symbol)

Returns the C++ type for the passed symbol. This returns the same type as return_type(), but already prepared to be used as a parameter for methods.

E.g. "const QString &<name>" for a symbol of type "string"

getter_name(symbol)

Returns the getter name of the property, if defined by the @getter_name annotation. Otherwise retuns the passed symbol.

setter_name(symbol)

Returns the setter name of the property, if defined by the @setter_name annotation. Otherwise retuns the passed symbol.

default_type_value(symbol)

Returns the default value for the passed symbol. Models are initialized as nullptr

flag_type(symbol)

Returns the name defined by the @type annotation for the passed flag. If this is not set, tries to pluralize the passed name by adding an 's' at the end.

parse_doc(string)

Parses the passed comment string and adds every javadoc command into its own group. Sentences without tag are put into the 'description' group.

{% with doc = comments|parse_doc -%}
{% if doc.brief %}    \brief {{doc.brief}}
{% endif %}

{% if doc.description %}
    {{doc.description}}
{% endif %}
{% endwith %}

lowerfirst(string)

Only lowers the first character of the given string.

strip_QT(string)

Removes the 'QT' at the beginning, if the string starts with it.

enum_value(value, module_name)

Returns the fully qualified C++ name of the given value. The passed module_name is used as C++ class name containing the enum.

Also supports passing '|' connected values.

jsonify(obj)

Returns a JSON representation of the given obj.

qml_type(interface)

Returns the name of the interface/module for use in QML. This name is defined by the @qml_type annotation. This annotation is optional: if not provided, the interface name is used, for modules module_name is used.

struct_includes(symbol)

Returns the includes for the structs that the interface or a struct depends on. The returned strings are complete and in format #include "struct.h".

comment_text(comment)

Returns the text of the passed comment without the leading/trailing comment tokens ('/**', '*').

qml_info_type(symbol)

Returns the correct type for the symbol, to be used inside the qmltype templates.

add_namespace_prefix(symbol, module)

Appends the string retrieved from namespace_prefix to the provided symbol.

The namespace is read from the annotation of the module the symbol is part of. In case the symbol is a string, the additional module argument can be provided where the namespace annotation is read from.

namespace_prefix(symbol)

Reads the namespace from the annotation of the module the symbol is part of and transforms this in a C++ prefix, which can be easily appended to a C++ class name.

namespace(symbol)

Returns the namespace from the annotation of the module the symbol is part of.

This filter is mainly used for namespace_prefix and add_namespace_prefix and provides special handling for the 'qt' namespace for which it returns an empty string.

begin_namespace(symbol)

Returns a C++ statement to start a new namespace.

The namespace is read from the annotation of the module the symbol is part of.

end_namespace(symbol)

Returns a C++ statement to end a namespace.

The namespace is read from the annotation of the module the symbol is part of.

Global Functions

error(msg)

Throws an error with the given msg

warning(msg)

Reports a warning with the given msg

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.