mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 04:51:08 +01:00
ircd::buffer: Add constructors which limit requested size to input buffer.
This commit is contained in:
parent
c719d137b0
commit
031f3e0a72
2 changed files with 19 additions and 0 deletions
|
@ -36,6 +36,7 @@ struct ircd::buffer::buffer
|
||||||
explicit operator std::string() const;
|
explicit operator std::string() const;
|
||||||
operator string_view() const;
|
operator string_view() const;
|
||||||
|
|
||||||
|
buffer(const buffer &start, const size_t &size);
|
||||||
buffer(const it &start, const it &stop);
|
buffer(const it &start, const it &stop);
|
||||||
buffer(const it &start, const size_t &size);
|
buffer(const it &start, const size_t &size);
|
||||||
buffer();
|
buffer();
|
||||||
|
@ -61,6 +62,16 @@ ircd::buffer::buffer<it>::buffer(const it &start,
|
||||||
:std::pair<it, it>{start, stop}
|
:std::pair<it, it>{start, stop}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
template<class it>
|
||||||
|
inline __attribute__((always_inline))
|
||||||
|
ircd::buffer::buffer<it>::buffer(const buffer &start,
|
||||||
|
const size_t &size)
|
||||||
|
:buffer
|
||||||
|
{
|
||||||
|
data(start), std::min(ircd::buffer::size(start), size)
|
||||||
|
}
|
||||||
|
{}
|
||||||
|
|
||||||
template<class it>
|
template<class it>
|
||||||
inline __attribute__((always_inline, flatten))
|
inline __attribute__((always_inline, flatten))
|
||||||
ircd::buffer::buffer<it>::operator string_view()
|
ircd::buffer::buffer<it>::operator string_view()
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct ircd::buffer::const_buffer
|
||||||
template<size_t SIZE> const_buffer(const char (&buf)[SIZE]);
|
template<size_t SIZE> const_buffer(const char (&buf)[SIZE]);
|
||||||
template<size_t SIZE> const_buffer(const std::array<char, SIZE> &buf);
|
template<size_t SIZE> const_buffer(const std::array<char, SIZE> &buf);
|
||||||
const_buffer(const buffer<const char *> &b);
|
const_buffer(const buffer<const char *> &b);
|
||||||
|
const_buffer(const buffer<char *> &b, const size_t &);
|
||||||
const_buffer(const buffer<char *> &b);
|
const_buffer(const buffer<char *> &b);
|
||||||
const_buffer(const mutable_buffer &b);
|
const_buffer(const mutable_buffer &b);
|
||||||
const_buffer(const string_view &s);
|
const_buffer(const string_view &s);
|
||||||
|
@ -42,6 +43,13 @@ ircd::buffer::const_buffer::const_buffer(const buffer<char *> &b)
|
||||||
:buffer<const char *>{data(b), size(b)}
|
:buffer<const char *>{data(b), size(b)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
inline
|
||||||
|
__attribute__((always_inline))
|
||||||
|
ircd::buffer::const_buffer::const_buffer(const buffer<char *> &b,
|
||||||
|
const size_t &max)
|
||||||
|
:buffer<const char *>{{data(b), size(b)}, max}
|
||||||
|
{}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
ircd::buffer::const_buffer::const_buffer(const mutable_buffer &b)
|
ircd::buffer::const_buffer::const_buffer(const mutable_buffer &b)
|
||||||
|
|
Loading…
Reference in a new issue