IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QMqttTopicFilter Class

The QMqttTopicFilter class represents a MQTT topic filter.

All functions in this class are reentrant.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QMqttTopicFilter Class▲

  • Header: QMqttTopicFilter

  • qmake: QT += mqtt

  • Group: QMqttTopicFilter is part of shared

Detailed Description▲

QMqttTopicFilter is a thin wrapper around a QString providing an expressive data type for MQTT topic filters. Beside the benefits of having a strong type preventing unintended misuse, QMqttTopicFilter provides convenient functions related to topic filters like isValid() or match().

For example, the following code would fail to compile and prevent a possible unintended and meaningless matching of two filters, especially if the variable names were less expressive:

 
Sélectionnez
QMqttTopicFilter globalFilter{"foo/#"};
QMqttTopicFilter specificFilter{"foo/bar"};
if (globalFilter.match(specificFilter)) {
    //...
}

The usability, however, is not affected since the following snippet compiles and runs as expected:

 
Sélectionnez
QMqttTopicFilter globalFilter{"foo/#"};
if (globalFilter.match("foo/bar")) {
    //...
}

See Also▲

See also QMqttTopicName

Member Type Documentation▲

 

enum QMqttTopicFilter::MatchOption▲

flags QMqttTopicFilter::MatchOptions

This enum value holds the matching options for the topic filter.

Constant

Value

Description

QMqttTopicFilter::NoMatchOption

0x0000

No match options are set.

QMqttTopicFilter::WildcardsDontMatchDollarTopicMatchOption

0x0001

A wildcard at the filter's beginning does not match a topic name that starts with the dollar sign ($).

The MatchOptions type is a typedef for QFlags<MatchOption>. It stores an OR combination of MatchOption values.

Member Function Documentation▲

 

QMqttTopicFilter::QMqttTopicFilter(const QString &filter = QString())▲

Creates a new MQTT topic filter with the specified filter.

QMqttTopicFilter::QMqttTopicFilter(const QLatin1String &filter)▲

Creates a new MQTT topic filter with the specified filter.

QMqttTopicFilter::QMqttTopicFilter(const QMqttTopicFilter &filter)▲

Creates a new MQTT topic filter as a copy of filter.

QMqttTopicFilter::~QMqttTopicFilter()▲

Destroys the QMqttTopicFilter object.

QString QMqttTopicFilter::filter() const▲

Returns the topic filter.

See Also▲

See also setFilter()

bool QMqttTopicFilter::isValid() const▲

Returns true if the topic filter is valid according to the MQTT standard section 4.7, or false otherwise.

bool QMqttTopicFilter::match(const QMqttTopicName &name, QMqttTopicFilter::MatchOptions matchOptions = NoMatchOption) const▲

Returns true if the topic filter matches the topic name name honoring the given matchOptions, or false otherwise.

void QMqttTopicFilter::setFilter(const QString &filter)▲

Sets the topic filter to filter.

See Also▲

See also filter()

[since 5.12] QString QMqttTopicFilter::sharedSubscriptionName() const▲

Returns the name of a share if the topic filter has been specified as a shared subscription. The format of shared subscriptions is defined as $share/sharename/topicfilter.

This function was introduced in Qt 5.12.

void QMqttTopicFilter::swap(QMqttTopicFilter &other)▲

Swaps the MQTT topic filter other with this MQTT topic filter. This operation is very fast and never fails.

QMqttTopicFilter &QMqttTopicFilter::operator=(const QMqttTopicFilter &filter)▲

Assigns the MQTT topic filter filter to this object, and returns a reference to the copy.

Related Non-Members▲

 

QDataStream &operator<<(QDataStream &out, const QMqttTopicFilter &filter)▲

Writes the topic filter filter to the stream out and returns a reference to the stream.

See Also▲

QDataStream &operator>>(QDataStream &in, QMqttTopicFilter &filter)▲

Reads a topic filter into filter from the stream in and returns a reference to the stream.

See Also▲

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+