paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
Public Member Functions | Static Public Member Functions
mqtt::topic_filter Class Reference

#include <topic.h>

Public Member Functions

 topic_filter (const string &filter)
 
bool has_wildcards () const
 
bool matches (const string &topic) const
 

Static Public Member Functions

static bool has_wildcards (const string &topic)
 

Detailed Description

An MQTT topic filter.

This is a multi-field string, delimited by forward slashes, '/', in which fields can contain the wildcards:

'+' - Matches a single field '#' - Matches all subsequent fields (must be last field in filter)

It can be used to match against specific topics.

Constructor & Destructor Documentation

◆ topic_filter()

mqtt::topic_filter::topic_filter ( const string filter)
explicit

Creates a new topic filter.

Parameters
filterA string MQTT topic filter. This is a slash ('/') delimited topic string that can contain wildcards '+' and '#'.

Member Function Documentation

◆ has_wildcards() [1/2]

static bool mqtt::topic_filter::has_wildcards ( const string topic)
static

Determines if the specified topic filter contains any wildcards.

Parameters
filterThe topic filter string to check for wildcards.
Returns
true if any of the fields contain a wildcard, false if not.

◆ has_wildcards() [2/2]

bool mqtt::topic_filter::has_wildcards ( ) const

Determines if this topic filter contains any wildcards.

Returns
true if any of the fields contain a wildcard, false if not.

◆ matches()

bool mqtt::topic_filter::matches ( const string topic) const

Determine if the topic matches this filter.

Parameters
topicAn MQTT topic. It should not contain wildcards.
Returns
true of the topic matches this filter, false otherwise.

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