diff --git a/example/openssl_tls.cpp b/example/openssl_tls.cpp index cbef07f..21d72f3 100644 --- a/example/openssl_tls.cpp +++ b/example/openssl_tls.cpp @@ -180,9 +180,9 @@ void subscribe_and_receive_openssl_tls(int num_receive) { topics.push_back(subscribe_topic { "test/mqtt-test", { qos_e::exactly_once, - subscribe_options::no_local_e::no, - subscribe_options::retain_as_published_e::retain, - subscribe_options::retain_handling_e::send + no_local_e::no, + retain_as_published_e::retain, + retain_handling_e::send } }); diff --git a/example/receiver.cpp b/example/receiver.cpp index e5d7315..123da86 100644 --- a/example/receiver.cpp +++ b/example/receiver.cpp @@ -28,9 +28,9 @@ asio::awaitable client_receiver(asio::io_context& ioc) { "test/mqtt-test", async_mqtt5::subscribe_options { async_mqtt5::qos_e::exactly_once, // All messages will arrive at QoS 2. - async_mqtt5::subscribe_options::no_local_e::no, // Forward message from Clients with same ID. - async_mqtt5::subscribe_options::retain_as_published_e::retain, // Keep the original RETAIN flag. - async_mqtt5::subscribe_options::retain_handling_e::send // Send retained messages when the subscription is established. + async_mqtt5::no_local_e::no, // Forward message from Clients with same ID. + async_mqtt5::retain_as_published_e::retain, // Keep the original RETAIN flag. + async_mqtt5::retain_handling_e::send // Send retained messages when the subscription is established. } }; diff --git a/example/websocket_tcp.cpp b/example/websocket_tcp.cpp index a89172d..a59a64c 100644 --- a/example/websocket_tcp.cpp +++ b/example/websocket_tcp.cpp @@ -124,11 +124,11 @@ void subscribe_and_receive_websocket_tcp(int num_receive) { topics.push_back(subscribe_topic{ "test/mqtt-test", { qos_e::exactly_once, - subscribe_options::no_local_e::no, - subscribe_options::retain_as_published_e::retain, - subscribe_options::retain_handling_e::send + no_local_e::no, + retain_as_published_e::retain, + retain_handling_e::send } - }); + }); c.async_subscribe( topics, subscribe_props{}, diff --git a/example/websocket_tls.cpp b/example/websocket_tls.cpp index bed4aa3..bb648e5 100644 --- a/example/websocket_tls.cpp +++ b/example/websocket_tls.cpp @@ -199,11 +199,11 @@ void subscribe_and_receive_websocket_tls(int num_receive) { topics.push_back(subscribe_topic{ "test/mqtt-test", { qos_e::exactly_once, - subscribe_options::no_local_e::no, - subscribe_options::retain_as_published_e::retain, - subscribe_options::retain_handling_e::send + no_local_e::no, + retain_as_published_e::retain, + retain_handling_e::send } - }); + }); c.async_subscribe( topics, subscribe_props{}, diff --git a/include/async_mqtt5/types.hpp b/include/async_mqtt5/types.hpp index 72acae0..508d5ae 100644 --- a/include/async_mqtt5/types.hpp +++ b/include/async_mqtt5/types.hpp @@ -79,58 +79,56 @@ enum class auth_step_e { server_final }; +/** + * \brief Representation of the No Local Subscribe Option. + * + * \details A Subscribe Option indicating whether or not Application Messages + * will be forwarded to a connection with a ClientID equal to the ClientID of the + * publishing connection. + */ +enum class no_local_e : std::uint8_t { + /** Application Messages can be forwarded to a connection with equal ClientID. */ + no = 0b0, + + /** Application Messages MUST NOT be forwarded to a connection with equal ClientID. */ + yes = 0b1 +}; + +/** + * \brief Representation of the Retain As Published Subscribe Option. + * + * \details A Subscribe Option indicating whether or not Application Messages forwarded + * using this subscription keep the \__RETAIN\__ flag they were published with. + */ +enum class retain_as_published_e : std::uint8_t { + /** Application Messages have the \__RETAIN\__ flag set to 0. */ + dont = 0b0, + + /** Application Messages keep the \__RETAIN\__ flag they were published with. */ + retain = 0b1 +}; + +/** + * \brief Representation of the Retain Handling Subscribe Option. + * + * \details A Subscribe Option specifying whether retained messages are sent + * when the subscription is established. + */ +enum class retain_handling_e : std::uint8_t { + /** Send retained messages at the time of subscribe. */ + send = 0b00, + + /** Send retained message only if the subscription does not currently exist. */ + new_subscription_only = 0b01, + + /** Do not send retained messages at the time of subscribe. */ + not_send = 0b10 +}; + /** * \brief Represents the \__SUBSCRIBE_OPTIONS\__ associated with each Subscription. */ struct subscribe_options { - - /** - * \brief Representation of the No Local Subscribe Option. - * - * \details A Subscribe Option indicating whether or not Application Messages - * will be forwarded to a connection with a ClientID equal to the ClientID of the - * publishing connection. - */ - enum class no_local_e : std::uint8_t { - /** Application Messages can be forwarded to a connection with equal ClientID. */ - no = 0b0, - - /** Application Messages MUST NOT be forwarded to a connection with equal ClientID. */ - yes = 0b1 - }; - - /** - * \brief Representation of the Retain As Published Subscribe Option. - * - * \details A Subscribe Option indicating whether or not Application Messages forwarded - * using this subscription keep the \__RETAIN\__ flag they were published with. - */ - enum class retain_as_published_e : std::uint8_t { - /** Application Messages have the \__RETAIN\__ flag set to 0. */ - dont = 0b0, - - /** Application Messages keep the \__RETAIN\__ flag they were published with. */ - retain = 0b1 - }; - - /** - * \brief Representation of the Retain Handling Subscribe Option. - * - * \details A Subscribe Option specifying whether retained messages are sent - * when the subscription is established. - */ - enum class retain_handling_e : std::uint8_t { - /** Send retained messages at the time of subscribe. */ - send = 0b00, - - /** Send retained message only if the subscription does not currently exist. */ - new_subscription_only = 0b01, - - /** Do not send retained messages at the time of subscribe. */ - not_send = 0b10 - }; - - /// Maximum \__QOS\__ level at which the Server can send Application Messages to the Client. qos_e max_qos = qos_e::exactly_once; diff --git a/test/integration/coroutine.cpp b/test/integration/coroutine.cpp index 65efd0f..f6c0d32 100644 --- a/test/integration/coroutine.cpp +++ b/test/integration/coroutine.cpp @@ -80,9 +80,9 @@ asio::awaitable sanity_check(mqtt_client& c) { subscribe_topic sub_topic = subscribe_topic { "test/mqtt-test", async_mqtt5::subscribe_options { qos_e::exactly_once, - subscribe_options::no_local_e::no, - subscribe_options::retain_as_published_e::retain, - subscribe_options::retain_handling_e::send + no_local_e::no, + retain_as_published_e::retain, + retain_handling_e::send } }; diff --git a/test/integration/read_message.cpp b/test/integration/read_message.cpp index 5680732..c1eab4a 100644 --- a/test/integration/read_message.cpp +++ b/test/integration/read_message.cpp @@ -203,7 +203,7 @@ BOOST_FIXTURE_TEST_CASE(receive_byte_by_byte, shared_test_data) { for (size_t i = 0; i < publish.size(); i++) broker_side.send( - std::string { publish[i] }, after(std::chrono::milliseconds(i + 2)) + std::string { publish[i] }, after(std::chrono::milliseconds(i + 5)) ); auto verify_fun = [&]( diff --git a/test/unit/error.cpp b/test/unit/error.cpp index 190c1d4..24df10c 100644 --- a/test/unit/error.cpp +++ b/test/unit/error.cpp @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(reason_code_to_string) { wildcard_subscriptions_not_supported }; - BOOST_CHECK_EQUAL(rcs.size(), 46); + BOOST_CHECK_EQUAL(rcs.size(), 46u); constexpr auto default_output = "Invalid reason code"; for (const auto& rc: rcs) diff --git a/test/unit/serialization.cpp b/test/unit/serialization.cpp index 5112f4c..fe09156 100644 --- a/test/unit/serialization.cpp +++ b/test/unit/serialization.cpp @@ -85,7 +85,10 @@ BOOST_AUTO_TEST_CASE(test_connect) { BOOST_CHECK_EQUAL(keep_alive_, keep_alive); BOOST_CHECK_EQUAL(clean_start_, clean_start); - cprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + cprops_.visit([](const auto& prop, const auto&) { + (void)prop; BOOST_ASSERT(prop); + return true; + }); BOOST_CHECK_EQUAL(*cprops_[prop::session_expiry_interval], session_expiry_interval); BOOST_CHECK_EQUAL(*cprops_[prop::receive_maximum], receive_max); BOOST_CHECK_EQUAL(*cprops_[prop::maximum_packet_size], maximum_packet_size); @@ -103,7 +106,7 @@ BOOST_AUTO_TEST_CASE(test_connect) { BOOST_CHECK_EQUAL((*w_).topic(), will_topic); BOOST_CHECK_EQUAL((*w_).message(), will_message); - (*w_).visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + (*w_).visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*(*w_)[prop::will_delay_interval], will_delay_interval); BOOST_CHECK_EQUAL(*(*w_)[prop::payload_format_indicator], will_payload_format_indicator); BOOST_CHECK_EQUAL(*(*w_)[prop::message_expiry_interval], will_message_expiry_interval); @@ -173,7 +176,7 @@ BOOST_AUTO_TEST_CASE(test_connack) { BOOST_CHECK_EQUAL(session_present_, session_present); BOOST_CHECK_EQUAL(reason_code_, reason_code); - cprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + cprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*cprops_[prop::session_expiry_interval], session_expiry_interval); BOOST_CHECK_EQUAL(*cprops_[prop::receive_maximum], receive_maximum); BOOST_CHECK_EQUAL(*cprops_[prop::maximum_qos], max_qos); @@ -242,7 +245,7 @@ BOOST_AUTO_TEST_CASE(test_publish) { BOOST_CHECK_EQUAL(topic_, topic); BOOST_CHECK_EQUAL(payload_, payload); - pprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + pprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*pprops_[prop::payload_format_indicator], payload_format_indicator); BOOST_CHECK_EQUAL(*pprops_[prop::message_expiry_interval], message_expiry_interval); BOOST_CHECK_EQUAL(*pprops_[prop::topic_alias], topic_alias); @@ -311,7 +314,7 @@ BOOST_AUTO_TEST_CASE(test_puback) { BOOST_ASSERT(rv); const auto& [reason_code_, pprops_] = *rv; - pprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + pprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(reason_code_, reason_code); BOOST_CHECK_EQUAL(*pprops_[prop::reason_string], reason_string); BOOST_ASSERT(pprops_[prop::user_property].size() == 2); @@ -348,7 +351,7 @@ BOOST_AUTO_TEST_CASE(test_pubrec) { BOOST_ASSERT(rv); const auto& [reason_code_, pprops_] = *rv; - pprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + pprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(reason_code_, reason_code); BOOST_CHECK_EQUAL(*pprops_[prop::reason_string], reason_string); BOOST_ASSERT(pprops_[prop::user_property].size() == 2); @@ -385,7 +388,7 @@ BOOST_AUTO_TEST_CASE(test_pubrel) { BOOST_ASSERT(rv); const auto& [reason_code_, pprops_] = *rv; - pprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + pprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(reason_code_, reason_code); BOOST_CHECK_EQUAL(*pprops_[prop::reason_string], reason_string); BOOST_ASSERT(pprops_[prop::user_property].size() == 2); @@ -422,7 +425,7 @@ BOOST_AUTO_TEST_CASE(test_pubcomp) { BOOST_ASSERT(rv);; const auto& [reason_code_, pprops_] = *rv; - pprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + pprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(reason_code_, reason_code); BOOST_CHECK_EQUAL(*pprops_[prop::reason_string], reason_string); BOOST_ASSERT(pprops_[prop::user_property].size() == 2); @@ -436,11 +439,6 @@ BOOST_AUTO_TEST_CASE(test_subscribe) { std::string user_property_1 = "SUBSCRIBE user prop"; std::string user_property_2 = "SUBSCRIBE user prop val"; - // delete using lines when we shorten the enum names - using no_local_e = subscribe_options::no_local_e; - using retain_as_published_e = subscribe_options::retain_as_published_e; - using retain_handling_e = subscribe_options::retain_handling_e; - qos_e qos = qos_e::at_least_once; no_local_e no_local = no_local_e::yes; retain_as_published_e retain_as_published = retain_as_published_e::retain; @@ -483,7 +481,7 @@ BOOST_AUTO_TEST_CASE(test_subscribe) { static_cast(qos); BOOST_CHECK_EQUAL(options_, mask); - sprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + sprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*sprops_[prop::subscription_identifier], sub_id); BOOST_ASSERT(sprops_[prop::user_property].size() == 2); BOOST_CHECK_EQUAL(sprops_[prop::user_property][0], user_property_1); @@ -520,7 +518,7 @@ BOOST_AUTO_TEST_CASE(test_suback) { const auto& [sprops_, reason_codes_] = *rv; BOOST_CHECK(reason_codes_ == reason_codes); - sprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + sprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*sprops_[prop::reason_string], reason_string); BOOST_ASSERT(sprops_[prop::user_property].size() == 2); BOOST_CHECK_EQUAL(sprops_[prop::user_property][0], user_property_1); @@ -555,7 +553,7 @@ BOOST_AUTO_TEST_CASE(test_unsubscribe) { const auto& [uprops_, topics_] = *rv; BOOST_CHECK(topics_ == topics); - uprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + uprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_ASSERT(uprops_[prop::user_property].size() == 2); BOOST_CHECK_EQUAL(uprops_[prop::user_property][0], user_property_1); BOOST_CHECK_EQUAL(uprops_[prop::user_property][1], user_property_2); @@ -591,7 +589,7 @@ BOOST_AUTO_TEST_CASE(test_unsuback) { const auto& [uprops_, reason_codes_] = *rv; BOOST_CHECK(reason_codes_ == reason_codes); - uprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + uprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*uprops_[prop::reason_string], reason_string); BOOST_ASSERT(uprops_[prop::user_property].size() == 2); BOOST_CHECK_EQUAL(uprops_[prop::user_property][0], user_property_1); @@ -628,7 +626,7 @@ BOOST_AUTO_TEST_CASE(test_disconnect) { const auto& [reason_code_, dprops_] = *rv; BOOST_CHECK_EQUAL(reason_code_, reason_code); - dprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + dprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*dprops_[prop::session_expiry_interval], session_expiry_interval); BOOST_CHECK_EQUAL(*dprops_[prop::reason_string], reason_string); BOOST_ASSERT(dprops_[prop::user_property].size() == 2); @@ -668,7 +666,7 @@ BOOST_AUTO_TEST_CASE(test_auth) { const auto& [reason_code_, aprops_] = *rv; BOOST_CHECK_EQUAL(reason_code_, reason_code); - aprops_.visit([](const auto& prop, const auto&) { BOOST_ASSERT(prop); return true; }); + aprops_.visit([](const auto& p, const auto&) { (void)p; BOOST_ASSERT(p); return true; }); BOOST_CHECK_EQUAL(*aprops_[prop::authentication_method], authentication_method); BOOST_CHECK_EQUAL(*aprops_[prop::authentication_data], authentication_data); BOOST_CHECK_EQUAL(*aprops_[prop::reason_string], reason_string);