8 #if !defined(MQTT_SHARED_SUBSCRIPTIONS_HPP)
9 #define MQTT_SHARED_SUBSCRIPTIONS_HPP
14 #include <type_traits>
16 #include <boost/assert.hpp>
53 if (whole_topic_filter.
substr(0, shared_prefix.size()) != shared_prefix) {
58 whole_topic_filter.remove_prefix(shared_prefix.size());
61 auto const idx = whole_topic_filter.find_first_of(
'/');
62 if (idx == string_view::npos)
return nullopt;
66 auto share_name = whole_topic_filter.
substr(0, idx);
67 whole_topic_filter.remove_prefix(std::min(idx + 1, whole_topic_filter.size()));
69 if (share_name.empty() || whole_topic_filter.empty())
return nullopt;
75 template <
typename T,
typename U>
82 std::copy(prefix.begin(), prefix.end(), it);
84 std::copy(share_name.begin(), share_name.end(), it);
85 it += share_name.size();
87 std::copy(topic_filter.begin(), topic_filter.end(), it);
88 it += topic_filter.size();
99 if (share_name.empty())
return topic_filter;
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
buffer create_topic_filter_buffer(T const &share_name, U const &topic_filter)
Definition: shared_subscriptions.hpp:76
bool operator==(null_strand const &lhs, null_strand const &rhs)
Definition: null_strand.hpp:52
boost::string_ref string_view
Definition: string_view.hpp:64
optional< share_name_topic_filter > parse_shared_subscription(buffer whole_topic_filter)
Definition: shared_subscriptions.hpp:51
constexpr std::remove_reference_t< T > && force_move(T &&t)
Definition: move.hpp:20
buffer allocate_buffer(Iterator b, Iterator e)
create buffer from the pair of iterators It copies string that from b to e into shared_ptr_array....
Definition: buffer.hpp:130
bool operator!=(null_strand const &lhs, null_strand const &rhs)
Definition: null_strand.hpp:56
bool operator<(share_name_topic_filter const &lhs, share_name_topic_filter const &rhs)
Definition: shared_subscriptions.hpp:36
buffer create_topic_filter_buffer(string_view share_name, string_view topic_filter)
Definition: shared_subscriptions.hpp:94
const_buffer buffer(MQTT_NS::buffer const &data)
create boost::asio::const_buffer from the MQTT_NS::buffer boost::asio::const_buffer is a kind of view...
Definition: buffer.hpp:253
shared_ptr_array make_shared_ptr_array(std::size_t size)
shared_ptr_array creating function. You can choose the target type.
Definition: shared_subscriptions.hpp:25
buffer share_name
Definition: shared_subscriptions.hpp:32
share_name_topic_filter(buffer share_name, buffer topic_filter)
Definition: shared_subscriptions.hpp:26
buffer topic_filter
Definition: shared_subscriptions.hpp:33