0
0
Fork 0
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:
Jason Volk 2017-09-14 11:28:11 -07:00
parent 438866a3d7
commit 04e83c6b90

View file

@ -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,