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 const 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 const 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 const size_t len = buffer.size();
61 const auto sink =
next(len);
62 for(
size_t i = 0; i != len; ++i) {
67 constexpr void append(uint8_t val,
size_t repeat = 1) {
68 for(
auto& b :
next(repeat)) {
73 constexpr bool full()
const {
return m_buffer.empty(); }
78 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 val, 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