123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #ifndef BOOST_BEAST_BUFFER_REF_HPP
- #define BOOST_BEAST_BUFFER_REF_HPP
- #include <cstddef>
- namespace boost {
- namespace beast {
- #if !defined(BOOST_ASIO_NO_DYNAMIC_BUFFER_V1)
- template<typename Buffer>
- struct buffer_ref
- {
-
- using const_buffers_type = typename Buffer::const_buffers_type;
-
- using mutable_buffers_type = typename Buffer::mutable_buffers_type;
-
- std::size_t
- size() const noexcept
- {
- return buffer_.size();
- }
-
- std::size_t
- max_size() const noexcept
- {
- return buffer_.max_size();
- }
-
- std::size_t
- capacity() const noexcept
- {
- return buffer_.capacity();
- }
-
- const_buffers_type
- data() const noexcept
- {
- return buffer_.data();
- }
-
-
-
- mutable_buffers_type prepare(std::size_t n)
- {
- return buffer_.prepare(n);
- }
-
-
-
- void commit(std::size_t n)
- {
- return buffer_.commit(n);
- }
-
-
- void consume(std::size_t n)
- {
- return buffer_.consume(n);
- }
-
- using buffer_type = Buffer;
-
- buffer_ref(Buffer & buffer) : buffer_(buffer) {}
-
- buffer_ref(const buffer_ref& buffer) = default;
- private:
- Buffer &buffer_;
- };
- template<class Allocator>
- class basic_flat_buffer;
- template<std::size_t N>
- class flat_static_buffer;
- template<class Allocator>
- class basic_multi_buffer;
- template<std::size_t N>
- class static_buffer;
- template<class Allocator>
- inline buffer_ref<basic_flat_buffer<Allocator>> ref(basic_flat_buffer<Allocator> & buf)
- {
- return buffer_ref<basic_flat_buffer<Allocator>>(buf);
- }
- template<std::size_t N>
- inline buffer_ref<flat_static_buffer<N>> ref(flat_static_buffer<N> & buf)
- {
- return buffer_ref<flat_static_buffer<N>>(buf);
- }
- template<class Allocator>
- inline buffer_ref<basic_multi_buffer<Allocator>> ref(basic_multi_buffer<Allocator> & buf)
- {
- return buffer_ref<basic_multi_buffer<Allocator>>(buf);
- }
- template<std::size_t N>
- inline buffer_ref<static_buffer<N>> ref(static_buffer<N> & buf)
- {
- return buffer_ref<static_buffer<N>>(buf);
- }
- #endif
- }
- }
- #endif
|