mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
refactor: decouple tr_announcer_udp (#4002)
This commit is contained in:
@@ -56,6 +56,16 @@ public:
|
||||
return Iterator(buf_, offset_ + n_bytes);
|
||||
}
|
||||
|
||||
[[nodiscard]] Iterator operator-(int n_bytes)
|
||||
{
|
||||
return Iterator(buf_, offset_ - n_bytes);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr auto operator-(Iterator const& that) const noexcept
|
||||
{
|
||||
return offset_ - that.offset_;
|
||||
}
|
||||
|
||||
Iterator& operator++() noexcept
|
||||
{
|
||||
if (iov_.iov_len > 1)
|
||||
@@ -71,6 +81,19 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator& operator+=(int n_bytes)
|
||||
{
|
||||
setOffset(offset_ + n_bytes);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Iterator& operator--() noexcept
|
||||
{
|
||||
// TODO(ckerr) inefficient; calls evbuffer_ptr_peek() every time
|
||||
setOffset(offset_ - 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool operator==(Iterator const& that) const noexcept
|
||||
{
|
||||
return offset_ == that.offset_;
|
||||
@@ -90,7 +113,7 @@ public:
|
||||
evbuffer_peek(buf_, std::numeric_limits<ev_ssize_t>::max(), &ptr, &iov_, 1);
|
||||
}
|
||||
|
||||
evbuffer* const buf_;
|
||||
evbuffer* buf_;
|
||||
Iovec iov_ = {};
|
||||
size_t offset_ = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user