Loading...
Searching...
No Matches
mqtt::will_options Class Reference

`#include <will_options.h>`

## Public Types

using | ptr_t = std::shared_ptr< will_options >
using | const_ptr_t = std::shared_ptr< const will_options >
using | unique_ptr_t = std::unique_ptr< will_options >

## Public Member Functions

| will_options ()
| will_options (string_ref top, const void *payload, size_t payload_len, int qos=DFLT_QOS, bool retained=DFLT_RETAINED, const properties &props=properties())
| will_options (const topic &top, const void *payload, size_t payload_len, int qos=DFLT_QOS, bool retained=DFLT_RETAINED, const properties &props=properties())
| will_options (string_ref top, binary_ref payload, int qos=DFLT_QOS, bool retained=DFLT_RETAINED, const properties &props=properties())
| will_options (string_ref top, const string &payload, int qos=DFLT_QOS, bool retained=DFLT_QOS, const properties &props=properties())
| will_options (const message &msg)
| will_options (const will_options &opt)
| will_options (will_options &&opt)
will_options & | operator= (const will_options &opt)
will_options & | operator= (will_options &&opt)
string | get_topic () const
const binary_ref & | get_payload () const
string | get_payload_str () const
int | get_qos () const
bool | is_retained () const
const_message_ptr | get_message () const
void | set_topic (string_ref top)
void | set_payload (binary_ref msg)
void | set_payload (string msg)
void | set_qos (const int qos)
void | set_retained (bool retained)
const properties & | get_properties () const
void | set_properties (const properties &props)
void | set_properties (properties &&props)

## Static Public Attributes

static constexpr int | DFLT_QOS = 0
static constexpr bool | DFLT_RETAINED = false

## Friends

class | connect_options

## Detailed Description

Holds the set of options that govern the Last Will and Testament feature.

Note
  This wraps struct v1 of the C library's MQTTAsync_willOptions structure. It sets the LWT binary payload, via the 'payload' struct field, and leaves the 'message' field as a nullptr.

## Member Typedef Documentation

## ptr_t

using mqtt::will_options::ptr_t = std::shared_ptr<will_options>

Smart/shared pointer to an object of this class.

## const_ptr_t

using mqtt::will_options::const_ptr_t = std::shared_ptr<const will_options>

Smart/shared pointer to a const object of this class.

## unique_ptr_t

using mqtt::will_options::unique_ptr_t = std::unique_ptr<will_options>

Smart/shared pointer to an object of this class.

## Constructor & Destructor Documentation

## will_options() [1/8]

mqtt::will_options::will_options | ( |  | ) |

Constructs a new object using the default values.

## will_options() [2/8]

mqtt::will_options::will_options | ( | string_ref | top,
|  | const void * | payload,
|  | size_t | payload_len,
|  | int | qos = `DFLT_QOS`,
|  | bool | retained = `DFLT_RETAINED`,
|  | const properties & | props = `properties()`
| ) |  |

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  top | The LWT message is published to the this topic.
  payload | The message that is published to the Will Topic.
  payload_len | The message size in bytes
  qos | The message Quality of Service.
  retained | Tell the broker to keep the LWT message after send to subscribers.
  props | MQTT v5 properties for the will message.

## will_options() [3/8]

mqtt::will_options::will_options | ( | const topic & | top,
|  | const void * | payload,
|  | size_t | payload_len,
|  | int | qos = `DFLT_QOS`,
|  | bool | retained = `DFLT_RETAINED`,
|  | const properties & | props = `properties()`
| ) |  |

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  top | The LWT message is published to the this topic.
  payload | The message that is published to the Will Topic.
  payload_len | The message size in bytes.
  qos | The message Quality of Service.
  retained | Tell the broker to keep the LWT message after send to subscribers.
  props | MQTT v5 properties for the will message.

## will_options() [4/8]

mqtt::will_options::will_options | ( | string_ref | top,
|  | binary_ref | payload,
|  | int | qos = `DFLT_QOS`,
|  | bool | retained = `DFLT_RETAINED`,
|  | const properties & | props = `properties()`
| ) |  |

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  top | The LWT message is published to the this topic.
  payload | The message payload that is published to the Will Topic.
  qos | The message Quality of Service.
  retained | Tell the broker to keep the LWT message after send to subscribers.
  props | MQTT v5 properties for the will message.

## will_options() [5/8]

mqtt::will_options::will_options | ( | string_ref | top,
|  | const string & | payload,
|  | int | qos = `DFLT_QOS`,
|  | bool | retained = `DFLT_QOS`,
|  | const properties & | props = `properties()`
| ) |  |

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  top | The LWT message is published to the this topic.
  payload | The message payload that is published to the Will Topic, as a string.
  qos | The message Quality of Service.
  retained | Tell the broker to keep the LWT message after send to subscribers.
  props | MQTT v5 properties for the will message.

## will_options() [6/8]

mqtt::will_options::will_options | ( | const message & | msg | ) |

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  msg | The message that is published to the Will Topic.

## will_options() [7/8]

mqtt::will_options::will_options | ( | const will_options & | opt | ) |

Copy constructor for the LWT options.

Parameters

  opt | The other options.

## will_options() [8/8]

mqtt::will_options::will_options | ( | will_options && | opt | ) |

Move constructor for the LWT options.

Parameters

  opt | The other options.

## Member Function Documentation

## operator=() [1/2]

will_options & mqtt::will_options::operator= | ( | const will_options & | opt | ) |

Copy assignment for the LWT options.

Parameters

  opt | The other options.

## operator=() [2/2]

will_options & mqtt::will_options::operator= | ( | will_options && | opt | ) |

Move assignment for the LWT options.

Parameters

  opt | The other options.

## get_topic()

string mqtt::will_options::get_topic | ( |  | ) | const

inline

Expose the underlying C struct for the unit tests. Gets the LWT message topic name.

Returns
  The LWT message topic name.

## get_payload()

const binary_ref & mqtt::will_options::get_payload | ( |  | ) | const

inline

Gets the LWT message payload.

Returns
  The LWT message payload.

## get_payload_str()

string mqtt::will_options::get_payload_str | ( |  | ) | const

inline

Gets the LWT message payload as a string.

Returns
  The LWT message payload as a string.

## get_qos()

int mqtt::will_options::get_qos | ( |  | ) | const

inline

Gets the QoS value for the LWT message.

Returns
  The QoS value for the LWT message.

## is_retained()

bool mqtt::will_options::is_retained | ( |  | ) | const

inline

Gets the 'retained' flag for the LWT message.

Returns
  The 'retained' flag for the LWT message.

## get_message()

const_message_ptr mqtt::will_options::get_message | ( |  | ) | const

inline

Gets the LWT message as a message object.

Returns
  A pointer to a copy of the LWT message.

## set_topic()

void mqtt::will_options::set_topic | ( | string_ref | top | ) |

Sets the LWT message topic name.

Parameters

  top | The topic where to sent the message

## set_payload() [1/2]

void mqtt::will_options::set_payload | ( | binary_ref | msg | ) |

Sets the LWT message text.

Parameters

  msg | The LWT message

## set_payload() [2/2]

void mqtt::will_options::set_payload | ( | string | msg | ) |

inline

Sets the LWT message text.

Parameters

  msg | The LWT message

## set_qos()

void mqtt::will_options::set_qos | ( | const int | qos | ) |

inline

Sets the QoS value.

Parameters

  qos | The LWT message QoS

## set_retained()

void mqtt::will_options::set_retained | ( | bool | retained | ) |

inline

Sets the retained flag.

Parameters

  retained | Tell the broker to keep the LWT message after send to subscribers.

## get_properties()

const properties & mqtt::will_options::get_properties | ( |  | ) | const

inline

Gets the connect properties.

Returns
  A const reference to the properties for the connect.

## set_properties() [1/2]

void mqtt::will_options::set_properties | ( | const properties & | props | ) |

inline

Sets the properties for the connect.

Parameters

  props | The properties to place into the message.

## set_properties() [2/2]

void mqtt::will_options::set_properties | ( | properties && | props | ) |

inline

Moves the properties for the connect.

Parameters

  props | The properties to move into the connect object.

## Friends And Related Symbol Documentation

## connect_options

friend class connect_options

friend

The connect options has special access

## Field Documentation

## DFLT_QOS

constexpr int mqtt::will_options::DFLT_QOS = 0

static constexpr

The default QoS for the LWT, if unspecified

## DFLT_RETAINED

constexpr bool mqtt::will_options::DFLT_RETAINED = false

static constexpr

The default retained flag for LWT, if unspecified

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

- will_options.h