mirror of
https://github.com/eclipse/paho.mqtt.cpp.git
synced 2025-05-09 19:31:22 +08:00
Fixed doc comment and deprecation warnings.
This commit is contained in:
parent
381caad141
commit
91bfc64bdd
@ -130,8 +130,7 @@ int main(int argc, char* argv[])
|
|||||||
auto top = mqtt::topic(cli, "data/time", QOS);
|
auto top = mqtt::topic(cli, "data/time", QOS);
|
||||||
cout << "Publishing data..." << endl;
|
cout << "Publishing data..." << endl;
|
||||||
|
|
||||||
while (timestamp() % DELTA_MS != 0)
|
while (timestamp() % DELTA_MS != 0);
|
||||||
;
|
|
||||||
|
|
||||||
uint64_t t = timestamp(), tlast = t, tstart = t;
|
uint64_t t = timestamp(), tlast = t, tstart = t;
|
||||||
|
|
||||||
|
@ -205,8 +205,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Just block till user tells us to quit.
|
// Just block till user tells us to quit.
|
||||||
|
|
||||||
while (std::tolower(std::cin.get()) != 'q')
|
while (std::tolower(std::cin.get()) != 'q');
|
||||||
;
|
|
||||||
|
|
||||||
// Disconnect
|
// Disconnect
|
||||||
|
|
||||||
|
@ -84,8 +84,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
mqtt::client cli(SERVER_ADDRESS, CLIENT_ID, mqtt::create_options(MQTTVERSION_5));
|
mqtt::client cli(SERVER_ADDRESS, CLIENT_ID, mqtt::create_options(MQTTVERSION_5));
|
||||||
|
|
||||||
auto connOpts = mqtt::connect_options_builder()
|
auto connOpts = mqtt::connect_options_builder::v5()
|
||||||
.mqtt_version(MQTTVERSION_5)
|
|
||||||
.automatic_reconnect(seconds(2), seconds(30))
|
.automatic_reconnect(seconds(2), seconds(30))
|
||||||
.clean_start(false)
|
.clean_start(false)
|
||||||
.properties({{mqtt::property::SESSION_EXPIRY_INTERVAL, INFINITE}})
|
.properties({{mqtt::property::SESSION_EXPIRY_INTERVAL, INFINITE}})
|
||||||
|
@ -196,7 +196,6 @@ private:
|
|||||||
* server, which allows for off-line message buffering.
|
* server, which allows for off-line message buffering.
|
||||||
* This allows the caller to specify a user-defined persistence object,
|
* This allows the caller to specify a user-defined persistence object,
|
||||||
* or use no persistence.
|
* or use no persistence.
|
||||||
* @param opts The create options
|
|
||||||
* @throw exception if an argument is invalid
|
* @throw exception if an argument is invalid
|
||||||
*/
|
*/
|
||||||
void create();
|
void create();
|
||||||
@ -223,8 +222,7 @@ public:
|
|||||||
* as a URI.
|
* as a URI.
|
||||||
* @param clientId a client identifier that is unique on the server
|
* @param clientId a client identifier that is unique on the server
|
||||||
* being connected to
|
* being connected to
|
||||||
* @param persistence The user persistence structure. If this is null,
|
* @param persistence The persistence that the client should use.
|
||||||
* then no persistence is used.
|
|
||||||
* @throw exception if an argument is invalid
|
* @throw exception if an argument is invalid
|
||||||
*/
|
*/
|
||||||
async_client(
|
async_client(
|
||||||
@ -243,7 +241,7 @@ public:
|
|||||||
* being connected to
|
* being connected to
|
||||||
* @param maxBufferedMessages the maximum number of messages allowed to
|
* @param maxBufferedMessages the maximum number of messages allowed to
|
||||||
* be buffered while not connected
|
* be buffered while not connected
|
||||||
* @param persistDir The directory to use for persistence data
|
* @param persistence The persistence that the client should use.
|
||||||
* @throw exception if an argument is invalid
|
* @throw exception if an argument is invalid
|
||||||
*/
|
*/
|
||||||
async_client(
|
async_client(
|
||||||
@ -262,7 +260,7 @@ public:
|
|||||||
* @param clientId a client identifier that is unique on the server
|
* @param clientId a client identifier that is unique on the server
|
||||||
* being connected to
|
* being connected to
|
||||||
* @param opts The create options
|
* @param opts The create options
|
||||||
* @param persistDir The directory to use for persistence data
|
* @param persistence The persistence that the client should use.
|
||||||
* @throw exception if an argument is invalid
|
* @throw exception if an argument is invalid
|
||||||
*/
|
*/
|
||||||
async_client(
|
async_client(
|
||||||
@ -582,7 +580,7 @@ public:
|
|||||||
* server.
|
* server.
|
||||||
* @param userContext optional object used to pass context to the
|
* @param userContext optional object used to pass context to the
|
||||||
* callback. Use @em nullptr if not required.
|
* callback. Use @em nullptr if not required.
|
||||||
* @param cb
|
* @param cb Listener callback object
|
||||||
* @return token used to track and wait for the publish to complete. The
|
* @return token used to track and wait for the publish to complete. The
|
||||||
* token will be passed to callback methods if set.
|
* token will be passed to callback methods if set.
|
||||||
*/
|
*/
|
||||||
@ -631,7 +629,7 @@ public:
|
|||||||
* Subscribe to a topic, which may include wildcards.
|
* Subscribe to a topic, which may include wildcards.
|
||||||
* @param topicFilter the topic to subscribe to, which can include
|
* @param topicFilter the topic to subscribe to, which can include
|
||||||
* wildcards.
|
* wildcards.
|
||||||
* @param qos the maximum quality of service at which to subscribe.
|
* @param qos The maximum quality of service at which to subscribe.
|
||||||
* Messages published at a lower quality of service will be
|
* Messages published at a lower quality of service will be
|
||||||
* received at the published QoS. Messages published at a
|
* received at the published QoS. Messages published at a
|
||||||
* higher quality of service will be received using the QoS
|
* higher quality of service will be received using the QoS
|
||||||
@ -651,8 +649,9 @@ public:
|
|||||||
) override;
|
) override;
|
||||||
/**
|
/**
|
||||||
* Subscribe to multiple topics, each of which may include wildcards.
|
* Subscribe to multiple topics, each of which may include wildcards.
|
||||||
* @param topicFilters
|
* @param topicFilters The collection of topic filters to subscribe to,
|
||||||
* @param qos the maximum quality of service at which to subscribe.
|
* any of which can include wildcards
|
||||||
|
* @param qos The maximum quality of service at which to subscribe.
|
||||||
* Messages published at a lower quality of service will be
|
* Messages published at a lower quality of service will be
|
||||||
* received at the published QoS. Messages published at a
|
* received at the published QoS. Messages published at a
|
||||||
* higher quality of service will be received using the QoS
|
* higher quality of service will be received using the QoS
|
||||||
@ -669,13 +668,14 @@ public:
|
|||||||
) override;
|
) override;
|
||||||
/**
|
/**
|
||||||
* Subscribes to multiple topics, each of which may include wildcards.
|
* Subscribes to multiple topics, each of which may include wildcards.
|
||||||
* @param topicFilters
|
* @param topicFilters The collection of topic filters to subscribe to,
|
||||||
* @param qos the maximum quality of service at which to subscribe.
|
* any of which can include wildcards
|
||||||
|
* @param qos The maximum quality of service at which to subscribe.
|
||||||
* Messages published at a lower quality of service will be
|
* Messages published at a lower quality of service will be
|
||||||
* received at the published QoS. Messages published at a
|
* received at the published QoS. Messages published at a
|
||||||
* higher quality of service will be received using the QoS
|
* higher quality of service will be received using the QoS
|
||||||
* specified on the subscribe.
|
* specified on the subscribe.
|
||||||
* @param userContext optional object used to pass context to the
|
* @param userContext Optional object used to pass context to the
|
||||||
* callback. Use @em nullptr if not required.
|
* callback. Use @em nullptr if not required.
|
||||||
* @param cb listener that will be notified when subscribe has completed
|
* @param cb listener that will be notified when subscribe has completed
|
||||||
* @param opts The MQTT v5 subscribe options (one for each topic)
|
* @param opts The MQTT v5 subscribe options (one for each topic)
|
||||||
@ -691,17 +691,17 @@ public:
|
|||||||
) override;
|
) override;
|
||||||
/**
|
/**
|
||||||
* Requests the server unsubscribe the client from a topic.
|
* Requests the server unsubscribe the client from a topic.
|
||||||
* @param topicFilter the topic to unsubscribe from. It must match a
|
* @param topicFilter The topic to unsubscribe from. It must match a
|
||||||
* topicFilter specified on an earlier subscribe.
|
* topicFilter specified on an earlier subscribe.
|
||||||
* @param props The MQTT v5 properties.
|
* @param props The MQTT v5 properties.
|
||||||
* @return token used to track and wait for the unsubscribe to complete.
|
* @return token Used to track and wait for the unsubscribe to complete.
|
||||||
* The token will be passed to callback methods if set.
|
* The token will be passed to callback methods if set.
|
||||||
*/
|
*/
|
||||||
token_ptr unsubscribe(const string& topicFilter, const properties& props = properties())
|
token_ptr unsubscribe(const string& topicFilter, const properties& props = properties())
|
||||||
override;
|
override;
|
||||||
/**
|
/**
|
||||||
* Requests the server unsubscribe the client from one or more topics.
|
* Requests the server unsubscribe the client from one or more topics.
|
||||||
* @param topicFilters one or more topics to unsubscribe from. Each
|
* @param topicFilters One or more topics to unsubscribe from. Each
|
||||||
* topicFilter must match one specified on an
|
* topicFilter must match one specified on an
|
||||||
* earlier subscribe.
|
* earlier subscribe.
|
||||||
* @param props The MQTT v5 properties.
|
* @param props The MQTT v5 properties.
|
||||||
@ -713,7 +713,9 @@ public:
|
|||||||
) override;
|
) override;
|
||||||
/**
|
/**
|
||||||
* Requests the server unsubscribe the client from one or more topics.
|
* Requests the server unsubscribe the client from one or more topics.
|
||||||
* @param topicFilters
|
* @param topicFilters One or more topics to unsubscribe from. Each
|
||||||
|
* topicFilter must match one specified on an
|
||||||
|
* earlier subscribe.
|
||||||
* @param userContext optional object used to pass context to the
|
* @param userContext optional object used to pass context to the
|
||||||
* callback. Use @em nullptr if not required.
|
* callback. Use @em nullptr if not required.
|
||||||
* @param cb listener that will be notified when unsubscribe has
|
* @param cb listener that will be notified when unsubscribe has
|
||||||
|
@ -184,7 +184,7 @@ public:
|
|||||||
virtual connect_response connect();
|
virtual connect_response connect();
|
||||||
/**
|
/**
|
||||||
* Connects to an MQTT server using the specified options.
|
* Connects to an MQTT server using the specified options.
|
||||||
* @param opts
|
* @param opts The connect options
|
||||||
*/
|
*/
|
||||||
virtual connect_response connect(connect_options opts);
|
virtual connect_response connect(connect_options opts);
|
||||||
/**
|
/**
|
||||||
@ -327,8 +327,8 @@ public:
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Subscribe to a topic, which may include wildcards using a QoS of 1.
|
* Subscribe to a topic, which may include wildcards using a QoS of 1.
|
||||||
* @param topicFilter
|
* @param topicFilter A single topic to subscribe
|
||||||
* @param props The MQTT v5 properties.
|
maked * @param props The MQTT v5 properties.
|
||||||
* @param opts The MQTT v5 subscribe options for the topic
|
* @param opts The MQTT v5 subscribe options for the topic
|
||||||
* @return The "subscribe" response from the server.
|
* @return The "subscribe" response from the server.
|
||||||
*/
|
*/
|
||||||
|
@ -106,7 +106,7 @@ class connect_options
|
|||||||
* @note In the connect options, by default, the Paho C treats
|
* @note In the connect options, by default, the Paho C treats
|
||||||
* nullptr char arrays as unset values, so we keep that semantic and
|
* nullptr char arrays as unset values, so we keep that semantic and
|
||||||
* only set those char arrays if the string is non-empty.
|
* only set those char arrays if the string is non-empty.
|
||||||
* @param str The C++ string object.
|
* @param sr The C++ string object.
|
||||||
* @return Pointer to a NUL terminated string. This is only valid until
|
* @return Pointer to a NUL terminated string. This is only valid until
|
||||||
* the next time the string is updated.
|
* the next time the string is updated.
|
||||||
*/
|
*/
|
||||||
@ -295,8 +295,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
const_string_collection_ptr get_servers() const { return serverURIs_; }
|
const_string_collection_ptr get_servers() const { return serverURIs_; }
|
||||||
/**
|
/**
|
||||||
* Gets the version of MQTT to be used on the connect.
|
* Gets the version of MQTT to be used for the connection.
|
||||||
* @return
|
* @return The version of MQTT to be used for the connection:
|
||||||
* @li MQTTVERSION_DEFAULT (0) = default: start with 3.1.1, and if that
|
* @li MQTTVERSION_DEFAULT (0) = default: start with 3.1.1, and if that
|
||||||
* fails, fall back to 3.1
|
* fails, fall back to 3.1
|
||||||
* @li MQTTVERSION_3_1 (3) = only try version 3.1
|
* @li MQTTVERSION_3_1 (3) = only try version 3.1
|
||||||
@ -333,8 +333,8 @@ public:
|
|||||||
* This will only take effect if the version is _already_ set to v3.x
|
* This will only take effect if the version is _already_ set to v3.x
|
||||||
* (not v5).
|
* (not v5).
|
||||||
*
|
*
|
||||||
* @param clean @em true if the server should NOT remember state for the
|
* @param cleanSession @em true if the server should NOT remember state
|
||||||
* client across reconnects, @em false otherwise.
|
* for the client across reconnects, @em false otherwise.
|
||||||
*/
|
*/
|
||||||
void set_clean_session(bool cleanSession);
|
void set_clean_session(bool cleanSession);
|
||||||
/**
|
/**
|
||||||
@ -347,8 +347,8 @@ public:
|
|||||||
*
|
*
|
||||||
* This will only take effect if the MQTT version is set to v5
|
* This will only take effect if the MQTT version is set to v5
|
||||||
*
|
*
|
||||||
* @param clean @em true if the server should NOT remember state for the
|
* @param cleanStart @em true if the server should NOT remember state
|
||||||
* client across reconnects, @em false otherwise.
|
* for the client across reconnects, @em false otherwise.
|
||||||
*/
|
*/
|
||||||
void set_clean_start(bool cleanStart);
|
void set_clean_start(bool cleanStart);
|
||||||
/**
|
/**
|
||||||
@ -463,7 +463,9 @@ public:
|
|||||||
* call it before setting any other version-specific options. @sa
|
* call it before setting any other version-specific options. @sa
|
||||||
* connect_options::v5()
|
* connect_options::v5()
|
||||||
*/
|
*/
|
||||||
void set_mqtt_version(int mqttVersion);
|
[[deprecated("Use a versioned creation function to construct for the desired version"
|
||||||
|
)]] void
|
||||||
|
set_mqtt_version(int mqttVersion);
|
||||||
/**
|
/**
|
||||||
* Enable or disable automatic reconnects.
|
* Enable or disable automatic reconnects.
|
||||||
* The retry intervals are not affected.
|
* The retry intervals are not affected.
|
||||||
@ -747,15 +749,16 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets the user name to use for the connection.
|
* Sets the user name for the connection.
|
||||||
* @param userName
|
* @param userName The user name for the connection.
|
||||||
*/
|
*/
|
||||||
auto user_name(string_ref userName) -> self& {
|
auto user_name(string_ref userName) -> self& {
|
||||||
opts_.set_user_name(userName);
|
opts_.set_user_name(userName);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets the password to use for the connection.
|
* Sets the password for the connection.
|
||||||
|
* @param password The password for the connection.
|
||||||
*/
|
*/
|
||||||
auto password(binary_ref password) -> self& {
|
auto password(binary_ref password) -> self& {
|
||||||
opts_.set_password(password);
|
opts_.set_password(password);
|
||||||
@ -853,7 +856,9 @@ public:
|
|||||||
* this function, call it before setting any other version-specific
|
* this function, call it before setting any other version-specific
|
||||||
* options. @sa connect_options_builder::v5()
|
* options. @sa connect_options_builder::v5()
|
||||||
*/
|
*/
|
||||||
auto mqtt_version(int ver) -> self& {
|
[[deprecated("Use a versioned creation function to construct for the desired version"
|
||||||
|
)]] auto
|
||||||
|
mqtt_version(int ver) -> self& {
|
||||||
opts_.set_mqtt_version(ver);
|
opts_.set_mqtt_version(ver);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public:
|
|||||||
* being connected to
|
* being connected to
|
||||||
* @param maxBufferedMessages the maximum number of messages allowed to
|
* @param maxBufferedMessages the maximum number of messages allowed to
|
||||||
* be buffered while not connected
|
* be buffered while not connected
|
||||||
* @param persistDir The directory to use for persistence data
|
* @param persistence The persistence that the client should use.
|
||||||
* @throw exception if an argument is invalid
|
* @throw exception if an argument is invalid
|
||||||
*/
|
*/
|
||||||
create_options(
|
create_options(
|
||||||
@ -155,7 +155,7 @@ public:
|
|||||||
* @param clientId a client identifier that is unique on the server
|
* @param clientId a client identifier that is unique on the server
|
||||||
* being connected to
|
* being connected to
|
||||||
* @param opts The create options
|
* @param opts The create options
|
||||||
* @param persistDir The directory to use for persistence data
|
* @param persistence The persistence that the client should use.
|
||||||
* @throw exception if an argument is invalid
|
* @throw exception if an argument is invalid
|
||||||
*/
|
*/
|
||||||
create_options(
|
create_options(
|
||||||
@ -199,7 +199,7 @@ public:
|
|||||||
const string& get_server_uri() const noexcept { return serverURI_; };
|
const string& get_server_uri() const noexcept { return serverURI_; };
|
||||||
/**
|
/**
|
||||||
* Set the client identifier.
|
* Set the client identifier.
|
||||||
* @param The client identifier.
|
* @param clientId The client identifier.
|
||||||
*/
|
*/
|
||||||
void set_client_id(const string& clientId) { clientId_ = clientId; }
|
void set_client_id(const string& clientId) { clientId_ = clientId; }
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +49,7 @@ class delivery_token : public token
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the message to which this token corresponds.
|
* Sets the message to which this token corresponds.
|
||||||
* @param msg
|
* @param msg The message to which this token corresponds.
|
||||||
*/
|
*/
|
||||||
void set_message(const_message_ptr msg) { msg_ = msg; }
|
void set_message(const_message_ptr msg) { msg_ = msg; }
|
||||||
|
|
||||||
|
@ -60,12 +60,12 @@ public:
|
|||||||
virtual ~iaction_listener() {}
|
virtual ~iaction_listener() {}
|
||||||
/**
|
/**
|
||||||
* This method is invoked when an action fails.
|
* This method is invoked when an action fails.
|
||||||
* @param asyncActionToken
|
* @param asyncActionToken The token
|
||||||
*/
|
*/
|
||||||
virtual void on_failure(const token& asyncActionToken) = 0;
|
virtual void on_failure(const token& asyncActionToken) = 0;
|
||||||
/**
|
/**
|
||||||
* This method is invoked when an action has completed successfully.
|
* This method is invoked when an action has completed successfully.
|
||||||
* @param asyncActionToken
|
* @param asyncActionToken The token
|
||||||
*/
|
*/
|
||||||
virtual void on_success(const token& asyncActionToken) = 0;
|
virtual void on_success(const token& asyncActionToken) = 0;
|
||||||
};
|
};
|
||||||
|
@ -196,11 +196,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Publishes a message to a topic on the server
|
* Publishes a message to a topic on the server
|
||||||
* @param topic The topic to deliver the message to
|
* @param topic The topic to deliver the message to
|
||||||
* @param payload the bytes to use as the message payload
|
* @param payload The bytes to use as the message payload
|
||||||
* @param n the number of bytes in the payload
|
* @param n The number of bytes in the payload
|
||||||
* @param qos the Quality of Service to deliver the message at. Valid
|
* @param qos The Quality of Service to deliver the message at. Valid
|
||||||
* values are 0, 1 or 2.
|
* values are 0, 1 or 2.
|
||||||
* @param retained whether or not this message should be retained by the
|
* @param retained Whether or not this message should be retained by the
|
||||||
* server.
|
* server.
|
||||||
* @return token used to track and wait for the publish to complete. The
|
* @return token used to track and wait for the publish to complete. The
|
||||||
* token will be passed to callback methods if set.
|
* token will be passed to callback methods if set.
|
||||||
@ -220,15 +220,15 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Publishes a message to a topic on the server
|
* Publishes a message to a topic on the server
|
||||||
* @param topic The topic to deliver the message to
|
* @param topic The topic to deliver the message to
|
||||||
* @param payload the bytes to use as the message payload
|
* @param payload The bytes to use as the message payload
|
||||||
* @param n the number of bytes in the payload
|
* @param n The number of bytes in the payload
|
||||||
* @param qos the Quality of Service to deliver the message at. Valid
|
* @param qos The Quality of Service to deliver the message at. Valid
|
||||||
* values are 0, 1 or 2.
|
* values are 0, 1 or 2.
|
||||||
* @param retained whether or not this message should be retained by the
|
* @param retained whether or not this message should be retained by the
|
||||||
* server.
|
* server.
|
||||||
* @param userContext optional object used to pass context to the
|
* @param userContext Optional object used to pass context to the
|
||||||
* callback. Use @em nullptr if not required.
|
* callback. Use @em nullptr if not required.
|
||||||
* @param cb
|
* @param cb The listener callback object
|
||||||
* @return token used to track and wait for the publish to complete. The
|
* @return token used to track and wait for the publish to complete. The
|
||||||
* token will be passed to callback methods if set.
|
* token will be passed to callback methods if set.
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +79,7 @@ private:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the dup flag in the underlying message
|
* Set the dup flag in the underlying message
|
||||||
* @param dup
|
* @param dup Whether to set the dup flag.
|
||||||
*/
|
*/
|
||||||
void set_duplicate(bool dup) { msg_.dup = to_int(dup); }
|
void set_duplicate(bool dup) { msg_.dup = to_int(dup); }
|
||||||
|
|
||||||
|
@ -224,7 +224,8 @@ inline uint16_t get<uint16_t>(const property& prop) {
|
|||||||
* `get<uint16_t>()`
|
* `get<uint16_t>()`
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline int16_t get<int16_t>(const property& prop) {
|
[[deprecated("Integer properties are unsigned. Use get<uint16_t>()")]] inline int16_t
|
||||||
|
get<int16_t>(const property& prop) {
|
||||||
return (int16_t)prop.c_struct().value.integer2;
|
return (int16_t)prop.c_struct().value.integer2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +245,8 @@ inline uint32_t get<uint32_t>(const property& prop) {
|
|||||||
* `get<uint32_t>()`
|
* `get<uint32_t>()`
|
||||||
*/
|
*/
|
||||||
template <>
|
template <>
|
||||||
inline int32_t get<int32_t>(const property& prop) {
|
[[deprecated("Integer properties are unsigned. Use get<uint32_t>()")]] inline int32_t
|
||||||
|
get<int32_t>(const property& prop) {
|
||||||
return (int32_t)prop.c_struct().value.integer4;
|
return (int32_t)prop.c_struct().value.integer4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ namespace mqtt {
|
|||||||
* shared pointers, as the "dead" part of the queue will not hold onto a
|
* shared pointers, as the "dead" part of the queue will not hold onto a
|
||||||
* reference count after the item has been removed from the queue.
|
* reference count after the item has been removed from the queue.
|
||||||
*
|
*
|
||||||
* @param T The type of the items to be held in the queue.
|
* @tparam T The type of the items to be held in the queue.
|
||||||
* @param Container The type of the underlying container to use. It must
|
* @tparam Container The type of the underlying container to use. It must
|
||||||
* support back(), front(), push_back(), pop_front().
|
* support back(), front(), push_back(), pop_front().
|
||||||
*/
|
*/
|
||||||
template <typename T, class Container = std::deque<T>>
|
template <typename T, class Container = std::deque<T>>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2013-2016 Frank Pagliughi <fpagliughi@mindspring.com>
|
* Copyright (c) 2013-2024 Frank Pagliughi <fpagliughi@mindspring.com>
|
||||||
*
|
*
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v2.0
|
* are made available under the terms of the Eclipse Public License v2.0
|
||||||
@ -212,13 +212,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
explicit topic_filter(const string& filter);
|
explicit topic_filter(const string& filter);
|
||||||
/**
|
/**
|
||||||
* Determines if the specified topic filter contains any wildcards.
|
* Determines if the specified topic/filter contains any wildcards.
|
||||||
*
|
*
|
||||||
* @param filter The topic filter string to check for wildcards.
|
* @param filter The topic/filter string to check for wildcards.
|
||||||
* @return @em true if any of the fields contain a wildcard, @em false
|
* @return @em true if any of the fields contain a wildcard, @em false
|
||||||
* if not.
|
* if not.
|
||||||
*/
|
*/
|
||||||
static bool has_wildcards(const string& topic);
|
static bool has_wildcards(const string& filter);
|
||||||
/**
|
/**
|
||||||
* Determines if this topic filter contains any wildcards.
|
* Determines if this topic filter contains any wildcards.
|
||||||
*
|
*
|
||||||
|
@ -86,7 +86,7 @@ private:
|
|||||||
* while others expect NULL pointers for missing parameters.
|
* while others expect NULL pointers for missing parameters.
|
||||||
* So we always return a pointer to a valid C char array, even when
|
* So we always return a pointer to a valid C char array, even when
|
||||||
* empty.
|
* empty.
|
||||||
* @param str The C++ string object.
|
* @param sr The C++ string object.
|
||||||
* @return Pointer to a NUL terminated string. This is only valid until
|
* @return Pointer to a NUL terminated string. This is only valid until
|
||||||
* the next time the string is updated. This is never nullptr.
|
* the next time the string is updated. This is never nullptr.
|
||||||
*/
|
*/
|
||||||
|
@ -202,7 +202,7 @@ std::ostream& operator<<(std::ostream& os, const property& prop)
|
|||||||
case MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER:
|
case MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER:
|
||||||
case MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER:
|
case MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER:
|
||||||
case MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER:
|
case MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER:
|
||||||
os << get<int>(prop);
|
os << get<uint32_t>(prop);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MQTTPROPERTY_TYPE_BINARY_DATA: {
|
case MQTTPROPERTY_TYPE_BINARY_DATA: {
|
||||||
|
@ -255,7 +255,9 @@ TEST_CASE("connect_options move_constructor", "[options]")
|
|||||||
// Check that we got the correct properties
|
// Check that we got the correct properties
|
||||||
REQUIRE(1 == opts.get_properties().size());
|
REQUIRE(1 == opts.get_properties().size());
|
||||||
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
||||||
REQUIRE(42 == get<int>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(
|
||||||
|
42 == get<uint32_t>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL)
|
||||||
|
);
|
||||||
|
|
||||||
REQUIRE(copts.connectProperties == &opts.get_properties().c_struct());
|
REQUIRE(copts.connectProperties == &opts.get_properties().c_struct());
|
||||||
}
|
}
|
||||||
@ -317,7 +319,9 @@ TEST_CASE("connect_options copy_assignment", "[options]")
|
|||||||
// Check that we got the correct properties
|
// Check that we got the correct properties
|
||||||
REQUIRE(1 == opts.get_properties().size());
|
REQUIRE(1 == opts.get_properties().size());
|
||||||
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
||||||
REQUIRE(42 == get<int>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(
|
||||||
|
42 == get<uint32_t>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL)
|
||||||
|
);
|
||||||
|
|
||||||
REQUIRE(copts.connectProperties == &opts.get_properties().c_struct());
|
REQUIRE(copts.connectProperties == &opts.get_properties().c_struct());
|
||||||
}
|
}
|
||||||
@ -381,7 +385,9 @@ TEST_CASE("connect_options move_assignment", "[options]")
|
|||||||
// Check that we got the correct properties
|
// Check that we got the correct properties
|
||||||
REQUIRE(1 == opts.get_properties().size());
|
REQUIRE(1 == opts.get_properties().size());
|
||||||
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
||||||
REQUIRE(42 == get<int>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(
|
||||||
|
42 == get<uint32_t>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL)
|
||||||
|
);
|
||||||
|
|
||||||
REQUIRE(copts.connectProperties == &opts.get_properties().c_struct());
|
REQUIRE(copts.connectProperties == &opts.get_properties().c_struct());
|
||||||
}
|
}
|
||||||
@ -682,7 +688,9 @@ TEST_CASE("connect_options_builder copy_assignment", "[options]")
|
|||||||
// Check that we got the correct properties
|
// Check that we got the correct properties
|
||||||
REQUIRE(1 == opts.get_properties().size());
|
REQUIRE(1 == opts.get_properties().size());
|
||||||
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
||||||
REQUIRE(42 == get<int>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(
|
||||||
|
42 == get<uint32_t>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,6 +747,8 @@ TEST_CASE("connect_options_builder move_assignment", "[options]")
|
|||||||
// Check that we got the correct properties
|
// Check that we got the correct properties
|
||||||
REQUIRE(1 == opts.get_properties().size());
|
REQUIRE(1 == opts.get_properties().size());
|
||||||
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
||||||
REQUIRE(42 == get<int>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(
|
||||||
|
42 == get<uint32_t>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,9 @@ TEST_CASE("disconnect_options copy ctor", "[options]")
|
|||||||
// Check that the properties transferred over
|
// Check that the properties transferred over
|
||||||
REQUIRE(1 == opts.get_properties().size());
|
REQUIRE(1 == opts.get_properties().size());
|
||||||
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(opts.get_properties().contains(property::SESSION_EXPIRY_INTERVAL));
|
||||||
REQUIRE(42 == get<int>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL));
|
REQUIRE(
|
||||||
|
42 == get<uint32_t>(opts.get_properties(), property::SESSION_EXPIRY_INTERVAL)
|
||||||
|
);
|
||||||
|
|
||||||
REQUIRE(1 == opts.c_struct().properties.count);
|
REQUIRE(1 == opts.c_struct().properties.count);
|
||||||
REQUIRE(
|
REQUIRE(
|
||||||
|
@ -78,7 +78,7 @@ TEST_CASE("int property constructor", "[property]")
|
|||||||
REQUIRE(prop.c_struct().value.integer2 == 512);
|
REQUIRE(prop.c_struct().value.integer2 == 512);
|
||||||
|
|
||||||
REQUIRE(prop.type() == typ);
|
REQUIRE(prop.type() == typ);
|
||||||
REQUIRE(get<int16_t>(prop) == int16_t(512));
|
REQUIRE(get<uint16_t>(prop) == 512);
|
||||||
|
|
||||||
// Should be able to support full 16-bit unsigned range
|
// Should be able to support full 16-bit unsigned range
|
||||||
const uint16_t MAX = std::numeric_limits<uint16_t>::max();
|
const uint16_t MAX = std::numeric_limits<uint16_t>::max();
|
||||||
@ -103,7 +103,7 @@ TEST_CASE("int property constructor", "[property]")
|
|||||||
REQUIRE(prop.c_struct().value.integer4 == 70000);
|
REQUIRE(prop.c_struct().value.integer4 == 70000);
|
||||||
|
|
||||||
REQUIRE(prop.type() == typ);
|
REQUIRE(prop.type() == typ);
|
||||||
REQUIRE(get<int32_t>(prop) == int32_t(70000));
|
REQUIRE(get<uint32_t>(prop) == 70000);
|
||||||
|
|
||||||
// Should be able to support full 32-bit unsigned range
|
// Should be able to support full 32-bit unsigned range
|
||||||
const uint32_t MAX = std::numeric_limits<uint32_t>::max();
|
const uint32_t MAX = std::numeric_limits<uint32_t>::max();
|
||||||
@ -235,7 +235,7 @@ TEST_CASE("int property copy constructor", "[property]")
|
|||||||
REQUIRE(prop.c_struct().value.integer4 == 70000);
|
REQUIRE(prop.c_struct().value.integer4 == 70000);
|
||||||
|
|
||||||
REQUIRE(prop.type() == typ);
|
REQUIRE(prop.type() == typ);
|
||||||
REQUIRE(get<int32_t>(prop) == int32_t(70000));
|
REQUIRE(get<uint32_t>(prop) == 70000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ TEST_CASE("int property move constructor", "[property]")
|
|||||||
REQUIRE(prop.c_struct().value.integer4 == 70000);
|
REQUIRE(prop.c_struct().value.integer4 == 70000);
|
||||||
|
|
||||||
REQUIRE(prop.type() == typ);
|
REQUIRE(prop.type() == typ);
|
||||||
REQUIRE(get<int32_t>(prop) == int32_t(70000));
|
REQUIRE(get<uint32_t>(prop) == 70000);
|
||||||
|
|
||||||
// Make sure the old value was moved
|
// Make sure the old value was moved
|
||||||
REQUIRE(org_prop.c_struct().identifier == 0);
|
REQUIRE(org_prop.c_struct().identifier == 0);
|
||||||
@ -434,7 +434,7 @@ TEST_CASE("properties constructors", "[properties]")
|
|||||||
REQUIRE(props.size() == 2);
|
REQUIRE(props.size() == 2);
|
||||||
|
|
||||||
REQUIRE(42 == get<uint8_t>(props, property::PAYLOAD_FORMAT_INDICATOR));
|
REQUIRE(42 == get<uint8_t>(props, property::PAYLOAD_FORMAT_INDICATOR));
|
||||||
REQUIRE(70000 == get<int>(props, property::MESSAGE_EXPIRY_INTERVAL));
|
REQUIRE(70000 == get<uint32_t>(props, property::MESSAGE_EXPIRY_INTERVAL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user