Loading...
Searching...
No Matches
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 | is_wildcard (char c)
static bool | is_wildcard (const string &s)
static bool | has_wildcards (const string &filter)

## 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

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

## Member Function Documentation

## is_wildcard() [1/2]

static bool mqtt::topic_filter::is_wildcard | ( | char | c | ) |

inline static

Determins if the character is a wildcard, '+' or '#'

Parameters

  c | The character to check

Returns
  true if `c` is a wildcard, '+' or '#'

## is_wildcard() [2/2]

static bool mqtt::topic_filter::is_wildcard | ( | const string & | s | ) |

inline static

Determins if the string (field) is a wildcard, "+" or "#"

Parameters

  s | The string to check

Returns
  true if `c` is a wildcard, "+" or "#"

## has_wildcards() [1/2]

static bool mqtt::topic_filter::has_wildcards | ( | const string & | filter | ) |

static

Determines if the specified topic/filter contains any wildcards.

Parameters

  filter | The 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

  topic | An 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:

- topic.h