mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
ircd::buffer: Add copy() overloads.
This commit is contained in:
parent
438866a3d7
commit
04e83c6b90
1 changed files with 19 additions and 0 deletions
|
@ -46,6 +46,8 @@ namespace ircd::buffer
|
|||
template<class it> size_t consume(buffer<it> &buffer, const size_t &bytes);
|
||||
template<class it> char *copy(char *&dest, char *const &stop, const buffer<it> &buffer);
|
||||
template<class it> size_t copy(char *const &dest, const size_t &max, const buffer<it> &buffer);
|
||||
template<class it> size_t copy(mutable_buffer &dst, const buffer<it> &src);
|
||||
size_t copy(mutable_buffer &dst, const string_view &src);
|
||||
template<class it> std::ostream &operator<<(std::ostream &s, const buffer<it> &buffer);
|
||||
|
||||
// Iterable of buffers tools
|
||||
|
@ -207,6 +209,23 @@ ircd::buffer::operator<<(std::ostream &s, const buffer<it> &buffer)
|
|||
return s;
|
||||
}
|
||||
|
||||
inline size_t
|
||||
ircd::buffer::copy(mutable_buffer &dst,
|
||||
const string_view &s)
|
||||
{
|
||||
return copy(dst, const_buffer{s});
|
||||
}
|
||||
|
||||
template<class it>
|
||||
size_t
|
||||
ircd::buffer::copy(mutable_buffer &dst,
|
||||
const buffer<it> &src)
|
||||
{
|
||||
auto e(begin(dst));
|
||||
auto b(copy(e, end(dst), src));
|
||||
return std::distance(b, e);
|
||||
}
|
||||
|
||||
template<class it>
|
||||
size_t
|
||||
ircd::buffer::copy(char *const &dest,
|
||||
|
|
Loading…
Reference in a new issue