Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This version of Boost is under active development. You are currently in the master branch. The current version is 1.91.0.
The last field in the Variable header of AUTH packet is a set of Properties.
A set contains a Property Length followed by the Properties. A Property consists
of an Identifier and a value.
This class extends prop::properties,
which provides common functionalities for all property classes. Below is
a list of possible AUTH Properties, along with descriptions
of their usage:
Table 1.17. AUTH properties
|
Identifier |
Value type |
Description |
|---|---|---|
|
authentication_method |
|
A UTF-8 Encoded String containing the name of the authentication method used for extended authentication. |
|
authentication_data |
|
Binary Data containing authentication data. The contents of the data are defined by the authentication method. |
|
reason_string |
|
A UTF-8 Encoded String representing the reason associated with this response. |
|
user_property |
|
Name, value pair ( |
After obtaining an instance of boost::mqtt5::auth_props,
the subscript operator can be used to access a Property.
The Identifiers listed in the table above are available within the boost::mqtt5::prop namespace for Property access.
![]() |
Note |
|---|---|
When accessing a property value, the subscript operator will return a
|
The following example shows how to set a Property value:
boost::mqtt5::auth_props props; props[boost::mqtt5::prop::authentication_method] = "SCRAM-SHA-1"; props[boost::mqtt5::prop::authentication_data] = "data"; props[boost::mqtt5::prop::user_property].emplace_back("name", "value");
The following example shows how to retrieve a Property value:
std::optional<std::string> auth_data = props[boost::mqtt5::prop::authentication_data]; if (auth_data.has_value()) // authentication data property was previously set else // authentication data property was not set std::vector<std::pair<std::string, std::string>>& user_props = props[boost::mqtt5::prop::user_property]; if (!user_props.empty()) // user property was previously set else // user property was not set