Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Raii::Buffer Class Reference

A buffer of bytes, with a fixed size. More...

#include <buffer.h>

Collaboration diagram for Raii::Buffer:
Collaboration graph

Public Member Functions

 Buffer ()
 Creates a buffer class that manages an empty block of memory. More...
 
 Buffer (size_t bufferSize)
 Allocates a new buffer, which is the given number of bytes in size. More...
 
 Buffer (const Buffer &other)
 Creates a copy of the given buffer. More...
 
 Buffer (Buffer &&other) noexcept
 Moves the given buffer. More...
 
Bufferoperator= (const Buffer &other)
 Creates a copy of the given buffer, and assigns that to this buffer. More...
 
Bufferoperator= (Buffer &&other) noexcept
 Moves the given buffer's data to this buffer. More...
 
 ~Buffer ()
 Destructor. More...
 
size_t GetSize () const
 Gets the buffer's size, in bytes. More...
 
char & operator[] (size_t i)
 Indexed access. Returns reference to mutable char. More...
 
const char & operator[] (size_t i) const
 Indexed access. Returns reference to a constant char. More...
 

Private Attributes

size_t m_bufSize
 Stores the size of this buffer's memory block. More...
 
char * m_data
 Stores a pointer to this buffer's memory block. More...
 

Detailed Description

A buffer of bytes, with a fixed size.

Buffers manage a block of memory, which can be copied and moved. A Buffer's memory block is automatically released when it goes out of scope.

Definition at line 30 of file buffer.h.

Constructor & Destructor Documentation

Raii::Buffer::Buffer ( )
inline

Creates a buffer class that manages an empty block of memory.

Definition at line 34 of file buffer.h.

Raii::Buffer::Buffer ( size_t  bufferSize)
inlineexplicit

Allocates a new buffer, which is the given number of bytes in size.

Definition at line 37 of file buffer.h.

Raii::Buffer::Buffer ( const Buffer other)

Creates a copy of the given buffer.

Definition at line 24 of file buffer.cpp.

References m_bufSize, and m_data.

Raii::Buffer::Buffer ( Buffer &&  other)
noexcept

Moves the given buffer.

Definition at line 31 of file buffer.cpp.

Raii::Buffer::~Buffer ( )
inline

Destructor.

Definition at line 52 of file buffer.h.

References m_data.

Member Function Documentation

Buffer & Raii::Buffer::operator= ( const Buffer other)

Creates a copy of the given buffer, and assigns that to this buffer.

Definition at line 40 of file buffer.cpp.

References m_bufSize, and m_data.

Buffer & Raii::Buffer::operator= ( Buffer &&  other)
noexcept

Moves the given buffer's data to this buffer.

Definition at line 64 of file buffer.cpp.

References m_bufSize, and m_data.

size_t Raii::Buffer::GetSize ( ) const
inline

Gets the buffer's size, in bytes.

Definition at line 55 of file buffer.h.

References m_bufSize.

Referenced by printBuffer().

Here is the caller graph for this function:

char& Raii::Buffer::operator[] ( size_t  i)
inline

Indexed access. Returns reference to mutable char.

Definition at line 58 of file buffer.h.

References m_data.

const char& Raii::Buffer::operator[] ( size_t  i) const
inline

Indexed access. Returns reference to a constant char.

Definition at line 61 of file buffer.h.

References m_data.

Member Data Documentation

size_t Raii::Buffer::m_bufSize
private

Stores the size of this buffer's memory block.

Definition at line 65 of file buffer.h.

Referenced by Buffer(), GetSize(), and operator=().

char* Raii::Buffer::m_data
private

Stores a pointer to this buffer's memory block.

Definition at line 68 of file buffer.h.

Referenced by Buffer(), operator=(), operator[](), and ~Buffer().


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