123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #ifndef __ASIO2_MQTT_OPTIONS_HPP__
- #define __ASIO2_MQTT_OPTIONS_HPP__
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- #pragma once
- #endif
- #include <asio2/base/detail/util.hpp>
- #include <asio2/mqtt/message.hpp>
- namespace asio2::detail
- {
- class mqtt_options
- {
- public:
- using self = mqtt_options;
-
- mqtt_options()
- {
- _receive_maximum = static_cast<decltype(_receive_maximum )>(65535);
- _topic_alias_maximum = static_cast<decltype(_topic_alias_maximum)>(65535);
- _maximum_qos = static_cast<decltype(_maximum_qos )>(mqtt::qos_type::exactly_once);
- _retain_available = static_cast<decltype(_retain_available )>(1);
- }
-
- ~mqtt_options() = default;
-
- inline self& set_mqtt_options(const mqtt_options& options)
- {
- this->_mqtt_options_copy_from(options);
- return (*this);
- }
-
-
-
-
- template<class Integer>
- inline self& receive_maximum(Integer v)
- {
- static_assert(std::is_integral_v<detail::remove_cvref_t<Integer>>);
- _receive_maximum = static_cast<decltype(_receive_maximum)>(v);
- return (*this);
- }
- inline auto receive_maximum() const { return _receive_maximum; }
-
-
-
-
-
- template<class Integer>
- inline self& topic_alias_maximum(Integer v)
- {
- static_assert(std::is_integral_v<detail::remove_cvref_t<Integer>>);
- _topic_alias_maximum = static_cast<decltype(_topic_alias_maximum)>(v);
- return (*this);
- }
- inline auto topic_alias_maximum() const { return _topic_alias_maximum; }
-
-
-
- template<class Integer>
- inline self& maximum_qos(Integer v)
- {
- static_assert(std::is_integral_v<detail::remove_cvref_t<Integer>>);
- ASIO2_ASSERT(v >= 0 && v <= 2);
- _maximum_qos = static_cast<decltype(_maximum_qos)>(v);
- return (*this);
- }
- inline auto maximum_qos() const { return _maximum_qos; }
-
-
-
-
-
- inline self& retain_available(bool v)
- {
- _retain_available = static_cast<decltype(_retain_available)>(v);
- return (*this);
- }
- inline bool retain_available() const { return (_retain_available == static_cast<decltype(_retain_available)>(1)); }
- protected:
- template<class MqttOptions>
- inline void _mqtt_options_copy_from(const MqttOptions& o)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this->receive_maximum ( o._receive_maximum );
- this->topic_alias_maximum ( o._topic_alias_maximum );
-
- this->maximum_qos ( o._maximum_qos );
- this->retain_available ( o._retain_available );
-
-
-
-
-
- }
- protected:
- decltype(std::declval<mqtt::v5::payload_format_indicator >().value()) _payload_format_indicator {};
- decltype(std::declval<mqtt::v5::message_expiry_interval >().value()) _message_expiry_interval {};
- decltype(std::declval<mqtt::v5::content_type >().value()) _content_type {};
- decltype(std::declval<mqtt::v5::response_topic >().value()) _response_topic {};
- decltype(std::declval<mqtt::v5::correlation_data >().value()) _correlation_data {};
- decltype(std::declval<mqtt::v5::subscription_identifier >().value()) _subscription_identifier {};
- decltype(std::declval<mqtt::v5::session_expiry_interval >().value()) _session_expiry_interval {};
- decltype(std::declval<mqtt::v5::assigned_client_identifier >().value()) _assigned_client_identifier {};
- decltype(std::declval<mqtt::v5::server_keep_alive >().value()) _server_keep_alive {};
- decltype(std::declval<mqtt::v5::authentication_method >().value()) _authentication_method {};
- decltype(std::declval<mqtt::v5::authentication_data >().value()) _authentication_data {};
- decltype(std::declval<mqtt::v5::request_problem_information >().value()) _request_problem_information {};
- decltype(std::declval<mqtt::v5::will_delay_interval >().value()) _will_delay_interval {};
- decltype(std::declval<mqtt::v5::request_response_information >().value()) _request_response_information {};
- decltype(std::declval<mqtt::v5::response_information >().value()) _response_information {};
- decltype(std::declval<mqtt::v5::server_reference >().value()) _server_reference {};
- decltype(std::declval<mqtt::v5::reason_string >().value()) _reason_string {};
- decltype(std::declval<mqtt::v5::receive_maximum >().value()) _receive_maximum {};
- decltype(std::declval<mqtt::v5::topic_alias_maximum >().value()) _topic_alias_maximum {};
- decltype(std::declval<mqtt::v5::topic_alias >().value()) _topic_alias {};
- decltype(std::declval<mqtt::v5::maximum_qos >().value()) _maximum_qos {};
- decltype(std::declval<mqtt::v5::retain_available >().value()) _retain_available {};
- decltype(std::declval<mqtt::v5::user_property >().value()) _user_property {};
- decltype(std::declval<mqtt::v5::maximum_packet_size >().value()) _maximum_packet_size {};
- decltype(std::declval<mqtt::v5::wildcard_subscription_available >().value()) _wildcard_subscription_available {};
- decltype(std::declval<mqtt::v5::subscription_identifier_available >().value()) _subscription_identifier_available {};
- decltype(std::declval<mqtt::v5::shared_subscription_available >().value()) _shared_subscription_available {};
- };
- }
- namespace asio2::mqtt
- {
- using options = asio2::detail::mqtt_options;
- }
- namespace asio2
- {
- using mqtt_options = asio2::detail::mqtt_options;
- }
- #endif
|