rename of aux::array_view to span (#933)

This commit is contained in:
Alden Torres 2016-07-22 12:31:42 -04:00 committed by Arvid Norberg
parent 7bf49c0a1c
commit f57612b82d
32 changed files with 161 additions and 162 deletions

View File

@ -149,8 +149,8 @@ nobase_include_HEADERS = \
web_connection_base.hpp \ web_connection_base.hpp \
web_peer_connection.hpp \ web_peer_connection.hpp \
xml_parse.hpp \ xml_parse.hpp \
span.hpp \
\ \
aux_/array_view.hpp \
aux_/allocating_handler.hpp \ aux_/allocating_handler.hpp \
aux_/bind_to_device.hpp \ aux_/bind_to_device.hpp \
aux_/cpuid.hpp \ aux_/cpuid.hpp \

View File

@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <algorithm> // for copy #include <algorithm> // for copy
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
namespace libtorrent { namespace aux namespace libtorrent { namespace aux
{ {
@ -47,7 +47,7 @@ namespace libtorrent { namespace aux
// it to native endianess // it to native endianess
template <class T, class Byte> template <class T, class Byte>
inline typename std::enable_if<sizeof(Byte)==1, T>::type inline typename std::enable_if<sizeof(Byte)==1, T>::type
read_impl(array_view<Byte>& view, type<T>) read_impl(span<Byte>& view, type<T>)
{ {
T ret = 0; T ret = 0;
for (int i = 0; i < int(sizeof(T)); ++i) for (int i = 0; i < int(sizeof(T)); ++i)
@ -61,7 +61,7 @@ namespace libtorrent { namespace aux
template <class T, class Byte> template <class T, class Byte>
inline typename std::enable_if<sizeof(Byte)==1, void>::type inline typename std::enable_if<sizeof(Byte)==1, void>::type
write_impl(T val, array_view<Byte>& view) write_impl(T val, span<Byte>& view)
{ {
int shift = int(sizeof(T)) * 8; int shift = int(sizeof(T)) * 8;
for (int i = 0; i < int(sizeof(T)); ++i) for (int i = 0; i < int(sizeof(T)); ++i)
@ -75,78 +75,78 @@ namespace libtorrent { namespace aux
// -- adaptors // -- adaptors
template <typename Byte> template <typename Byte>
std::int64_t read_int64(array_view<Byte>& view) std::int64_t read_int64(span<Byte>& view)
{ return read_impl(view, type<std::int64_t>()); } { return read_impl(view, type<std::int64_t>()); }
template <typename Byte> template <typename Byte>
std::uint64_t read_uint64(array_view<Byte>& view) std::uint64_t read_uint64(span<Byte>& view)
{ return read_impl(view, type<std::uint64_t>()); } { return read_impl(view, type<std::uint64_t>()); }
template <typename Byte> template <typename Byte>
std::uint32_t read_uint32(array_view<Byte>& view) std::uint32_t read_uint32(span<Byte>& view)
{ return read_impl(view, type<std::uint32_t>()); } { return read_impl(view, type<std::uint32_t>()); }
template <typename Byte> template <typename Byte>
std::int32_t read_int32(array_view<Byte>& view) std::int32_t read_int32(span<Byte>& view)
{ return read_impl(view, type<std::int32_t>()); } { return read_impl(view, type<std::int32_t>()); }
template <typename Byte> template <typename Byte>
std::int16_t read_int16(array_view<Byte>& view) std::int16_t read_int16(span<Byte>& view)
{ return read_impl(view, type<std::int16_t>()); } { return read_impl(view, type<std::int16_t>()); }
template <typename Byte> template <typename Byte>
std::uint16_t read_uint16(array_view<Byte>& view) std::uint16_t read_uint16(span<Byte>& view)
{ return read_impl(view, type<std::uint16_t>()); } { return read_impl(view, type<std::uint16_t>()); }
template <typename Byte> template <typename Byte>
std::int8_t read_int8(array_view<Byte>& view) std::int8_t read_int8(span<Byte>& view)
{ return read_impl(view, type<std::int8_t>()); } { return read_impl(view, type<std::int8_t>()); }
template <typename Byte> template <typename Byte>
std::uint8_t read_uint8(array_view<Byte>& view) std::uint8_t read_uint8(span<Byte>& view)
{ return read_impl(view, type<std::uint8_t>()); } { return read_impl(view, type<std::uint8_t>()); }
template <typename Byte> template <typename Byte>
void write_uint64(std::uint64_t val, array_view<Byte>& view) void write_uint64(std::uint64_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_int64(std::int64_t val, array_view<Byte>& view) void write_int64(std::int64_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_uint32(std::uint32_t val, array_view<Byte>& view) void write_uint32(std::uint32_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_int32(std::int32_t val, array_view<Byte>& view) void write_int32(std::int32_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_uint16(std::uint16_t val, array_view<Byte>& view) void write_uint16(std::uint16_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_int16(std::int16_t val, array_view<Byte>& view) void write_int16(std::int16_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_uint8(std::uint8_t val, array_view<Byte>& view) void write_uint8(std::uint8_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template <typename Byte> template <typename Byte>
void write_int8(std::int8_t val, array_view<Byte>& view) void write_int8(std::int8_t val, span<Byte>& view)
{ write_impl(val, view); } { write_impl(val, view); }
template<typename Byte> template<typename Byte>
inline int write_string(std::string const& str, array_view<Byte>& view) inline int write_string(std::string const& str, span<Byte>& view)
{ {
int const len = int(str.size()); int const len = int(str.size());
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
view[i] = str[i]; view[i] = str[i];
view = array_view<Byte>(view.data() + len, int(view.size()) - len); view = span<Byte>(view.data() + len, int(view.size()) - len);
return len; return len;
} }

View File

@ -1025,13 +1025,13 @@ namespace libtorrent
void send_udp_packet_hostname(char const* hostname void send_udp_packet_hostname(char const* hostname
, int port , int port
, array_view<char const> p , span<char const> p
, error_code& ec , error_code& ec
, int flags); , int flags);
void send_udp_packet(bool ssl void send_udp_packet(bool ssl
, udp::endpoint const& ep , udp::endpoint const& ep
, array_view<char const> p , span<char const> p
, error_code& ec , error_code& ec
, int flags); , int flags);

View File

@ -161,8 +161,8 @@ namespace libtorrent
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
// next_barrier, buffers-to-prepend // next_barrier, buffers-to-prepend
virtual virtual
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
hit_send_barrier(aux::array_view<boost::asio::mutable_buffer> iovec) override; hit_send_barrier(span<boost::asio::mutable_buffer> iovec) override;
#endif #endif
virtual void get_specific_peer_info(peer_info& p) const override; virtual void get_specific_peer_info(peer_info& p) const override;

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/invariant_check.hpp" #include "libtorrent/invariant_check.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#if defined __GLIBC__ #if defined __GLIBC__
#include <malloc.h> #include <malloc.h>
@ -166,7 +166,7 @@ public:
// allocate an uninitialized buffer of the specified size // allocate an uninitialized buffer of the specified size
// and copy the initialization range into the start of the buffer // and copy the initialization range into the start of the buffer
buffer(std::size_t const size, aux::array_view<char const> initialize) buffer(std::size_t const size, span<char const> initialize)
: buffer(size) : buffer(size)
{ {
TORRENT_ASSERT(initialize.size() <= size); TORRENT_ASSERT(initialize.size() <= size);
@ -210,10 +210,10 @@ public:
buffer::const_interval data() const buffer::const_interval data() const
{ return interval(m_begin, m_begin + m_size); } { return interval(m_begin, m_begin + m_size); }
operator aux::array_view<char>() operator span<char>()
{ return aux::array_view<char>(m_begin, int(m_size)); } { return span<char>(m_begin, int(m_size)); }
operator aux::array_view<char const>() const operator span<char const>() const
{ return aux::array_view<char const>(m_begin, int(m_size)); } { return span<char const>(m_begin, int(m_size)); }
std::size_t size() const { return m_size; } std::size_t size() const { return m_size; }

View File

@ -71,7 +71,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -116,7 +116,7 @@ namespace libtorrent
// The content of the argument is copied into the // The content of the argument is copied into the
// newly constructed entry // newly constructed entry
entry(dictionary_type); entry(dictionary_type);
entry(aux::array_view<char const>); entry(span<char const>);
template <typename U, typename = typename std::enable_if< template <typename U, typename = typename std::enable_if<
std::is_same<U, entry::string_type>::value std::is_same<U, entry::string_type>::value
|| std::is_same<U, char const*>::value >::type> || std::is_same<U, char const*>::value >::type>
@ -160,7 +160,7 @@ namespace libtorrent
entry& operator=(entry const&); entry& operator=(entry const&);
entry& operator=(entry&&); entry& operator=(entry&&);
entry& operator=(dictionary_type); entry& operator=(dictionary_type);
entry& operator=(aux::array_view<char const>); entry& operator=(span<char const>);
template <typename U, typename = typename std::enable_if< template <typename U, typename = typename std::enable_if<
std::is_same<U, entry::string_type>::value std::is_same<U, entry::string_type>::value
|| std::is_same<U, char const*>::value >::type> || std::is_same<U, char const*>::value >::type>

View File

@ -174,7 +174,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/session_handle.hpp" #include "libtorrent/session_handle.hpp"
#include "libtorrent/peer_connection_handle.hpp" #include "libtorrent/peer_connection_handle.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -509,8 +509,8 @@ namespace libtorrent
// send buffer, must be owned by the crypto plugin and guaranteed to stay // send buffer, must be owned by the crypto plugin and guaranteed to stay
// alive until the crypto_plugin is destructed or this function is called // alive until the crypto_plugin is destructed or this function is called
// again. // again.
virtual std::tuple<int, aux::array_view<boost::asio::const_buffer>> virtual std::tuple<int, span<boost::asio::const_buffer>>
encrypt(aux::array_view<boost::asio::mutable_buffer> /*send_vec*/) = 0; encrypt(span<boost::asio::mutable_buffer> /*send_vec*/) = 0;
// decrypt the provided buffers. // decrypt the provided buffers.
// consume is set to the number of bytes which should be trimmed from the // consume is set to the number of bytes which should be trimmed from the
@ -521,7 +521,7 @@ namespace libtorrent
// //
// packet_size is set to the minimum number of bytes which must be read to // packet_size is set to the minimum number of bytes which must be read to
// advance the next step of decryption. default is 0 // advance the next step of decryption. default is 0
virtual void decrypt(aux::array_view<boost::asio::mutable_buffer> /*receive_vec*/ virtual void decrypt(span<boost::asio::mutable_buffer> /*receive_vec*/
, int& /* consume */, int& /*produce*/, int& /*packet_size*/) = 0; , int& /* consume */, int& /*produce*/, int& /*packet_size*/) = 0;
}; };
} }

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_id.hpp" #include "libtorrent/peer_id.hpp"
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include <cstdint> #include <cstdint>
@ -87,12 +87,12 @@ namespace libtorrent
// this is the same as default constructing followed by a call to // this is the same as default constructing followed by a call to
// ``update(data, len)``. // ``update(data, len)``.
hasher(char const* data, int len); hasher(char const* data, int len);
hasher(aux::array_view<char const> data); hasher(span<char const> data);
hasher(hasher const&); hasher(hasher const&);
hasher& operator=(hasher const&); hasher& operator=(hasher const&);
// append the following bytes to what is being hashed // append the following bytes to what is being hashed
hasher& update(aux::array_view<char const> data); hasher& update(span<char const> data);
hasher& update(char const* data, int len); hasher& update(char const* data, int len);
// returns the SHA-1 digest of the buffers previously passed to // returns the SHA-1 digest of the buffers previously passed to

View File

@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/udp_socket.hpp" #include "libtorrent/udp_socket.hpp"
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#include "libtorrent/deadline_timer.hpp" #include "libtorrent/deadline_timer.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -71,7 +71,7 @@ namespace libtorrent { namespace dht
, boost::enable_shared_from_this<dht_tracker> , boost::enable_shared_from_this<dht_tracker>
{ {
typedef boost::function<void(udp::endpoint const& typedef boost::function<void(udp::endpoint const&
, aux::array_view<char const>, error_code&, int)> send_fun_t; , span<char const>, error_code&, int)> send_fun_t;
dht_tracker(dht_observer* observer dht_tracker(dht_observer* observer
, io_service& ios , io_service& ios

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/sha1_hash.hpp" #include "libtorrent/sha1_hash.hpp"
#include "libtorrent/extensions.hpp" #include "libtorrent/extensions.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include <list> #include <list>
#include <array> #include <array>
@ -99,8 +99,8 @@ namespace libtorrent
struct encryption_handler struct encryption_handler
{ {
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
encrypt(aux::array_view<boost::asio::mutable_buffer> iovec); encrypt(span<boost::asio::mutable_buffer> iovec);
int decrypt(crypto_receive_buffer& recv_buffer int decrypt(crypto_receive_buffer& recv_buffer
, std::size_t& bytes_transferred); , std::size_t& bytes_transferred);
@ -144,10 +144,10 @@ namespace libtorrent
void set_incoming_key(unsigned char const* key, int len) override; void set_incoming_key(unsigned char const* key, int len) override;
void set_outgoing_key(unsigned char const* key, int len) override; void set_outgoing_key(unsigned char const* key, int len) override;
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
encrypt(aux::array_view<boost::asio::mutable_buffer> buf) override; encrypt(span<boost::asio::mutable_buffer> buf) override;
void decrypt(aux::array_view<boost::asio::mutable_buffer> buf void decrypt(span<boost::asio::mutable_buffer> buf
, int& consume , int& consume
, int& produce , int& produce
, int& packet_size) override; , int& packet_size) override;

View File

@ -61,7 +61,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/receive_buffer.hpp" #include "libtorrent/receive_buffer.hpp"
#include "libtorrent/aux_/allocating_handler.hpp" #include "libtorrent/aux_/allocating_handler.hpp"
#include "libtorrent/debug.hpp" #include "libtorrent/debug.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include <ctime> #include <ctime>
#include <algorithm> #include <algorithm>
@ -749,11 +749,11 @@ namespace libtorrent
void send_piece_suggestions(int num); void send_piece_suggestions(int num);
virtual virtual
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
hit_send_barrier(aux::array_view<boost::asio::mutable_buffer> /* iovec */) hit_send_barrier(span<boost::asio::mutable_buffer> /* iovec */)
{ {
return std::make_tuple(INT_MAX return std::make_tuple(INT_MAX
, aux::array_view<boost::asio::const_buffer>()); , span<boost::asio::const_buffer>());
} }
void attach_to_torrent(sha1_hash const& ih); void attach_to_torrent(sha1_hash const& ih);

View File

@ -30,39 +30,39 @@ POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef TORRENT_ARRAY_VIEW_HPP_INCLUDED #ifndef TORRENT_SPAN_HPP_INCLUDED
#define TORRENT_ARRAY_VIEW_HPP_INCLUDED #define TORRENT_SPAN_HPP_INCLUDED
#include <vector> #include <vector>
#include <array> #include <array>
#include <type_traits> // for std::is_convertible #include <type_traits> // for std::is_convertible
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
namespace libtorrent { namespace aux { namespace libtorrent
template <typename T>
struct array_view
{ {
array_view() : m_ptr(nullptr), m_len(0) {} template <typename T>
struct span
{
span() : m_ptr(nullptr), m_len(0) {}
template <typename U> template <typename U>
array_view(array_view<U> const& v) span(span<U> const& v)
: m_ptr(v.data()), m_len(v.size()) {} : m_ptr(v.data()), m_len(v.size()) {}
array_view(T& p) : m_ptr(&p), m_len(1) {} span(T& p) : m_ptr(&p), m_len(1) {}
array_view(T* p, size_t l) : m_ptr(p), m_len(l) {} span(T* p, size_t l) : m_ptr(p), m_len(l) {}
template <typename U, size_t N> template <typename U, size_t N>
array_view(std::array<U, N>& arr) span(std::array<U, N>& arr)
: m_ptr(arr.data()), m_len(arr.size()) {} : m_ptr(arr.data()), m_len(arr.size()) {}
template <typename U, size_t N> template <typename U, size_t N>
array_view(U (&arr)[N]) span(U (&arr)[N])
: m_ptr(&arr[0]), m_len(N) {} : m_ptr(&arr[0]), m_len(N) {}
// anything with a .data() member function is considered a container // anything with a .data() member function is considered a container
template <typename Cont, typename = decltype(std::declval<Cont>().data())> template <typename Cont, typename = decltype(std::declval<Cont>().data())>
array_view(Cont& c) span(Cont& c)
: m_ptr(c.data()), m_len(c.size()) {} : m_ptr(c.data()), m_len(c.size()) {}
size_t size() const { return m_len; } size_t size() const { return m_len; }
@ -80,19 +80,19 @@ namespace libtorrent { namespace aux {
T& front() const { TORRENT_ASSERT(m_len > 0); return m_ptr[0]; } T& front() const { TORRENT_ASSERT(m_len > 0); return m_ptr[0]; }
T& back() const { TORRENT_ASSERT(m_len > 0); return m_ptr[m_len-1]; } T& back() const { TORRENT_ASSERT(m_len > 0); return m_ptr[m_len-1]; }
array_view<T> first(size_t const n) const span<T> first(size_t const n) const
{ {
TORRENT_ASSERT(size() >= n); TORRENT_ASSERT(size() >= n);
return { data(), size() - n }; return { data(), size() - n };
} }
array_view<T> last(size_t const n) const span<T> last(size_t const n) const
{ {
TORRENT_ASSERT(size() >= n); TORRENT_ASSERT(size() >= n);
return { data() + size() - n, n }; return { data() + size() - n, n };
} }
array_view<T> cut_first(size_t const n) const span<T> cut_first(size_t const n) const
{ {
TORRENT_ASSERT(size() >= n); TORRENT_ASSERT(size() >= n);
return { data() + n, int(size()) - n }; return { data() + n, int(size()) - n };
@ -108,7 +108,6 @@ namespace libtorrent { namespace aux {
T* m_ptr; T* m_ptr;
size_t m_len; size_t m_len;
}; };
}} }
#endif
#endif // TORRENT_SPAN_HPP_INCLUDED

View File

@ -63,7 +63,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/deadline_timer.hpp" #include "libtorrent/deadline_timer.hpp"
#include "libtorrent/union_endpoint.hpp" #include "libtorrent/union_endpoint.hpp"
#include "libtorrent/io_service.hpp" #include "libtorrent/io_service.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include "libtorrent/time.hpp" #include "libtorrent/time.hpp"
#include "libtorrent/debug.hpp" #include "libtorrent/debug.hpp"
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
@ -342,10 +342,10 @@ namespace libtorrent
public: public:
typedef boost::function<void(udp::endpoint const& typedef boost::function<void(udp::endpoint const&
, aux::array_view<char const> , span<char const>
, error_code&, int)> send_fun_t; , error_code&, int)> send_fun_t;
typedef boost::function<void(char const*, int typedef boost::function<void(char const*, int
, aux::array_view<char const> , span<char const>
, error_code&, int)> send_fun_hostname_t; , error_code&, int)> send_fun_hostname_t;
tracker_manager(send_fun_t const& send_fun tracker_manager(send_fun_t const& send_fun
@ -374,13 +374,13 @@ namespace libtorrent
void received_bytes(int bytes); void received_bytes(int bytes);
void incoming_error(error_code const& ec, udp::endpoint const& ep); void incoming_error(error_code const& ec, udp::endpoint const& ep);
bool incoming_packet(udp::endpoint const& ep, aux::array_view<char const> buf); bool incoming_packet(udp::endpoint const& ep, span<char const> buf);
// this is only used for SOCKS packets, since // this is only used for SOCKS packets, since
// they may be addressed to hostname // they may be addressed to hostname
// TODO: 3 make sure the udp_socket supports passing on string-hostnames // TODO: 3 make sure the udp_socket supports passing on string-hostnames
// too, and that this function is used // too, and that this function is used
bool incoming_packet(char const* hostname, aux::array_view<char const> buf); bool incoming_packet(char const* hostname, span<char const> buf);
void update_transaction_id( void update_transaction_id(
boost::shared_ptr<udp_tracker_connection> c boost::shared_ptr<udp_tracker_connection> c
@ -389,10 +389,10 @@ namespace libtorrent
aux::session_settings const& settings() const { return m_settings; } aux::session_settings const& settings() const { return m_settings; }
resolver_interface& host_resolver() { return m_host_resolver; } resolver_interface& host_resolver() { return m_host_resolver; }
void send_hostname(char const* hostname, int port, aux::array_view<char const> p void send_hostname(char const* hostname, int port, span<char const> p
, error_code& ec, int flags = 0); , error_code& ec, int flags = 0);
void send(udp::endpoint const& ep, aux::array_view<char const> p void send(udp::endpoint const& ep, span<char const> p
, error_code& ec, int flags = 0); , error_code& ec, int flags = 0);
private: private:

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/buffer.hpp" #include "libtorrent/buffer.hpp"
#include "libtorrent/deadline_timer.hpp" #include "libtorrent/deadline_timer.hpp"
#include "libtorrent/debug.hpp" #include "libtorrent/debug.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include "libtorrent/aux_/allocating_handler.hpp" #include "libtorrent/aux_/allocating_handler.hpp"
namespace libtorrent namespace libtorrent
@ -76,18 +76,18 @@ namespace libtorrent
struct packet struct packet
{ {
aux::array_view<char> data; span<char> data;
udp::endpoint from; udp::endpoint from;
error_code error; error_code error;
}; };
int read(aux::array_view<packet> pkts, error_code& ec); int read(span<packet> pkts, error_code& ec);
// this is only valid when using a socks5 proxy // this is only valid when using a socks5 proxy
void send_hostname(char const* hostname, int port, aux::array_view<char const> p void send_hostname(char const* hostname, int port, span<char const> p
, error_code& ec, int flags = 0); , error_code& ec, int flags = 0);
void send(udp::endpoint const& ep, aux::array_view<char const> p void send(udp::endpoint const& ep, span<char const> p
, error_code& ec, int flags = 0); , error_code& ec, int flags = 0);
void bind(udp::endpoint const& ep, error_code& ec); void bind(udp::endpoint const& ep, error_code& ec);
void close(); void close();
@ -128,9 +128,9 @@ namespace libtorrent
udp_socket(udp_socket const&); udp_socket(udp_socket const&);
udp_socket& operator=(udp_socket const&); udp_socket& operator=(udp_socket const&);
void wrap(udp::endpoint const& ep, aux::array_view<char const> p, error_code& ec, int flags); void wrap(udp::endpoint const& ep, span<char const> p, error_code& ec, int flags);
void wrap(char const* hostname, int port, aux::array_view<char const> p, error_code& ec, int flags); void wrap(char const* hostname, int port, span<char const> p, error_code& ec, int flags);
bool unwrap(udp::endpoint& from, aux::array_view<char>& buf); bool unwrap(udp::endpoint& from, span<char>& buf);
udp::socket m_socket; udp::socket m_socket;

View File

@ -93,11 +93,11 @@ namespace libtorrent
void timeout(error_code const& error); void timeout(error_code const& error);
void start_announce(); void start_announce();
bool on_receive(udp::endpoint const& ep, aux::array_view<char const> buf); bool on_receive(udp::endpoint const& ep, span<char const> buf);
bool on_receive_hostname(char const* hostname, aux::array_view<char const> buf); bool on_receive_hostname(char const* hostname, span<char const> buf);
bool on_connect_response(aux::array_view<char const> buf); bool on_connect_response(span<char const> buf);
bool on_announce_response(aux::array_view<char const> buf); bool on_announce_response(span<char const> buf);
bool on_scrape_response(aux::array_view<char const> buf); bool on_scrape_response(span<char const> buf);
// wraps tracker_connection::fail // wraps tracker_connection::fail
void fail(error_code const& ec, int code = -1 void fail(error_code const& ec, int code = -1

View File

@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_status.hpp" #include "libtorrent/session_status.hpp"
#include "libtorrent/enum_net.hpp" #include "libtorrent/enum_net.hpp"
#include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/aux_/session_settings.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp"
@ -56,7 +56,7 @@ namespace libtorrent
struct utp_socket_manager final struct utp_socket_manager final
{ {
typedef boost::function<void(udp::endpoint const& typedef boost::function<void(udp::endpoint const&
, aux::array_view<char const> , span<char const>
, error_code&, int)> send_fun_t; , error_code&, int)> send_fun_t;
typedef boost::function<void(boost::shared_ptr<socket_type> const&)> typedef boost::function<void(boost::shared_ptr<socket_type> const&)>
@ -71,7 +71,7 @@ namespace libtorrent
~utp_socket_manager(); ~utp_socket_manager();
// return false if this is not a uTP packet // return false if this is not a uTP packet
bool incoming_packet(udp::endpoint const& ep, aux::array_view<char const> p); bool incoming_packet(udp::endpoint const& ep, span<char const> p);
// if the UDP socket failed with an EAGAIN or EWOULDBLOCK, this will be // if the UDP socket failed with an EAGAIN or EWOULDBLOCK, this will be
// called once the socket is writeable again // called once the socket is writeable again

View File

@ -172,7 +172,7 @@ void delete_utp_impl(utp_socket_impl* s);
bool should_delete(utp_socket_impl* s); bool should_delete(utp_socket_impl* s);
void tick_utp_impl(utp_socket_impl* s, time_point now); void tick_utp_impl(utp_socket_impl* s, time_point now);
void utp_init_mtu(utp_socket_impl* s, int link_mtu, int utp_mtu); void utp_init_mtu(utp_socket_impl* s, int link_mtu, int utp_mtu);
bool utp_incoming_packet(utp_socket_impl* s, aux::array_view<char const> p bool utp_incoming_packet(utp_socket_impl* s, span<char const> p
, udp::endpoint const& ep, time_point receive_time); , udp::endpoint const& ep, time_point receive_time);
bool utp_match(utp_socket_impl* s, udp::endpoint const& ep, std::uint16_t id); bool utp_match(utp_socket_impl* s, udp::endpoint const& ep, std::uint16_t id);
udp::endpoint utp_remote_endpoint(utp_socket_impl* s); udp::endpoint utp_remote_endpoint(utp_socket_impl* s);

View File

@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/performance_counters.hpp" #include "libtorrent/performance_counters.hpp"
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/session_settings.hpp" #include "libtorrent/session_settings.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include "libtorrent/kademlia/dht_observer.hpp" #include "libtorrent/kademlia/dht_observer.hpp"
#include <functional> #include <functional>
@ -121,7 +121,7 @@ TORRENT_TEST(dht_rate_limit)
if (ec) return; if (ec) return;
udp_socket::packet p; udp_socket::packet p;
error_code err; error_code err;
int const num = int(sock.read(lt::aux::array_view<udp_socket::packet>(&p, 1), err)); int const num = int(sock.read(lt::span<udp_socket::packet>(&p, 1), err));
if (num) dht->incoming_packet(p.from, p.data.data(), int(p.data.size())); if (num) dht->incoming_packet(p.from, p.data.data(), int(p.data.size()));
if (stop || err) return; if (stop || err) return;
sock.async_read(on_read); sock.async_read(on_read);

View File

@ -3471,12 +3471,12 @@ namespace libtorrent
} }
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
bt_peer_connection::hit_send_barrier( bt_peer_connection::hit_send_barrier(
aux::array_view<boost::asio::mutable_buffer> iovec) span<boost::asio::mutable_buffer> iovec)
{ {
int next_barrier; int next_barrier;
aux::array_view<boost::asio::const_buffer> out_iovec; span<boost::asio::const_buffer> out_iovec;
std::tie(next_barrier, out_iovec) = m_enc_handler.encrypt(iovec); std::tie(next_barrier, out_iovec) = m_enc_handler.encrypt(iovec);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (next_barrier != 0) if (next_barrier != 0)

View File

@ -328,7 +328,7 @@ namespace libtorrent
m_type = dictionary_t; m_type = dictionary_t;
} }
entry::entry(aux::array_view<char const> v) entry::entry(span<char const> v)
: m_type(undefined_t) : m_type(undefined_t)
{ {
#if TORRENT_USE_ASSERTS #if TORRENT_USE_ASSERTS
@ -468,7 +468,7 @@ namespace libtorrent
return *this; return *this;
} }
entry& entry::operator=(aux::array_view<char const> v) entry& entry::operator=(span<char const> v)
{ {
destruct(); destruct();
new(&data) string_type(v.data(), v.size()); new(&data) string_type(v.data(), v.size());

View File

@ -85,7 +85,7 @@ namespace libtorrent
#endif #endif
} }
hasher::hasher(aux::array_view<char const> data) hasher::hasher(span<char const> data)
: hasher() : hasher()
{ {
update(data); update(data);
@ -148,7 +148,7 @@ namespace libtorrent
return update({data, size_t(len)}); return update({data, size_t(len)});
} }
hasher& hasher::update(aux::array_view<char const> data) hasher& hasher::update(span<char const> data)
{ {
TORRENT_ASSERT(!data.empty()); TORRENT_ASSERT(!data.empty());
#ifdef TORRENT_USE_LIBGCRYPT #ifdef TORRENT_USE_LIBGCRYPT

View File

@ -687,7 +687,7 @@ namespace libtorrent { namespace dht
m_send_quota -= int(m_send_buf.size()); m_send_quota -= int(m_send_buf.size());
error_code ec; error_code ec;
m_send_fun(addr, aux::array_view<char const>(&m_send_buf[0] m_send_fun(addr, span<char const>(&m_send_buf[0]
, int(m_send_buf.size())), ec, 0); , int(m_send_buf.size())), ec, 0);
if (ec) if (ec)
{ {

View File

@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pe_crypto.hpp" #include "libtorrent/pe_crypto.hpp"
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -103,9 +103,9 @@ namespace libtorrent
m_xor_mask = h.final(); m_xor_mask = h.final();
} }
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
encryption_handler::encrypt( encryption_handler::encrypt(
aux::array_view<boost::asio::mutable_buffer> iovec) span<boost::asio::mutable_buffer> iovec)
{ {
using namespace boost::asio; using namespace boost::asio;
@ -146,7 +146,7 @@ namespace libtorrent
} }
int next_barrier = 0; int next_barrier = 0;
aux::array_view<const_buffer> out_iovec; span<const_buffer> out_iovec;
if (num_bufs != 0) if (num_bufs != 0)
{ {
std::tie(next_barrier, out_iovec) std::tie(next_barrier, out_iovec)
@ -290,11 +290,11 @@ namespace libtorrent
encrypt(vec); encrypt(vec);
} }
std::tuple<int, aux::array_view<boost::asio::const_buffer>> std::tuple<int, span<boost::asio::const_buffer>>
rc4_handler::encrypt(aux::array_view<boost::asio::mutable_buffer> bufs) rc4_handler::encrypt(span<boost::asio::mutable_buffer> bufs)
{ {
using namespace boost::asio; using namespace boost::asio;
aux::array_view<boost::asio::const_buffer> empty; span<boost::asio::const_buffer> empty;
if (!m_encrypt) return std::make_tuple(0, empty); if (!m_encrypt) return std::make_tuple(0, empty);
if (bufs.size() == 0) return std::make_tuple(0, empty); if (bufs.size() == 0) return std::make_tuple(0, empty);
@ -313,7 +313,7 @@ namespace libtorrent
return std::make_tuple(bytes_processed, empty); return std::make_tuple(bytes_processed, empty);
} }
void rc4_handler::decrypt(aux::array_view<boost::asio::mutable_buffer> bufs void rc4_handler::decrypt(span<boost::asio::mutable_buffer> bufs
, int& consume , int& consume
, int& produce , int& produce
, int& packet_size) , int& packet_size)

View File

@ -5473,7 +5473,7 @@ namespace libtorrent
int const send_bytes = (std::min)(m_send_buffer.size(), 1024*1024); int const send_bytes = (std::min)(m_send_buffer.size(), 1024*1024);
m_send_buffer.build_mutable_iovec(send_bytes, vec); m_send_buffer.build_mutable_iovec(send_bytes, vec);
int next_barrier; int next_barrier;
aux::array_view<boost::asio::const_buffer> inject_vec; span<boost::asio::const_buffer> inject_vec;
std::tie(next_barrier, inject_vec) = hit_send_barrier(vec); std::tie(next_barrier, inject_vec) = hit_send_barrier(vec);
for (auto i = inject_vec.rbegin(); i != inject_vec.rend(); ++i) for (auto i = inject_vec.rbegin(); i != inject_vec.rend(); ++i)
{ {

View File

@ -51,7 +51,7 @@ boost::asio::mutable_buffer receive_buffer::reserve(int size)
{ {
int const new_size = std::max(m_recv_end + size, m_packet_size); int const new_size = std::max(m_recv_end + size, m_packet_size);
buffer new_buffer(new_size buffer new_buffer(new_size
, aux::array_view<char const>(m_recv_buffer.ptr(), m_recv_end)); , span<char const>(m_recv_buffer.ptr(), m_recv_end));
m_recv_buffer = std::move(new_buffer); m_recv_buffer = std::move(new_buffer);
// since we just increased the size of the buffer, reset the watermark to // since we just increased the size of the buffer, reset the watermark to
@ -73,7 +73,7 @@ void receive_buffer::grow(int const limit)
// re-allcoate the buffer and copy over the part of it that's used // re-allcoate the buffer and copy over the part of it that's used
buffer new_buffer(new_size buffer new_buffer(new_size
, aux::array_view<char const>(m_recv_buffer.ptr(), m_recv_end)); , span<char const>(m_recv_buffer.ptr(), m_recv_end));
m_recv_buffer = std::move(new_buffer); m_recv_buffer = std::move(new_buffer);
// since we just increased the size of the buffer, reset the watermark to // since we just increased the size of the buffer, reset the watermark to
@ -187,7 +187,7 @@ void receive_buffer::normalize(int force_shrink)
bool const shrink_buffer = m_recv_buffer.size() / 2 > m_watermark.mean() bool const shrink_buffer = m_recv_buffer.size() / 2 > m_watermark.mean()
&& m_watermark.mean() > (m_recv_end - m_recv_start); && m_watermark.mean() > (m_recv_end - m_recv_start);
aux::array_view<char const> bytes_to_shift( span<char const> bytes_to_shift(
m_recv_buffer.ptr() + m_recv_start m_recv_buffer.ptr() + m_recv_start
, m_recv_end - m_recv_start); , m_recv_end - m_recv_start);

View File

@ -2196,7 +2196,7 @@ namespace aux {
void session_impl::send_udp_packet_hostname(char const* hostname void session_impl::send_udp_packet_hostname(char const* hostname
, int const port , int const port
, array_view<char const> p , span<char const> p
, error_code& ec , error_code& ec
, int const flags) , int const flags)
{ {
@ -2227,7 +2227,7 @@ namespace aux {
void session_impl::send_udp_packet(bool const ssl void session_impl::send_udp_packet(bool const ssl
, udp::endpoint const& ep , udp::endpoint const& ep
, array_view<char const> p , span<char const> p
, error_code& ec , error_code& ec
, int const flags) , int const flags)
{ {
@ -2346,7 +2346,7 @@ namespace aux {
continue; continue;
} }
aux::array_view<char const> const buf = packet.data; span<char const> const buf = packet.data;
// give the uTP socket manager first dis on the packet. Presumably // give the uTP socket manager first dis on the packet. Presumably
// the majority of packets are uTP packets. // the majority of packets are uTP packets.

View File

@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/udp_tracker_connection.hpp" #include "libtorrent/udp_tracker_connection.hpp"
#include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/aux_/io.hpp" #include "libtorrent/aux_/io.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
using namespace std::placeholders; using namespace std::placeholders;
@ -312,7 +312,7 @@ namespace libtorrent
} }
bool tracker_manager::incoming_packet(udp::endpoint const& ep bool tracker_manager::incoming_packet(udp::endpoint const& ep
, aux::array_view<char const> const buf) , span<char const> const buf)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
// ignore packets smaller than 8 bytes // ignore packets smaller than 8 bytes
@ -327,7 +327,7 @@ namespace libtorrent
// the first word is the action, if it's not [0, 3] // the first word is the action, if it's not [0, 3]
// it's not a valid udp tracker response // it's not a valid udp tracker response
aux::array_view<const char> ptr = buf; span<const char> ptr = buf;
std::uint32_t const action = aux::read_uint32(ptr); std::uint32_t const action = aux::read_uint32(ptr);
if (action > 3) return false; if (action > 3) return false;
@ -357,7 +357,7 @@ namespace libtorrent
} }
bool tracker_manager::incoming_packet(char const* hostname bool tracker_manager::incoming_packet(char const* hostname
, aux::array_view<char const> const buf) , span<char const> const buf)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
// ignore packets smaller than 8 bytes // ignore packets smaller than 8 bytes
@ -365,7 +365,7 @@ namespace libtorrent
// the first word is the action, if it's not [0, 3] // the first word is the action, if it's not [0, 3]
// it's not a valid udp tracker response // it's not a valid udp tracker response
aux::array_view<const char> ptr = buf; span<const char> ptr = buf;
std::uint32_t const action = aux::read_uint32(ptr); std::uint32_t const action = aux::read_uint32(ptr);
if (action > 3) return false; if (action > 3) return false;
@ -389,14 +389,14 @@ namespace libtorrent
} }
void tracker_manager::send_hostname(char const* hostname, int const port void tracker_manager::send_hostname(char const* hostname, int const port
, array_view<char const> p, error_code& ec, int const flags) , span<char const> p, error_code& ec, int const flags)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
m_send_fun_hostname(hostname, port, p, ec, flags); m_send_fun_hostname(hostname, port, p, ec, flags);
} }
void tracker_manager::send(udp::endpoint const& ep void tracker_manager::send(udp::endpoint const& ep
, array_view<char const> p , span<char const> p
, error_code& ec, int const flags) , error_code& ec, int const flags)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());

View File

@ -169,7 +169,7 @@ udp_socket::udp_socket(io_service& ios)
, m_abort(true) , m_abort(true)
{} {}
int udp_socket::read(array_view<packet> pkts, error_code& ec) int udp_socket::read(span<packet> pkts, error_code& ec)
{ {
int const num = int(pkts.size()); int const num = int(pkts.size());
int ret = 0; int ret = 0;
@ -203,11 +203,11 @@ int udp_socket::read(array_view<packet> pkts, error_code& ec)
&& m_socks5_connection->active())) continue; && m_socks5_connection->active())) continue;
p.error = ec; p.error = ec;
p.data = array_view<char>(); p.data = span<char>();
} }
else else
{ {
p.data = array_view<char>(m_buf->data(), len); p.data = span<char>(m_buf->data(), len);
// support packets coming from the SOCKS5 proxy // support packets coming from the SOCKS5 proxy
if (m_socks5_connection && m_socks5_connection->active()) if (m_socks5_connection && m_socks5_connection->active())
@ -234,7 +234,7 @@ int udp_socket::read(array_view<packet> pkts, error_code& ec)
} }
void udp_socket::send_hostname(char const* hostname, int const port void udp_socket::send_hostname(char const* hostname, int const port
, array_view<char const> p, error_code& ec, int const flags) , span<char const> p, error_code& ec, int const flags)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
@ -264,7 +264,7 @@ void udp_socket::send_hostname(char const* hostname, int const port
if (!ec) send(udp::endpoint(target, port), p, ec, flags); if (!ec) send(udp::endpoint(target, port), p, ec, flags);
} }
void udp_socket::send(udp::endpoint const& ep, array_view<char const> p void udp_socket::send(udp::endpoint const& ep, span<char const> p
, error_code& ec, int const flags) , error_code& ec, int const flags)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
@ -298,7 +298,7 @@ void udp_socket::send(udp::endpoint const& ep, array_view<char const> p
m_socket.send_to(boost::asio::buffer(p.data(), p.size()), ep, 0, ec); m_socket.send_to(boost::asio::buffer(p.data(), p.size()), ep, 0, ec);
} }
void udp_socket::wrap(udp::endpoint const& ep, array_view<char const> p void udp_socket::wrap(udp::endpoint const& ep, span<char const> p
, error_code& ec, int const flags) , error_code& ec, int const flags)
{ {
TORRENT_UNUSED(flags); TORRENT_UNUSED(flags);
@ -323,7 +323,7 @@ void udp_socket::wrap(udp::endpoint const& ep, array_view<char const> p
m_socket.send_to(iovec, m_socks5_connection->target(), 0, ec); m_socket.send_to(iovec, m_socks5_connection->target(), 0, ec);
} }
void udp_socket::wrap(char const* hostname, int const port, array_view<char const> p void udp_socket::wrap(char const* hostname, int const port, span<char const> p
, error_code& ec, int const flags) , error_code& ec, int const flags)
{ {
TORRENT_UNUSED(flags); TORRENT_UNUSED(flags);
@ -356,7 +356,7 @@ void udp_socket::wrap(char const* hostname, int const port, array_view<char cons
// buf is an in-out parameter. It will be updated // buf is an in-out parameter. It will be updated
// return false if the packet should be ignored. It's not a valid Socks5 UDP // return false if the packet should be ignored. It's not a valid Socks5 UDP
// forwarded packet // forwarded packet
bool udp_socket::unwrap(udp::endpoint& from, array_view<char>& buf) bool udp_socket::unwrap(udp::endpoint& from, span<char>& buf)
{ {
using namespace libtorrent::detail; using namespace libtorrent::detail;
@ -396,7 +396,7 @@ bool udp_socket::unwrap(udp::endpoint& from, array_view<char>& buf)
from = udp::endpoint(addr, read_uint16(p)); from = udp::endpoint(addr, read_uint16(p));
} }
buf = array_view<char>(p, size - (p - buf.data())); buf = span<char>(p, size - (p - buf.data()));
return true; return true;
} }

View File

@ -53,7 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/ip_filter.hpp" #include "libtorrent/ip_filter.hpp"
#include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/time.hpp"
#include "libtorrent/aux_/io.hpp" #include "libtorrent/aux_/io.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include "libtorrent/socket_io.hpp" #include "libtorrent/socket_io.hpp"
@ -325,7 +325,7 @@ namespace libtorrent
} }
bool udp_tracker_connection::on_receive_hostname(char const* hostname bool udp_tracker_connection::on_receive_hostname(char const* hostname
, aux::array_view<char const> buf) , span<char const> buf)
{ {
TORRENT_UNUSED(hostname); TORRENT_UNUSED(hostname);
// just ignore the hostname this came from, pretend that // just ignore the hostname this came from, pretend that
@ -336,7 +336,7 @@ namespace libtorrent
} }
bool udp_tracker_connection::on_receive(udp::endpoint const& ep bool udp_tracker_connection::on_receive(udp::endpoint const& ep
, aux::array_view<char const> const buf) , span<char const> const buf)
{ {
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
boost::shared_ptr<request_callback> cb = requester(); boost::shared_ptr<request_callback> cb = requester();
@ -382,9 +382,9 @@ namespace libtorrent
// ignore packets smaller than 8 bytes // ignore packets smaller than 8 bytes
if (buf.size() < 8) return false; if (buf.size() < 8) return false;
aux::array_view<const char> ptr = buf; span<const char> ptr = buf;
int const action = read_int32(ptr); int const action = aux::read_int32(ptr);
std::uint32_t const transaction = read_uint32(ptr); std::uint32_t const transaction = aux::read_uint32(ptr);
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action); if (cb) cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action);
@ -452,7 +452,7 @@ namespace libtorrent
m_transaction_id = new_tid; m_transaction_id = new_tid;
} }
bool udp_tracker_connection::on_connect_response(aux::array_view<char const> buf) bool udp_tracker_connection::on_connect_response(span<char const> buf)
{ {
// ignore packets smaller than 16 bytes // ignore packets smaller than 16 bytes
if (buf.size() < 16) return false; if (buf.size() < 16) return false;
@ -464,7 +464,7 @@ namespace libtorrent
// reset transaction // reset transaction
update_transaction_id(); update_transaction_id();
std::uint64_t const connection_id = read_int64(buf); std::uint64_t const connection_id = aux::read_int64(buf);
std::lock_guard<std::mutex> l(m_cache_mutex); std::lock_guard<std::mutex> l(m_cache_mutex);
connection_cache_entry& cce = m_connection_cache[m_target.address()]; connection_cache_entry& cce = m_connection_cache[m_target.address()];
@ -493,7 +493,7 @@ namespace libtorrent
} }
char buf[16]; char buf[16];
aux::array_view<char> view = buf; span<char> view = buf;
TORRENT_ASSERT(m_transaction_id != 0); TORRENT_ASSERT(m_transaction_id != 0);
@ -555,7 +555,7 @@ namespace libtorrent
if (i == m_connection_cache.end()) return; if (i == m_connection_cache.end()) return;
char buf[8 + 4 + 4 + 20]; char buf[8 + 4 + 4 + 20];
aux::array_view<char> view = buf; span<char> view = buf;
aux::write_int64(i->second.connection_id, view); // connection_id aux::write_int64(i->second.connection_id, view); // connection_id
aux::write_int32(action_scrape, view); // action (scrape) aux::write_int32(action_scrape, view); // action (scrape)
@ -588,7 +588,7 @@ namespace libtorrent
} }
} }
bool udp_tracker_connection::on_announce_response(aux::array_view<char const> buf) bool udp_tracker_connection::on_announce_response(span<char const> buf)
{ {
if (buf.size() < 20) return false; if (buf.size() < 20) return false;
@ -647,7 +647,7 @@ namespace libtorrent
return true; return true;
} }
bool udp_tracker_connection::on_scrape_response(aux::array_view<char const> buf) bool udp_tracker_connection::on_scrape_response(span<char const> buf)
{ {
using namespace libtorrent::aux; using namespace libtorrent::aux;
@ -703,7 +703,7 @@ namespace libtorrent
if (m_abort) return; if (m_abort) return;
char buf[800]; char buf[800];
aux::array_view<char> out = buf; span<char> out = buf;
tracker_request const& req = tracker_req(); tracker_request const& req = tracker_req();
bool const stats = req.send_stats; bool const stats = req.send_stats;
@ -771,13 +771,13 @@ namespace libtorrent
if (!m_hostname.empty()) if (!m_hostname.empty())
{ {
m_man.send_hostname(m_hostname.c_str() m_man.send_hostname(m_hostname.c_str()
, m_target.port(), aux::array_view<char const>(buf , m_target.port(), span<char const>(buf
, int(sizeof(buf) - out.size())), ec , int(sizeof(buf) - out.size())), ec
, udp_socket::tracker_connection); , udp_socket::tracker_connection);
} }
else else
{ {
m_man.send(m_target, aux::array_view<char const>(buf m_man.send(m_target, span<char const>(buf
, int(sizeof(buf) - out.size())), ec , int(sizeof(buf) - out.size())), ec
, udp_socket::tracker_connection); , udp_socket::tracker_connection);
} }

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#include "libtorrent/performance_counters.hpp" #include "libtorrent/performance_counters.hpp"
#include "libtorrent/aux_/time.hpp" // for aux::time_now() #include "libtorrent/aux_/time.hpp" // for aux::time_now()
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
// #define TORRENT_DEBUG_MTU 1135 // #define TORRENT_DEBUG_MTU 1135
@ -157,13 +157,13 @@ namespace libtorrent
if ((flags & dont_fragment) && len > TORRENT_DEBUG_MTU) return; if ((flags & dont_fragment) && len > TORRENT_DEBUG_MTU) return;
#endif #endif
m_send_fun(ep, array_view<char const>(p, len), ec m_send_fun(ep, span<char const>(p, len), ec
, ((flags & dont_fragment) ? udp_socket::dont_fragment : 0) , ((flags & dont_fragment) ? udp_socket::dont_fragment : 0)
| udp_socket::peer_connection); | udp_socket::peer_connection);
} }
bool utp_socket_manager::incoming_packet(udp::endpoint const& ep bool utp_socket_manager::incoming_packet(udp::endpoint const& ep
, aux::array_view<char const> p) , span<char const> p)
{ {
// UTP_LOGV("incoming packet size:%d\n", size); // UTP_LOGV("incoming packet size:%d\n", size);

View File

@ -326,7 +326,7 @@ struct utp_socket_impl
void tick(time_point now); void tick(time_point now);
void init_mtu(int link_mtu, int utp_mtu); void init_mtu(int link_mtu, int utp_mtu);
bool incoming_packet(aux::array_view<std::uint8_t const> buf bool incoming_packet(span<std::uint8_t const> buf
, udp::endpoint const& ep, time_point receive_time); , udp::endpoint const& ep, time_point receive_time);
void writable(); void writable();
@ -747,11 +747,11 @@ void utp_init_mtu(utp_socket_impl* s, int link_mtu, int utp_mtu)
} }
bool utp_incoming_packet(utp_socket_impl* s bool utp_incoming_packet(utp_socket_impl* s
, aux::array_view<char const> p , span<char const> p
, udp::endpoint const& ep, time_point receive_time) , udp::endpoint const& ep, time_point receive_time)
{ {
return s->incoming_packet( return s->incoming_packet(
aux::array_view<std::uint8_t const>(reinterpret_cast<std::uint8_t const*>(p.data()), int(p.size())) span<std::uint8_t const>(reinterpret_cast<std::uint8_t const*>(p.data()), int(p.size()))
, ep, receive_time); , ep, receive_time);
} }
@ -2704,7 +2704,7 @@ void utp_socket_impl::init_mtu(int link_mtu, int utp_mtu)
} }
// return false if this is an invalid packet // return false if this is an invalid packet
bool utp_socket_impl::incoming_packet(aux::array_view<std::uint8_t const> buf bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
, udp::endpoint const& ep, time_point receive_time) , udp::endpoint const& ep, time_point receive_time)
{ {
INVARIANT_CHECK; INVARIANT_CHECK;

View File

@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pe_crypto.hpp" #include "libtorrent/pe_crypto.hpp"
#include "libtorrent/session.hpp" #include "libtorrent/session.hpp"
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#include "libtorrent/aux_/array_view.hpp" #include "libtorrent/span.hpp"
#include "setup_transfer.hpp" #include "setup_transfer.hpp"
#include "test.hpp" #include "test.hpp"
@ -63,7 +63,7 @@ void test_enc_handler(libtorrent::crypto_plugin& a, libtorrent::crypto_plugin& b
{ {
mutable_buffer iovec(&buf[0], buf_len); mutable_buffer iovec(&buf[0], buf_len);
int next_barrier; int next_barrier;
lt::aux::array_view<const_buffer> iovec_out; lt::span<const_buffer> iovec_out;
std::tie(next_barrier, iovec_out) = a.encrypt(iovec); std::tie(next_barrier, iovec_out) = a.encrypt(iovec);
TEST_CHECK(buf != cmp_buf); TEST_CHECK(buf != cmp_buf);
TEST_EQUAL(iovec_out.size(), 0); TEST_EQUAL(iovec_out.size(), 0);
@ -85,7 +85,7 @@ void test_enc_handler(libtorrent::crypto_plugin& a, libtorrent::crypto_plugin& b
{ {
mutable_buffer iovec(&buf[0], buf_len); mutable_buffer iovec(&buf[0], buf_len);
int next_barrier; int next_barrier;
lt::aux::array_view<const_buffer> iovec_out; lt::span<const_buffer> iovec_out;
std::tie(next_barrier, iovec_out) = b.encrypt(iovec); std::tie(next_barrier, iovec_out) = b.encrypt(iovec);
TEST_EQUAL(iovec_out.size(), 0); TEST_EQUAL(iovec_out.size(), 0);
TEST_CHECK(buf != cmp_buf); TEST_CHECK(buf != cmp_buf);