paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends
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_optionsoperator= (const will_options &opt)
 
will_optionsoperator= (will_options &&opt)
 
string get_topic () const
 
const binary_refget_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 propertiesget_properties () const
 
void set_properties (const properties &props)
 
void set_properties (properties &&props)
 

Static Public Attributes

static PAHO_MQTTPP_EXPORT const int DFLT_QOS
 
static PAHO_MQTTPP_EXPORT const bool DFLT_RETAINED
 

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

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
topThe LWT message is published to the this topic.
payloadThe message that is published to the Will Topic.
payload_lenThe message size in bytes
qosThe message Quality of Service.
retainedTell the broker to keep the LWT message after send to subscribers.
propsMQTT 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
topThe LWT message is published to the this topic.
payloadThe message that is published to the Will Topic.
payload_lenThe message size in bytes.
qosThe message Quality of Service.
retainedTell the broker to keep the LWT message after send to subscribers.
propsMQTT 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
topThe LWT message is published to the this topic.
payloadThe message payload that is published to the Will Topic.
qosThe message Quality of Service.
retainedTell the broker to keep the LWT message after send to subscribers.
propsMQTT 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
topThe LWT message is published to the this topic.
payloadThe message payload that is published to the Will Topic, as a string.
qosThe message Quality of Service.
retainedTell the broker to keep the LWT message after send to subscribers.
propsMQTT 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
msgThe 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
optThe other options.

◆ will_options() [8/8]

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

Move constructor for the LWT options.

Parameters
optThe 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
optThe other options.

◆ operator=() [2/2]

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

Move assignment for the LWT options.

Parameters
optThe 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
topThe 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
msgThe LWT message

◆ set_payload() [2/2]

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

Sets the LWT message text.

Parameters
msgThe LWT message

◆ set_qos()

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

Sets the QoS value.

Parameters
qosThe LWT message QoS

◆ set_retained()

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

Sets the retained flag.

Parameters
retainedTell 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
propsThe 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
propsThe properties to move into the connect object.

Friends And Related Function Documentation

◆ connect_options

friend class connect_options
friend

The connect options has special access

Field Documentation

◆ DFLT_QOS

PAHO_MQTTPP_EXPORT const int mqtt::will_options::DFLT_QOS
static

The default QoS for the LWT, if unspecified

◆ DFLT_RETAINED

PAHO_MQTTPP_EXPORT const bool mqtt::will_options::DFLT_RETAINED
static

The defalut retained flag for LWT, if unspecified


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