7#ifndef BOTAN_BUFFER_STUFFER_H_
8#define BOTAN_BUFFER_STUFFER_H_
10#include <botan/assert.h>
11#include <botan/strong_type.h>
12#include <botan/types.h>
26 constexpr explicit BufferStuffer(std::span<uint8_t> buffer) : m_buffer(buffer) {}
32 constexpr std::span<uint8_t>
next(
size_t bytes) {
35 auto result = m_buffer.first(bytes);
36 m_buffer = m_buffer.subspan(bytes);
40 template <
size_t bytes>
41 constexpr std::span<uint8_t, bytes>
next() {
44 auto result = m_buffer.first<bytes>();
45 m_buffer = m_buffer.subspan(bytes);
49 template <concepts::contiguous_strong_type StrongT>
59 constexpr void append(std::span<const uint8_t> buffer) {
60 auto sink =
next(buffer.size());
61 std::copy(buffer.begin(), buffer.end(), sink.begin());
64 constexpr void append(uint8_t b,
size_t repeat = 1) {
65 auto sink =
next(repeat);
66 std::fill(sink.begin(), sink.end(), b);
69 constexpr bool full()
const {
return m_buffer.empty(); }
74 std::span<uint8_t> m_buffer;
#define BOTAN_STATE_CHECK(expr)
constexpr void append(std::span< const uint8_t > buffer)
constexpr void append(uint8_t b, size_t repeat=1)
constexpr size_t remaining_capacity() const
StrongSpan< StrongT > next(size_t bytes)
constexpr std::span< uint8_t > next(size_t bytes)
constexpr std::span< uint8_t, bytes > next()
constexpr uint8_t & next_byte()
constexpr BufferStuffer(std::span< uint8_t > buffer)
constexpr bool full() const