Open CASCADE Technology  7.3.1.dev
Public Member Functions | Protected Member Functions | Protected Attributes
Standard_ArrayStreamBuffer Class Reference

Custom buffer object implementing STL interface std::streambuf for streamed reading from allocated memory block. Implements minimal sub-set of methods for passing buffer to std::istream, including seek support. More...

#include <Standard_ArrayStreamBuffer.hxx>

Inheritance diagram for Standard_ArrayStreamBuffer:
Inheritance graph
[legend]

Public Member Functions

 Standard_ArrayStreamBuffer (const char *theBegin, const size_t theSize)
 Main constructor. Passed pointer is stored as is (memory is NOT copied nor released with destructor). More...
 
virtual ~Standard_ArrayStreamBuffer ()
 Destructor. More...
 
virtual void Init (const char *theBegin, const size_t theSize)
 (Re)-initialize the stream. Passed pointer is stored as is (memory is NOT copied nor released with destructor). More...
 
virtual std::streamsize xsgetn (char *thePtr, std::streamsize theCount) override
 Read a bunch of bytes at once. More...
 

Protected Member Functions

virtual int_type underflow () override
 Get character on underflow. Virtual function called by other member functions to get the current character in the controlled input sequence without changing the current position. More...
 
virtual int_type uflow () override
 Get character on underflow and advance position. Virtual function called by other member functions to get the current character in the controlled input sequence and then advance the position indicator to the next character. More...
 
virtual int_type pbackfail (int_type ch) override
 Put character back in the case of backup underflow. Virtual function called by other member functions to put a character back into the controlled input sequence and decrease the position indicator. More...
 
virtual std::streamsize showmanyc () override
 Get number of characters available. Virtual function (to be read s-how-many-c) called by other member functions to get an estimate on the number of characters available in the associated input sequence. More...
 
virtual pos_type seekoff (off_type theOff, std::ios_base::seekdir theWay, std::ios_base::openmode theWhich) override
 Seek to specified position. More...
 
virtual pos_type seekpos (pos_type thePosition, std::ios_base::openmode theWhich) override
 Change to specified position, according to mode. More...
 

Protected Attributes

const char * myBegin
 
const char * myEnd
 
const char * myCurrent
 

Detailed Description

Custom buffer object implementing STL interface std::streambuf for streamed reading from allocated memory block. Implements minimal sub-set of methods for passing buffer to std::istream, including seek support.

This class can be used for creating a seekable input stream in cases, when the source data does not satisfies Reader requirements (non-seekable stream, compressed data) or represents an in-memory resource.

The memory itself is NOT managed by this class - it is up to the caller to ensure that passed memory pointer is not released during Standard_ArrayStreamBuffer lifetime.

Usage example:

const char* theBuffer;
const size_t theBufferLength;
Standard_ArrayStreamBuffer aStreamBuffer (theBuffer, theBufferLength);
std::istream aStream (&aStreamBuffer);
TopoDS_Shape aShape;
BRep_Builder aBuilder;
BRepTools::Read (aShape, aStream, aBuilder);

Constructor & Destructor Documentation

◆ Standard_ArrayStreamBuffer()

Standard_ArrayStreamBuffer::Standard_ArrayStreamBuffer ( const char *  theBegin,
const size_t  theSize 
)

Main constructor. Passed pointer is stored as is (memory is NOT copied nor released with destructor).

Parameters
theBeginpointer to the beggining of pre-allocated buffer
theSizelength of pre-allocated buffer

◆ ~Standard_ArrayStreamBuffer()

virtual Standard_ArrayStreamBuffer::~Standard_ArrayStreamBuffer ( )
virtual

Destructor.

Member Function Documentation

◆ Init()

virtual void Standard_ArrayStreamBuffer::Init ( const char *  theBegin,
const size_t  theSize 
)
virtual

(Re)-initialize the stream. Passed pointer is stored as is (memory is NOT copied nor released with destructor).

Parameters
theBeginpointer to the beggining of pre-allocated buffer
theSizelength of pre-allocated buffer

◆ pbackfail()

virtual int_type Standard_ArrayStreamBuffer::pbackfail ( int_type  ch)
overrideprotectedvirtual

Put character back in the case of backup underflow. Virtual function called by other member functions to put a character back into the controlled input sequence and decrease the position indicator.

◆ seekoff()

virtual pos_type Standard_ArrayStreamBuffer::seekoff ( off_type  theOff,
std::ios_base::seekdir  theWay,
std::ios_base::openmode  theWhich 
)
overrideprotectedvirtual

Seek to specified position.

◆ seekpos()

virtual pos_type Standard_ArrayStreamBuffer::seekpos ( pos_type  thePosition,
std::ios_base::openmode  theWhich 
)
overrideprotectedvirtual

Change to specified position, according to mode.

◆ showmanyc()

virtual std::streamsize Standard_ArrayStreamBuffer::showmanyc ( )
overrideprotectedvirtual

Get number of characters available. Virtual function (to be read s-how-many-c) called by other member functions to get an estimate on the number of characters available in the associated input sequence.

◆ uflow()

virtual int_type Standard_ArrayStreamBuffer::uflow ( )
overrideprotectedvirtual

Get character on underflow and advance position. Virtual function called by other member functions to get the current character in the controlled input sequence and then advance the position indicator to the next character.

◆ underflow()

virtual int_type Standard_ArrayStreamBuffer::underflow ( )
overrideprotectedvirtual

Get character on underflow. Virtual function called by other member functions to get the current character in the controlled input sequence without changing the current position.

◆ xsgetn()

virtual std::streamsize Standard_ArrayStreamBuffer::xsgetn ( char *  thePtr,
std::streamsize  theCount 
)
overridevirtual

Read a bunch of bytes at once.

Field Documentation

◆ myBegin

const char* Standard_ArrayStreamBuffer::myBegin
protected

◆ myCurrent

const char* Standard_ArrayStreamBuffer::myCurrent
protected

◆ myEnd

const char* Standard_ArrayStreamBuffer::myEnd
protected

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