DirectZ
Loading...
Searching...
No Matches
memory_buffer Class Reference

A custom stream buffer that uses a dynamically resizable std::vector<char> as its underlying storage. More...

#include <memory_buffer.hpp>

Inheritance diagram for memory_buffer:

Public Member Functions

 memory_buffer ()
 memory_buffer (const memory_buffer &)=delete
memory_bufferoperator= (const memory_buffer &)=delete
std::string str () const
void str (const std::string &s)

Protected Member Functions

int_type underflow () override
 Called when the get area is exhausted. For an in-memory buffer, this means EOF.
int_type overflow (int_type c=traits_type::eof()) override
 Called when a write occurs at or past the end of the put area.
pos_type seekoff (off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) override
 Implements seeking to an absolute or relative position. This is the corrected version.
pos_type seekpos (pos_type pos, std::ios_base::openmode which=std::ios_base::in|std::ios_base::out) override
 Implements seeking to an absolute position by deferring to seekoff.

Detailed Description

A custom stream buffer that uses a dynamically resizable std::vector<char> as its underlying storage.

This class inherits from std::streambuf and overrides key virtual functions to provide stream I/O operations on an in-memory buffer. The buffer can grow as needed, and it maintains separate positions for reading (get) and writing (put).

Constructor & Destructor Documentation

◆ memory_buffer() [1/2]

memory_buffer::memory_buffer ( )
inline

◆ memory_buffer() [2/2]

memory_buffer::memory_buffer ( const memory_buffer & )
delete

Member Function Documentation

◆ operator=()

memory_buffer & memory_buffer::operator= ( const memory_buffer & )
delete

◆ overflow()

int_type memory_buffer::overflow ( int_type c = traits_type::eof())
inlineoverrideprotected

Called when a write occurs at or past the end of the put area.

Parameters
cThe character to be written.
Returns
The character c on success, or traits_type::eof() on failure.

◆ seekoff()

pos_type memory_buffer::seekoff ( off_type off,
std::ios_base::seekdir dir,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out )
inlineoverrideprotected

Implements seeking to an absolute or relative position. This is the corrected version.

◆ seekpos()

pos_type memory_buffer::seekpos ( pos_type pos,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out )
inlineoverrideprotected

Implements seeking to an absolute position by deferring to seekoff.

◆ str() [1/2]

std::string memory_buffer::str ( ) const
inline

◆ str() [2/2]

void memory_buffer::str ( const std::string & s)
inline

◆ underflow()

int_type memory_buffer::underflow ( )
inlineoverrideprotected

Called when the get area is exhausted. For an in-memory buffer, this means EOF.


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