6#ifndef PRISM_BUFFER_HPP
7#define PRISM_BUFFER_HPP
9#include "prism/compiler/cplusplus.hpp"
10#include "prism/compiler/lifetimebound.hpp"
48[[nodiscard]]
inline std::string_view
A wrapper around a contiguous block of allocated memory.
struct pm_buffer_t pm_buffer_t
A wrapper around a contiguous block of allocated memory.
Definition buffer.h:22
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_buffer_t * pm_buffer_new(void)
Allocate and initialize a new buffer.
PRISM_EXPORTED_FUNCTION size_t pm_buffer_length(const pm_buffer_t *buffer) PRISM_NONNULL(1)
Return the length of the buffer.
PRISM_EXPORTED_FUNCTION char * pm_buffer_value(const pm_buffer_t *buffer) PRISM_NONNULL(1)
Return the value of the buffer.
PRISM_EXPORTED_FUNCTION void pm_buffer_free(pm_buffer_t *buffer) PRISM_NONNULL(1)
Free both the memory held by the buffer and the buffer itself.
unique_buffer make_buffer() noexcept
Allocate a new empty buffer.
Definition buffer.hpp:38
std::unique_ptr< pm_buffer_t, buffer_deleter > unique_buffer
An owned buffer.
Definition buffer.hpp:30
std::string_view view(const pm_buffer_t *buffer) noexcept
The bytes written to the given buffer so far.
Definition buffer.hpp:49
Frees a buffer with pm_buffer_free.
Definition buffer.hpp:20
void operator()(pm_buffer_t *buffer) const noexcept
Frees the given buffer.
Definition buffer.hpp:26