24#ifndef __mqtt_properties_h
25#define __mqtt_properties_h
28 #include "MQTTProperties.h"
36#include <initializer_list>
57 void copy(
const MQTTProperty& other);
155 const MQTTProperty&
c_struct()
const {
return prop_; }
166 return ::MQTTPropertyName(prop_.identifier);
183 return (uint8_t) prop.
c_struct().value.byte;
192 return (uint16_t) prop.
c_struct().value.integer2;
201 return (int16_t) prop.
c_struct().value.integer2;
210 return (uint32_t) prop.
c_struct().value.integer4;
219 return (int32_t) prop.
c_struct().value.integer4;
238 string name = (!prop.
c_struct().value.data.data) ?
string()
241 string value = (!prop.
c_struct().value.value.data) ?
string()
244 return std::make_tuple(std::move(name), std::move(value));
261 MQTTProperties props_;
280 : props_(::MQTTProperties_copy(&other.props_)) {}
286 std::memset(&other.props_, 0,
sizeof(MQTTProperties));
293 props_ = ::MQTTProperties_copy(&cprops);
308 const MQTTProperties&
c_struct()
const {
return props_; }
326 bool empty()
const {
return props_.count == 0; }
331 size_t size()
const {
return size_t(props_.count); }
337 ::MQTTProperties_add(&props_, &prop.
c_struct());
343 ::MQTTProperties_free(&props_);
351 return ::MQTTProperties_hasProperty(
const_cast<MQTTProperties*
>(&props_),
352 MQTTPropertyCodes(propid)) != 0;
365 return size_t(::MQTTProperties_propertyCount(
366 const_cast<MQTTProperties*
>(&props_), MQTTPropertyCodes(propid)));
393 MQTTProperty* prop = MQTTProperties_getPropertyAt(
394 const_cast<MQTTProperties*
>(&props.
c_struct()),
395 MQTTPropertyCodes(propid),
int(idx));
412 return get<T>(props, propid, 0);
Definition properties.h:256
bool contains(property::code propid) const
Definition properties.h:350
property get(property::code propid, size_t idx=0)
properties(std::initializer_list< property > props)
bool empty() const
Definition properties.h:326
size_t size() const
Definition properties.h:331
properties(const properties &other)
Definition properties.h:279
~properties()
Definition properties.h:303
properties(const MQTTProperties &cprops)
Definition properties.h:292
properties & operator=(properties &&rhs)
friend T get(const properties &props, property::code propid, size_t idx)
Definition properties.h:391
void add(const property &prop)
Definition properties.h:336
size_t count(property::code propid) const
Definition properties.h:364
properties & operator=(const properties &rhs)
const MQTTProperties & c_struct() const
Definition properties.h:308
void clear()
Definition properties.h:342
properties(properties &&other)
Definition properties.h:285
Definition properties.h:51
property & operator=(const property &rhs)
const MQTTProperty & c_struct() const
Definition properties.h:155
code
Definition properties.h:63
@ MAXIMUM_QOS
Definition properties.h:84
@ WILL_DELAY_INTERVAL
Definition properties.h:76
@ SERVER_REFERENCE
Definition properties.h:79
@ TOPIC_ALIAS
Definition properties.h:83
@ ASSIGNED_CLIENT_IDENTIFER
Definition properties.h:71
@ PAYLOAD_FORMAT_INDICATOR
Definition properties.h:64
@ RECEIVE_MAXIMUM
Definition properties.h:81
@ TOPIC_ALIAS_MAXIMUM
Definition properties.h:82
@ REQUEST_PROBLEM_INFORMATION
Definition properties.h:75
@ CONTENT_TYPE
Definition properties.h:66
@ AUTHENTICATION_DATA
Definition properties.h:74
@ RETAIN_AVAILABLE
Definition properties.h:85
@ RESPONSE_INFORMATION
Definition properties.h:78
@ REQUEST_RESPONSE_INFORMATION
Definition properties.h:77
@ SHARED_SUBSCRIPTION_AVAILABLE
Definition properties.h:90
@ REASON_STRING
Definition properties.h:80
@ SUBSCRIPTION_IDENTIFIER
Definition properties.h:69
@ SERVER_KEEP_ALIVE
Definition properties.h:72
@ WILDCARD_SUBSCRIPTION_AVAILABLE
Definition properties.h:88
@ SESSION_EXPIRY_INTERVAL
Definition properties.h:70
@ AUTHENTICATION_METHOD
Definition properties.h:73
@ MAXIMUM_PACKET_SIZE
Definition properties.h:87
@ RESPONSE_TOPIC
Definition properties.h:67
@ SUBSCRIPTION_IDENTIFIERS_AVAILABLE
Definition properties.h:89
@ MESSAGE_EXPIRY_INTERVAL
Definition properties.h:65
@ CORRELATION_DATA
Definition properties.h:68
@ USER_PROPERTY
Definition properties.h:86
code type() const
Definition properties.h:160
property & operator=(property &&rhs)
property(code c, int32_t val)
property(const property &other)
property(MQTTProperty &&cprop)
property(const MQTTProperty &cprop)
property(property &&other)
property(code c, string_ref name, string_ref val)
const char * type_name() const
Definition properties.h:165
property(code c, string_ref val)
#define PAHO_MQTTPP_EXPORT
Definition export.h:40
Definition async_client.h:49
int16_t get< int16_t >(const property &prop)
Definition properties.h:200
T get(const property &)
Definition properties.h:175
std::tuple< string, string > string_pair
Definition properties.h:43
string get< string >(const property &prop)
Definition properties.h:227
uint16_t get< uint16_t >(const property &prop)
Definition properties.h:191
std::bad_cast bad_cast
Definition exception.h:38
std::string string
Definition types.h:40
uint8_t get< uint8_t >(const property &prop)
Definition properties.h:182
int32_t get< int32_t >(const property &prop)
Definition properties.h:218
string_pair get< string_pair >(const property &prop)
Definition properties.h:237
uint32_t get< uint32_t >(const property &prop)
Definition properties.h:209