Prism Ruby parser
Loading...
Searching...
No Matches
buffer.hpp File Reference

Ownership of buffers from C++, and access to their contents. More...

#include "prism/compiler/cplusplus.hpp"
#include "prism/compiler/lifetimebound.hpp"
#include "prism/buffer.h"
#include <memory>
#include <string_view>
Include dependency graph for buffer.hpp:

Go to the source code of this file.

Data Structures

struct  prism::buffer_deleter
 Frees a buffer with pm_buffer_free. More...

Typedefs

using prism::unique_buffer = std::unique_ptr<pm_buffer_t, buffer_deleter>
 An owned buffer.

Functions

unique_buffer prism::make_buffer () noexcept
 Allocate a new empty buffer.
std::string_view prism::view (const pm_buffer_t *buffer) noexcept
 The bytes written to the given buffer so far.

Detailed Description

Ownership of buffers from C++, and access to their contents.

Function Documentation

◆ make_buffer()

unique_buffer prism::make_buffer ( )
inlinenodiscardnoexcept

Allocate a new empty buffer.

Allocation failure aborts, so this never throws.

Returns
A unique_buffer managing the newly allocated buffer.

◆ view()

std::string_view prism::view ( const pm_buffer_t * buffer)
inlinenodiscardnoexcept

The bytes written to the given buffer so far.

Parameters
bufferThe buffer to view.
Returns
A string_view of the contents of the buffer.