2
0
mirror of https://github.com/boostorg/mqtt5.git synced 2026-01-19 04:22:11 +00:00
Files
mqtt5/doc/qbk/reference/properties/pubrel_props.qbk
Korina Šimičević b42014f379 Simplify document generation and replace Async.MQTT5 with Boost.MQTT5 in docs
Summary:
related to T15996

- docs are now buildable with b2 (in a very simplified way) like mysql docs
- change Async.MQTT5 -> Boost.MQTT5, async_mqtt5 namespace to boost::mqtt5 namespace

- once changes are approved, Ill update all tabs to 4 spaces in .qbk files

Reviewers: ivica

Reviewed By: ivica

Subscribers: iljazovic, miljen

Differential Revision: https://repo.mireo.local/D33373
2025-01-27 08:22:13 +01:00

53 lines
2.3 KiB
Plaintext

[/
Copyright (c) 2023-2024 Ivica Siladic, Bruno Iljazovic, Korina Simicevic
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
]
[section:pubrel_props PUBREL properties]
The last field in the Variable header of __PUBREL__ 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 section lists all possible __PUBREL__ Properties and describes their usage:
[table:pubrel_props PUBREL properties
[[Identifier] [Value type] [Description]]
[[reason_string] [`std::string`] [A UTF-8 Encoded String representing the reason associated with this response.]]
[[user_property] [`std::pair<std::string, std::string>`] [Name, value pair (__UTF8_STRING_PAIR__) defining User Property. There can be multiple pairs in one packet.
This property may be used to provide additional diagnostic or other information. ]]
]
[h4 Usage]
After obtaining an instance of `boost::mqtt5::pubrel_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 `std::optional` of the value type for all properties,
except for `boost::mqtt5::prop::user_property`, where it will return an instance of `std::vector<std::pair<std::string, std::string>>`.]
[h4 Example]
The following example shows how to set a Property value:
[!c++]
boost::mqtt5::pubrel_props props;
props[boost::mqtt5::prop::reason_string] = "Some reason...";
props[boost::mqtt5::prop::user_property].emplace_back("name", "value");
The following example shows how to retrieve a Property value:
[!c++]
std::optional<std::string> reason_string = props[boost::mqtt5::prop::reason_string];
if (reason_string.has_value())
// reason string property was previously set
else
// reason string 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
[endsect]