Open CASCADE Technology 7.8.0
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).
 
virtual ~Standard_ArrayStreamBuffer ()
 Destructor.
 
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).
 
virtual std::streamsize xsgetn (char *thePtr, std::streamsize theCount) override
 Read a bunch of bytes at once.
 

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.
 
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.
 
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.
 
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.
 
virtual pos_type seekoff (off_type theOff, std::ios_base::seekdir theWay, std::ios_base::openmode theWhich) override
 Seek to specified position.
 
virtual pos_type seekpos (pos_type thePosition, std::ios_base::openmode theWhich) override
 Change to specified position, according to mode.
 

Protected Attributes

const charmyBegin
 
const charmyEnd
 
const charmyCurrent
 

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;
std::istream aStream (&aStreamBuffer);
static void Read(TopoDS_Shape &Sh, Standard_IStream &S, const BRep_Builder &B, const Message_ProgressRange &theProgress=Message_ProgressRange())
Reads a Shape from in returns it in <Sh>. is used to build the shape.
A framework providing advanced tolerance control. It is used to build Shapes. If tolerance control is...
Definition BRep_Builder.hxx:59
Definition NCollection_UBTree.hxx:64
Custom buffer object implementing STL interface std::streambuf for streamed reading from allocated me...
Definition Standard_ArrayStreamBuffer.hxx:48
Describes a shape which.
Definition TopoDS_Shape.hxx:41

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 beginning 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 beginning 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: