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

#include <properties.h>

Public Member Functions

 properties ()
 
 properties (const properties &other)
 
 properties (properties &&other)
 
 properties (const MQTTProperties &cprops)
 
 properties (std::initializer_list< property > props)
 
 ~properties ()
 
const MQTTProperties & c_struct () const
 
propertiesoperator= (const properties &rhs)
 
propertiesoperator= (properties &&rhs)
 
bool empty () const
 
size_t size () const
 
void add (const property &prop)
 
void clear ()
 
bool contains (property::code propid) const
 
size_t count (property::code propid) const
 
property get (property::code propid, size_t idx=0)
 

Friends

template<typename T >
get (const properties &props, property::code propid, size_t idx)
 
template<typename T >
get (const properties &props, property::code propid)
 

Detailed Description

MQTT v5 property list.

A collection of properties that can be added to outgoing packets or retrieved from incoming packets.

Constructor & Destructor Documentation

◆ properties() [1/5]

mqtt::properties::properties ( )

Default constructor. Creates an empty properties list.

◆ properties() [2/5]

mqtt::properties::properties ( const properties other)
inline

Copy constructor.

Parameters
otherThe property list to copy.

◆ properties() [3/5]

mqtt::properties::properties ( properties &&  other)
inline

Move constructor.

Parameters
otherThe property list to move to this one.

◆ properties() [4/5]

mqtt::properties::properties ( const MQTTProperties &  cprops)
inline

Creates a list of properties from a C struct.

Parameters
cpropsThe c struct of properties

◆ properties() [5/5]

mqtt::properties::properties ( std::initializer_list< property props)

Constructs from a list of property objects.

Parameters
propsAn initializer list of property objects.

◆ ~properties()

mqtt::properties::~properties ( )
inline

Destructor.

Member Function Documentation

◆ c_struct()

const MQTTProperties& mqtt::properties::c_struct ( ) const
inline

Gets a reference to the underlying C properties structure.

Returns
A const reference to the underlying C properties structure.

◆ operator=() [1/2]

properties& mqtt::properties::operator= ( const properties rhs)

Copy assignment.

Parameters
rhsThe other property list to copy into this one
Returns
A reference to this object.

◆ operator=() [2/2]

properties& mqtt::properties::operator= ( properties &&  rhs)

Move assignment.

Parameters
rhsThe property list to move to this one.
Returns
A reference to this object.

◆ empty()

bool mqtt::properties::empty ( ) const
inline

Determines if the property list is empty.

Returns
true if there are no properties in the list, false if the list contains any items.

◆ size()

size_t mqtt::properties::size ( ) const
inline

Gets the numbers of property items in the list.

Returns
The number of property items in the list.

◆ add()

void mqtt::properties::add ( const property prop)
inline

Adds a property to the list.

Parameters
propThe property to add to the list.

◆ clear()

void mqtt::properties::clear ( )
inline

Removes all the items from the property list.

◆ contains()

bool mqtt::properties::contains ( property::code  propid) const
inline

Determines if the list contains a specific property.

Parameters
propidThe property ID (code).
Returns
true if the list contains the property, false if not.

◆ count()

size_t mqtt::properties::count ( property::code  propid) const
inline

Get the number of properties in the list with the specified property ID.

Most properties can exist only once. User properties and subscription ID's can exist more than once.

Parameters
propidThe property ID (code).
Returns
The number of properties in the list with the specified ID.

◆ get()

property mqtt::properties::get ( property::code  propid,
size_t  idx = 0 
)

Gets the property with the specified ID.

Parameters
propidThe property ID (code).
idxWhich instance of the property to retrieve, if there are more than one.
Returns
The requested property

Friends And Related Function Documentation

◆ get [1/2]

template<typename T >
T get ( const properties props,
property::code  propid,
size_t  idx 
)
friend

Retrieves a single value from a property list for when there may be multiple identical property ID's.

Template Parameters
TThe type of the value to retrieve
Parameters
propsThe property list
propidThe property ID code for the desired value.
idxIndex of the desired property ID
Returns
The requested value of type T

◆ get [2/2]

template<typename T >
T get ( const properties props,
property::code  propid 
)
friend

Retrieves a single value from a property list.

Template Parameters
TThe type of the value to retrieve
Parameters
propsThe property list
propidThe property ID code for the desired value.
Returns
The requested value of type T

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