core-adapters 0.1.1
Third-party adapters for snicholls-core: nanobind helpers, nlohmann/json hooks, the snicholls_core Python package
Loading...
Searching...
No Matches
snicholls::python::byte_view Class Reference

A read-only view of a Python bytes-like object's contiguous buffer. More...

#include <snicholls/core_adapters/nanobind/bytes.hpp>

Public Member Functions

std::span< const std::byte > bytes () const noexcept
 The bytes.
 
std::string_view chars () const noexcept
 The bytes as characters.
 
std::size_t size () const noexcept
 The length in bytes.
 
bool acquire (PyObject *src) noexcept
 Takes src's buffer (the type caster's step).
 

Detailed Description

A read-only view of a Python bytes-like object's contiguous buffer.

Definition at line 164 of file bytes.hpp.

Member Function Documentation

◆ acquire()

bool snicholls::python::byte_view::acquire ( PyObject *  src)
inlinenoexcept

Takes src's buffer (the type caster's step).

Parameters
srcthe object.
Returns
whether it has one.

Definition at line 178 of file bytes.hpp.

◆ bytes()

std::span< const std::byte > snicholls::python::byte_view::bytes ( ) const
inlinenoexcept

The bytes.

Returns
a span valid while this view lives.

Definition at line 168 of file bytes.hpp.

◆ chars()

std::string_view snicholls::python::byte_view::chars ( ) const
inlinenoexcept

The bytes as characters.

Returns
a string_view valid while this view lives.

Definition at line 173 of file bytes.hpp.

◆ size()

std::size_t snicholls::python::byte_view::size ( ) const
inlinenoexcept

The length in bytes.

Returns
the size.

Definition at line 175 of file bytes.hpp.


The documentation for this class was generated from the following file: