Avara3D 0.2.0
C++ API reference
a3d::Buffer Class Reference

Container for a contiguous byte buffer. More...

#include <a3d/Buffer.h>

Public Member Functions

 Buffer (const std::filesystem::path &path)
 Reads the complete contents of path into a Buffer. More...
 
 Buffer (const std::vector< std::byte > &buf)
 Creates a Buffer by copying the bytes in buf. More...
 
 Buffer (const std::byte *buf, std::size_t size)
 Creates a Buffer containing size bytes copied from buf. More...
 
 Buffer (std::size_t size)
 Creates a Buffer with storage for size bytes. More...
 
std::byte * data () const
 Returns a mutable pointer to the owned bytes, or nullptr when the Buffer is empty. More...
 
std::size_t size () const
 Returns the buffer size in bytes. More...
 
std::byte * operator* () const
 Returns a mutable pointer to the owned bytes, equivalent to data(). More...
 
std::byte operator[] (std::size_t idx) const
 Returns the byte at idx without bounds checking. More...
 

Detailed Description

Container for a contiguous byte buffer.

Copying a Buffer deep-copies its bytes; moving transfers the owned storage.

Definition at line 23 of file Buffer.h.

Constructor & Destructor Documentation

◆ Buffer() [1/4]

a3d::Buffer::Buffer ( const std::filesystem::path &  path)
explicit

Reads the complete contents of path into a Buffer.

Exceptions
std::runtime_errorif the file cannot be opened, sized, or read.

◆ Buffer() [2/4]

a3d::Buffer::Buffer ( const std::vector< std::byte > &  buf)
explicit

Creates a Buffer by copying the bytes in buf.

◆ Buffer() [3/4]

a3d::Buffer::Buffer ( const std::byte *  buf,
std::size_t  size 
)

Creates a Buffer containing size bytes copied from buf.

◆ Buffer() [4/4]

a3d::Buffer::Buffer ( std::size_t  size)
explicit

Creates a Buffer with storage for size bytes.

Member Function Documentation

◆ data()

std::byte * a3d::Buffer::data ( ) const

Returns a mutable pointer to the owned bytes, or nullptr when the Buffer is empty.

◆ operator*()

std::byte * a3d::Buffer::operator* ( ) const

Returns a mutable pointer to the owned bytes, equivalent to data().

◆ operator[]()

std::byte a3d::Buffer::operator[] ( std::size_t  idx) const

Returns the byte at idx without bounds checking.

Parameters
idxvalid zero-based byte index.

◆ size()

std::size_t a3d::Buffer::size ( ) const

Returns the buffer size in bytes.


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