7 #if !defined(MQTT_BUFFER_HPP)
8 #define MQTT_BUFFER_HPP
12 #include <type_traits>
14 #include <boost/asio/buffer.hpp>
47 explicit buffer(std::string) =
delete;
68 buffer substr(std::size_t offset, std::size_t length = string_view::npos)
const& {
70 return buffer(string_view::substr(offset, length), lifetime_);
81 buffer substr(std::size_t offset, std::size_t length = string_view::npos) && {
92 return lifetime_.get();
99 inline namespace literals {
113 inline buffer operator""_mb(
char const* str, std::size_t length) {
129 template <
typename Iterator>
131 auto size =
static_cast<std::size_t
>(std::distance(b, e));
133 std::copy(b, e, spa.get());
152 return std::addressof(buf);
156 return std::addressof(buf) + 1;
159 template <
typename Col>
164 template <
typename Col>
174 template <
typename T>
177 typename std::enable_if<
188 template <
typename T>
191 typename std::enable_if<
199 template <
typename,
typename>
202 template <
typename T,
typename Buffer>
205 typename std::enable_if<
213 template <
typename T,
typename Buffer>
215 : std::integral_constant<bool,
216 sizeof(buffer_sequence_begin_helper<T>(0, 0)) != 1 &&
217 sizeof(buffer_sequence_end_helper<T>(0, 0)) != 1 &&
218 sizeof(buffer_sequence_element_type_helper<T, Buffer>(0, 0)) == 1>
224 template <
typename T>
227 std::is_class<T>::value,
228 detail::is_buffer_sequence_class<T, buffer>,
254 return buffer(data.data(), data.size());
buffer that has string_view interface This class provides string_view interface. This class hold stri...
Definition: buffer.hpp:30
bool has_life() const
check the buffer has lifetime.
Definition: buffer.hpp:91
buffer(std::string)=delete
string constructor (deleted)
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 substr(std::size_t offset, std::size_t length=string_view::npos) &&
get substring The returned buffer ragnge is the same as std::string_view::substr()....
Definition: buffer.hpp:81
constexpr buffer(string_view sv=string_view())
string_view constructor
Definition: buffer.hpp:38
buffer(string_view sv, const_shared_ptr_array spa)
string_view and lifetime constructor
Definition: buffer.hpp:55
char buffer_sequence_end_helper(...)
char(& buffer_sequence_element_type_helper(...))[2]
char buffer_sequence_begin_helper(...)
boost::string_ref string_view
Definition: string_view.hpp:64
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
buffer const * buffer_sequence_end(buffer const &buf)
Definition: buffer.hpp:155
buffer const * buffer_sequence_begin(buffer const &buf)
Definition: buffer.hpp:151
std::size_t size(basic_message_variant< PacketIdBytes > const &mv)
Definition: message_variant.hpp:93
Definition: buffer.hpp:242
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
Definition: buffer.hpp:241
shared_ptr_array make_shared_ptr_array(std::size_t size)
shared_ptr_array creating function. You can choose the target type.
std::shared_ptr< char const[]> const_shared_ptr_array
Definition: shared_ptr_array.hpp:21
Definition: buffer.hpp:219
Definition: buffer.hpp:231