7 #if !defined(MQTT_PROPERTY_PARSE_HPP)
8 #define MQTT_PROPERTY_PARSE_HPP
24 if (buf.empty())
return nullopt;
30 if (buf.size() < 1)
return nullopt;
36 if (buf.size() < 4)
return nullopt;
42 if (buf.size() < 2)
return nullopt;
43 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
44 if (buf.size() < 2U + len)
return nullopt;
46 buf.remove_prefix(2 + len);
50 if (buf.size() < 2)
return nullopt;
51 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
52 if (buf.size() < 2U + len)
return nullopt;
54 buf.remove_prefix(2 + len);
58 if (buf.size() < 2)
return nullopt;
59 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
60 if (buf.size() < 2U + len)
return nullopt;
62 buf.remove_prefix(2 + len);
67 auto val = std::get<0>(val_consumed);
68 auto consumed = std::get<1>(val_consumed);
69 if (consumed == 0)
return nullopt;
71 buf.remove_prefix(consumed);
75 if (buf.size() < 4)
return nullopt;
81 if (buf.size() < 2)
return nullopt;
82 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
83 if (buf.size() < 2U + len)
return nullopt;
85 buf.remove_prefix(2 + len);
89 if (buf.size() < 2)
return nullopt;
95 if (buf.size() < 2)
return nullopt;
96 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
97 if (buf.size() < 2U + len)
return nullopt;
99 buf.remove_prefix(2 + len);
103 if (buf.size() < 2)
return nullopt;
104 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
105 if (buf.size() < 2U + len)
return nullopt;
107 buf.remove_prefix(2 + len);
111 if (buf.size() < 1)
return nullopt;
113 buf.remove_prefix(1);
117 if (buf.size() < 4)
return nullopt;
119 buf.remove_prefix(4);
123 if (buf.size() < 1)
return nullopt;
125 buf.remove_prefix(1);
129 if (buf.size() < 2)
return nullopt;
130 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
131 if (buf.size() < 2U + len)
return nullopt;
133 buf.remove_prefix(2 + len);
137 if (buf.size() < 2)
return nullopt;
138 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
139 if (buf.size() < 2U + len)
return nullopt;
141 buf.remove_prefix(2 + len);
145 if (buf.size() < 2)
return nullopt;
146 auto len =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
147 if (buf.size() < 2U + len)
return nullopt;
149 buf.remove_prefix(2 + len);
153 if (buf.size() < 2)
return nullopt;
155 buf.remove_prefix(2);
159 if (buf.size() < 2)
return nullopt;
161 buf.remove_prefix(2);
165 if (buf.size() < 2)
return nullopt;
166 auto p =
topic_alias(buf.begin(), std::next(buf.begin(), 2));
167 buf.remove_prefix(2);
171 if (buf.size() < 1)
return nullopt;
172 auto p =
maximum_qos(buf.begin(), std::next(buf.begin(), 1));
173 buf.remove_prefix(1);
177 if (buf.size() < 1)
return nullopt;
179 buf.remove_prefix(1);
183 if (buf.size() < 2)
return nullopt;
184 auto keylen =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
185 if (buf.size() < 2U + keylen)
return nullopt;
186 auto key = buf.
substr(2, keylen);
187 buf.remove_prefix(2 + keylen);
189 if (buf.size() < 2)
return nullopt;
190 auto vallen =
make_uint16_t(buf.begin(), std::next(buf.begin(), 2));
191 if (buf.size() < 2U + vallen)
return nullopt;
192 auto val = buf.
substr(2, vallen);
195 buf.remove_prefix(2 + vallen);
200 if (buf.size() < 4)
return nullopt;
202 buf.remove_prefix(4);
206 if (buf.size() < 1)
return nullopt;
208 buf.remove_prefix(1);
212 if (buf.size() < 1)
return nullopt;
214 buf.remove_prefix(1);
218 if (buf.size() < 1)
return nullopt;
220 buf.remove_prefix(1);
233 std::vector<property_variant> props;
buffer that has string_view interface This class provides string_view interface. This class hold stri...
Definition: buffer.hpp:30
buffer substr(std::size_t offset, std::size_t length=string_view::npos) const &
get substring The returned buffer ragnge is the same as std::string_view::substr()....
Definition: buffer.hpp:68
Definition: property.hpp:345
Definition: property.hpp:373
Definition: property.hpp:367
Definition: property.hpp:301
Definition: property.hpp:313
Definition: property.hpp:641
Definition: property.hpp:495
Definition: property.hpp:285
Definition: property.hpp:439
Definition: property.hpp:445
Definition: property.hpp:307
Definition: property.hpp:517
Definition: property.hpp:351
Definition: property.hpp:433
Definition: property.hpp:327
Definition: property.hpp:692
Definition: property.hpp:675
Definition: property.hpp:319
Definition: property.hpp:462
Definition: property.hpp:479
Definition: property.hpp:534
Definition: property.hpp:658
Definition: property.hpp:395
std::vector< property_variant > parse(buffer buf)
Definition: property_parse.hpp:232
id
Definition: property_id.hpp:19
@ subscription_identifier
@ request_problem_information
@ message_expiry_interval
@ shared_subscription_available
@ request_response_information
@ session_expiry_interval
@ assigned_client_identifier
@ subscription_identifier_available
@ payload_format_indicator
@ wildcard_subscription_available
optional< property_variant > parse_one(buffer &buf)
Definition: property_parse.hpp:23
variant< property::payload_format_indicator, property::message_expiry_interval, property::content_type, property::response_topic, property::correlation_data, property::subscription_identifier, property::session_expiry_interval, property::assigned_client_identifier, property::server_keep_alive, property::authentication_method, property::authentication_data, property::request_problem_information, property::will_delay_interval, property::request_response_information, property::response_information, property::server_reference, property::reason_string, property::receive_maximum, property::topic_alias_maximum, property::topic_alias, property::maximum_qos, property::retain_available, property::user_property, property::maximum_packet_size, property::wildcard_subscription_available, property::subscription_identifier_available, property::shared_subscription_available > property_variant
Definition: property_variant.hpp:49
constexpr std::remove_reference_t< T > && force_move(T &&t)
Definition: move.hpp:20
constexpr std::tuple< std::size_t, std::size_t > variable_length(T const &bytes)
Definition: variable_length.hpp:42
constexpr std::uint16_t make_uint16_t(It b, It e)
Definition: two_byte_util.hpp:34
Definition: exception.hpp:109