7 #if !defined(MQTT_PROPERTY_HPP)
8 #define MQTT_PROPERTY_HPP
15 #include <boost/asio/buffer.hpp>
16 #include <boost/numeric/conversion/cast.hpp>
17 #include <boost/container/static_vector.hpp>
51 template <std::
size_t N>
56 template <
typename It>
78 template <
typename It>
79 void fill(It b, It e)
const {
81 BOOST_ASSERT(
static_cast<std::size_t
>(std::distance(b, e)) >=
size());
82 *b++ =
static_cast<typename std::iterator_traits<It>::value_type
>(
id_);
83 std::copy(
buf_.begin(),
buf_.end(), b);
99 return 1 +
buf_.size();
112 boost::container::static_vector<char, N>
buf_;
139 template <
typename It>
142 using dt =
typename It::difference_type;
144 BOOST_ASSERT(
static_cast<std::size_t
>(std::distance(b, e)) >=
size());
145 *b++ =
static_cast<typename std::iterator_traits<It>::value_type
>(
id_);
147 std::advance(b,
static_cast<dt
>(
length_.size()));
148 std::copy(
buf_.begin(),
buf_.end(), b);
182 boost::container::static_vector<char, 2>
length_;
188 if (!already_checked) {
216 template <
typename It>
219 BOOST_ASSERT(
static_cast<std::size_t
>(std::distance(b, e)) >=
size());
220 *b++ =
static_cast<typename std::iterator_traits<It>::value_type
>(
id_);
248 constexpr std::size_t
val()
const {
254 boost::container::static_vector<char, 4>
value_;
271 template <
typename It>
276 return ( (
buf_.front() == 0)
292 template <
typename It>
296 std::uint32_t
val()
const {
336 template <
typename It>
358 template <
typename It>
362 std::uint16_t
val()
const {
386 template <
typename It>
391 return buf_.front() == 1;
402 template <
typename It>
406 std::uint32_t
val()
const {
418 template <
typename It>
423 return buf_.front() == 1;
452 template <
typename It>
456 std::uint16_t
val()
const {
469 template <
typename It>
473 std::uint16_t
val()
const {
486 template <
typename It>
490 std::uint16_t
val()
const {
506 template <
typename It>
510 std::uint8_t
val()
const {
511 return static_cast<std::uint8_t
>(
buf_.front());
524 template <
typename It>
529 return buf_.front() == 1;
545 v.emplace_back(
as::buffer(key_.len.data(), key_.len.size()));
547 v.emplace_back(
as::buffer(val_.len.data(), val_.len.size()));
551 template <
typename It>
554 using dt =
typename It::difference_type;
555 BOOST_ASSERT(
static_cast<std::size_t
>(std::distance(b, e)) >=
size());
557 *b++ =
static_cast<typename std::iterator_traits<It>::value_type
>(id_);
559 std::copy(key_.len.begin(), key_.len.end(), b);
560 std::advance(b,
static_cast<dt
>(key_.len.size()));
561 auto ptr = key_.buf.data();
562 auto size = key_.buf.size();
563 std::copy(ptr, std::next(ptr,
static_cast<dt
>(
size)), b);
564 std::advance(b,
static_cast<dt
>(
size));
567 std::copy(val_.len.begin(), val_.len.end(), b);
568 std::advance(b,
static_cast<dt
>(val_.len.size()));
569 auto ptr = val_.buf.data();
570 auto size = val_.buf.size();
571 std::copy(ptr, std::next(ptr,
static_cast<dt
>(
size)), b);
572 std::advance(b,
static_cast<dt
>(
size));
618 explicit len_str(
buffer b,
bool already_checked =
false)
620 len{
num_to_2bytes(boost::numeric_cast<std::uint16_t>(buf.size())) }
622 if (!already_checked) {
628 std::size_t
size()
const {
629 return len.size() + buf.size();
632 boost::container::static_vector<char, 2> len;
648 template <
typename It>
652 std::uint32_t
val()
const {
665 template <
typename It>
670 return buf_.front() == 1;
682 template <
typename It>
687 return buf_.front() == 1;
699 template <
typename It>
704 return buf_.front() == 1;
708 template <
typename Property>
709 std::enable_if_t< Property::of_ == detail::ostream_format::direct, std::ostream& >
710 operator<<(std::ostream& o, Property
const& p) {
715 template <
typename Property>
716 std::enable_if_t< Property::of_ == detail::ostream_format::int_cast, std::ostream& >
717 operator<<(std::ostream& o, Property
const& p) {
718 o << static_cast<int>(p.val());
722 template <
typename Property>
723 std::enable_if_t< Property::of_ == detail::ostream_format::key_val, std::ostream& >
724 operator<<(std::ostream& o, Property
const& p) {
725 o << p.key() <<
':' << p.val();
729 template <
typename Property>
730 std::enable_if_t< Property::of_ == detail::ostream_format::binary_string, std::ostream& >
731 operator<<(std::ostream& o, Property
const& p) {
buffer that has string_view interface This class provides string_view interface. This class hold stri...
Definition: buffer.hpp:30
Definition: property.hpp:345
assigned_client_identifier(buffer val, bool already_checked=false)
Definition: property.hpp:347
Definition: property.hpp:373
authentication_data(buffer val)
Definition: property.hpp:375
Definition: property.hpp:367
authentication_method(buffer val, bool already_checked=false)
Definition: property.hpp:369
Definition: property.hpp:301
content_type(buffer val, bool already_checked=false)
Definition: property.hpp:303
Definition: property.hpp:313
correlation_data(buffer val, bool already_checked=false)
Definition: property.hpp:315
Definition: property.hpp:641
std::uint32_t val() const
Definition: property.hpp:652
maximum_packet_size(It b, It e)
Definition: property.hpp:649
maximum_packet_size(std::uint32_t val)
Definition: property.hpp:645
Definition: property.hpp:495
maximum_qos(qos value)
Definition: property.hpp:499
std::uint8_t val() const
Definition: property.hpp:510
static constexpr const detail::ostream_format of_
Definition: property.hpp:514
maximum_qos(It b, It e)
Definition: property.hpp:507
Definition: property.hpp:285
message_expiry_interval(It b, It e)
Definition: property.hpp:293
std::uint32_t val() const
Definition: property.hpp:296
message_expiry_interval(std::uint32_t val)
Definition: property.hpp:289
Definition: property.hpp:439
reason_string(buffer val, bool already_checked=false)
Definition: property.hpp:441
Definition: property.hpp:445
receive_maximum(std::uint16_t val)
Definition: property.hpp:449
std::uint16_t val() const
Definition: property.hpp:456
receive_maximum(It b, It e)
Definition: property.hpp:453
Definition: property.hpp:307
response_topic(buffer val, bool already_checked=false)
Definition: property.hpp:309
Definition: property.hpp:517
bool val() const
Definition: property.hpp:528
retain_available(bool value)
Definition: property.hpp:521
retain_available(It b, It e)
Definition: property.hpp:525
Definition: property.hpp:351
server_keep_alive(It b, It e)
Definition: property.hpp:359
std::uint16_t val() const
Definition: property.hpp:362
server_keep_alive(std::uint16_t val)
Definition: property.hpp:355
Definition: property.hpp:433
server_reference(buffer val, bool already_checked=false)
Definition: property.hpp:435
Definition: property.hpp:327
session_expiry_interval(It b, It e)
Definition: property.hpp:337
session_expiry_interval_t val() const
Definition: property.hpp:340
session_expiry_interval(session_expiry_interval_t val)
Definition: property.hpp:331
Definition: property.hpp:692
shared_subscription_available(bool value)
Definition: property.hpp:696
shared_subscription_available(It b, It e)
Definition: property.hpp:700
bool val() const
Definition: property.hpp:703
Definition: property.hpp:675
bool val() const
Definition: property.hpp:686
subscription_identifier_available(It b, It e)
Definition: property.hpp:683
subscription_identifier_available(bool value)
Definition: property.hpp:679
Definition: property.hpp:319
subscription_identifier(std::size_t subscription_id)
Definition: property.hpp:323
Definition: property.hpp:462
topic_alias_maximum(It b, It e)
Definition: property.hpp:470
std::uint16_t val() const
Definition: property.hpp:473
topic_alias_maximum(std::uint16_t val)
Definition: property.hpp:466
Definition: property.hpp:479
std::uint16_t val() const
Definition: property.hpp:490
topic_alias(std::uint16_t val)
Definition: property.hpp:483
topic_alias(It b, It e)
Definition: property.hpp:487
Definition: property.hpp:534
std::size_t size() const
Get whole size of sequence.
Definition: property.hpp:588
static constexpr detail::ostream_format const of_
Definition: property.hpp:614
static constexpr std::size_t num_of_const_buffer_sequence()
Get number of element of const_buffer_sequence.
Definition: property.hpp:599
property::id id() const
Get property::id.
Definition: property.hpp:580
constexpr buffer const & key() const
Definition: property.hpp:606
void fill(It b, It e) const
Definition: property.hpp:552
constexpr buffer const & val() const
Definition: property.hpp:610
void add_const_buffer_sequence(std::vector< as::const_buffer > &v) const
Add const buffer sequence into the given buffer.
Definition: property.hpp:543
user_property(buffer key, buffer val, bool key_already_checked=false, bool val_already_checked=false)
Definition: property.hpp:536
Definition: property.hpp:658
bool val() const
Definition: property.hpp:669
wildcard_subscription_available(bool value)
Definition: property.hpp:662
wildcard_subscription_available(It b, It e)
Definition: property.hpp:666
Definition: property.hpp:395
will_delay_interval(std::uint32_t val)
Definition: property.hpp:399
will_delay_interval(It b, It e)
Definition: property.hpp:403
std::uint32_t val() const
Definition: property.hpp:406
@ well_formed
UTF-8 string is well_formed. See http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3....
constexpr validation validate_contents(string_view str)
Definition: utf8encoded_strings.hpp:47
ostream_format
Definition: property.hpp:44
std::enable_if_t< Property::of_==detail::ostream_format::direct, std::ostream & > operator<<(std::ostream &o, Property const &p)
Definition: property.hpp:710
id
Definition: property_id.hpp:19
boost::container::static_vector< char, 4 > num_to_4bytes(std::uint32_t val)
Definition: four_byte_util.hpp:21
void variable_push(Container &c, std::size_t size)
Definition: variable_length.hpp:31
constexpr std::remove_reference_t< T > && force_move(T &&t)
Definition: move.hpp:20
boost::container::static_vector< char, 2 > num_to_2bytes(std::uint16_t val)
Definition: two_byte_util.hpp:20
constexpr std::tuple< std::size_t, std::size_t > variable_length(T const &bytes)
Definition: variable_length.hpp:42
qos
Definition: subscribe_options.hpp:34
constexpr std::uint16_t make_uint16_t(It b, It e)
Definition: two_byte_util.hpp:34
constexpr std::uint32_t make_uint32_t(It b, It e)
Definition: four_byte_util.hpp:39
std::uint32_t session_expiry_interval_t
Definition: type.hpp:16
Definition: buffer.hpp:242
const_buffer buffer(MQTT_NS::buffer const &data)
create boost::asio::const_buffer from the MQTT_NS::buffer boost::asio::const_buffer is a kind of view...
Definition: buffer.hpp:253
Definition: buffer.hpp:241
Definition: exception.hpp:115
Definition: exception.hpp:109
Definition: exception.hpp:51
Definition: property.hpp:115
static constexpr ostream_format const of_
Definition: property.hpp:179
property::id id_
Definition: property.hpp:180
binary_property(property::id id, buffer buf)
Definition: property.hpp:116
std::size_t size() const
Get whole size of sequence.
Definition: property.hpp:163
constexpr buffer const & val() const
Definition: property.hpp:175
boost::container::static_vector< char, 2 > length_
Definition: property.hpp:182
property::id id() const
Get property::id.
Definition: property.hpp:155
static constexpr std::size_t num_of_const_buffer_sequence()
Get number of element of const_buffer_sequence.
Definition: property.hpp:171
void fill(It b, It e) const
Copy the internal information to the range between b and e it is for boost asio APIs.
Definition: property.hpp:140
buffer buf_
Definition: property.hpp:181
void add_const_buffer_sequence(std::vector< as::const_buffer > &v) const
Add const buffer sequence into the given buffer.
Definition: property.hpp:127
Definition: property.hpp:52
property::id id() const
Get property::id.
Definition: property.hpp:90
n_bytes_property(property::id id)
Definition: property.hpp:53
void add_const_buffer_sequence(std::vector< as::const_buffer > &v) const
Add const buffer sequence into the given buffer.
Definition: property.hpp:67
std::size_t size() const
Get whole size of sequence.
Definition: property.hpp:98
property::id id_
Definition: property.hpp:111
n_bytes_property(property::id id, It b, It e)
Definition: property.hpp:57
static constexpr ostream_format const of_
Definition: property.hpp:110
static constexpr std::size_t num_of_const_buffer_sequence()
Get number of element of const_buffer_sequence.
Definition: property.hpp:106
n_bytes_property(property::id id, boost::container::static_vector< char, N > buf)
Definition: property.hpp:60
void fill(It b, It e) const
Copy the internal information to the range between b and e it is for boost asio APIs.
Definition: property.hpp:79
boost::container::static_vector< char, N > buf_
Definition: property.hpp:112
Definition: property.hpp:185
string_property(property::id id, buffer buf, bool already_checked)
Definition: property.hpp:186
Definition: property.hpp:195
void add_const_buffer_sequence(std::vector< as::const_buffer > &v) const
Add const buffer sequence into the given buffer.
Definition: property.hpp:205
constexpr std::size_t val() const
Definition: property.hpp:248
boost::container::static_vector< char, 4 > value_
Definition: property.hpp:254
property::id id_
Definition: property.hpp:253
variable_property(property::id id, std::size_t value)
Definition: property.hpp:196
static constexpr ostream_format const of_
Definition: property.hpp:252
std::size_t size() const
Get whole size of sequence.
Definition: property.hpp:236
static constexpr std::size_t num_of_const_buffer_sequence()
Get number of element of const_buffer_sequence.
Definition: property.hpp:244
void fill(It b, It e) const
Copy the internal information to the range between b and e it is for boost asio APIs.
Definition: property.hpp:217
property::id id() const
Get property::id.
Definition: property.hpp:228