DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
docwire::imemorystreambuf Class Reference

imemorystreambuf is a stream buffer that wraps std::span<const std::byte> and provides a compatible interface with std::istream. More...

#include <memorystream.h>

Inheritance diagram for docwire::imemorystreambuf:

Public Member Functions

 imemorystreambuf (std::span< const std::byte > source)
 Construct a new imemorystreambuf object. More...
 
std::streampos seekpos (std::streampos sp, std::ios_base::openmode which=std::ios_base::in) override
 Set the position of the stream buffer. More...
 
std::streampos seekoff (std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in) override
 Move the position of the stream buffer. More...
 

Detailed Description

imemorystreambuf is a stream buffer that wraps std::span<const std::byte> and provides a compatible interface with std::istream.

C++20 introduced std::span, which is a utility class that provides a way to access a contiguous sequence of elements. imemorystreambuf is a stream buffer that wraps std::span<const std::byte> and provides a compatible interface with std::istream.

Unlike std::istringstream, imemorystreambuf does not make a copy of the underlying data. It uses a std::span to provide a way to access the data.

There are several alternatives to using imemorystreambuf, such as std::istringstream, but they have a few limitations:

  • std::istringstream requires a copy of the data.
  • std::istrstream is deprecated in C++11 and removed in C++26.
  • std::ispanstream but it requires C++23

imemorystreambuf is a drop-in replacement for std::istrstream and is compatible with C++20 and later.

Definition at line 37 of file memorystream.h.

Constructor & Destructor Documentation

◆ imemorystreambuf()

docwire::imemorystreambuf::imemorystreambuf ( std::span< const std::byte >  source)
inlineexplicit

Construct a new imemorystreambuf object.

Parameters
sourceThe source data to be used by the stream buffer.

Definition at line 47 of file memorystream.h.

Member Function Documentation

◆ seekoff()

std::streampos docwire::imemorystreambuf::seekoff ( std::streamoff  off,
std::ios_base::seekdir  way,
std::ios_base::openmode  which = std::ios_base::in 
)
inlineoverride

Move the position of the stream buffer.

Parameters
offThe offset to move the position.
wayThe direction to move the position.
whichThe I/O mode.
Returns
std::streampos The new position of the stream buffer.

Definition at line 78 of file memorystream.h.

◆ seekpos()

std::streampos docwire::imemorystreambuf::seekpos ( std::streampos  sp,
std::ios_base::openmode  which = std::ios_base::in 
)
inlineoverride

Set the position of the stream buffer.

Parameters
spThe position to set.
whichThe I/O mode.
Returns
std::streampos The new position of the stream buffer.

Definition at line 61 of file memorystream.h.


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