Open CASCADE Technology  7.4.0
Public Member Functions | Protected Member Functions | Protected Attributes

Standard_ReadLineBuffer Class Reference

Auxiliary tool for buffered reading of lines from input stream. More...

#include <Standard_ReadLineBuffer.hxx>

Public Member Functions

 Standard_ReadLineBuffer (size_t theMaxBufferSizeBytes)
 Constructor with initialization. More...
 
virtual ~Standard_ReadLineBuffer ()
 Destructor. More...
 
void Clear ()
 Clear buffer and cached values. More...
 
template<typename Stream_T >
const char * ReadLine (Stream_T &theStream, size_t &theLineLength)
 Read next line from the stream. More...
 
template<typename Stream_T >
const char * ReadLine (Stream_T &theStream, size_t &theLineLength, int64_t &theReadData)
 Read next line from the stream. More...
 

Protected Member Functions

bool readStream (std::istream &theStream, size_t theLen, size_t &theReadLen)
 Read from stl stream. More...
 
bool readStream (FILE *theStream, size_t theLen, size_t &theReadLen)
 Read from FILE stream. More...
 

Protected Attributes

std::vector< char > myReadBuffer
 Temp read buffer. More...
 
std::vector< char > myReadBufferLastStr
 Part of last string of myReadBuffer. More...
 
bool myUseReadBufferLastStr
 Flag to use myReadBufferLastStr during next line reading. More...
 
size_t myBufferPos
 Current position in myReadBuffer. More...
 
size_t myBytesLastRead
 The number of characters that were read last time from myReadBuffer. More...
 

Detailed Description

Auxiliary tool for buffered reading of lines from input stream.

Constructor & Destructor Documentation

◆ Standard_ReadLineBuffer()

Standard_ReadLineBuffer::Standard_ReadLineBuffer ( size_t  theMaxBufferSizeBytes)
inline

Constructor with initialization.

Parameters
theMaxBufferSizeBytesthe length of buffer to read (in bytes)

◆ ~Standard_ReadLineBuffer()

virtual Standard_ReadLineBuffer::~Standard_ReadLineBuffer ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ Clear()

void Standard_ReadLineBuffer::Clear ( )
inline

Clear buffer and cached values.

◆ ReadLine() [1/2]

template<typename Stream_T >
const char* Standard_ReadLineBuffer::ReadLine ( Stream_T &  theStream,
size_t &  theLineLength 
)
inline

Read next line from the stream.

Returns
pointer to the line or NULL on error / end of reading buffer (in case of NULL result theStream should be checked externally to identify the presence of errors). Empty lines will be returned also with zero length.
Parameters
theLineLength[out] - output parameter defined length of returned line.

◆ ReadLine() [2/2]

template<typename Stream_T >
const char* Standard_ReadLineBuffer::ReadLine ( Stream_T &  theStream,
size_t &  theLineLength,
int64_t &  theReadData 
)
inline

Read next line from the stream.

Returns
pointer to the line or NULL on error / end of reading buffer (in case of NULL result theStream should be checked externally to identify the presence of errors). Empty lines will be returned also with zero length.
Parameters
theLineLength[out] - output parameter defined length of returned line.
theReadData[out] - output parameter defined the number of elements successfully read from the stream during this call, it can be zero if no data was read and the line is taken from the buffer.

◆ readStream() [1/2]

bool Standard_ReadLineBuffer::readStream ( std::istream &  theStream,
size_t  theLen,
size_t &  theReadLen 
)
inlineprotected

Read from stl stream.

Returns
true if reading was finished without errors.

◆ readStream() [2/2]

bool Standard_ReadLineBuffer::readStream ( FILE *  theStream,
size_t  theLen,
size_t &  theReadLen 
)
inlineprotected

Read from FILE stream.

Returns
true if reading was finished without errors.

Field Documentation

◆ myBufferPos

size_t Standard_ReadLineBuffer::myBufferPos
protected

Current position in myReadBuffer.

◆ myBytesLastRead

size_t Standard_ReadLineBuffer::myBytesLastRead
protected

The number of characters that were read last time from myReadBuffer.

◆ myReadBuffer

std::vector<char> Standard_ReadLineBuffer::myReadBuffer
protected

Temp read buffer.

◆ myReadBufferLastStr

std::vector<char> Standard_ReadLineBuffer::myReadBufferLastStr
protected

Part of last string of myReadBuffer.

◆ myUseReadBufferLastStr

bool Standard_ReadLineBuffer::myUseReadBufferLastStr
protected

Flag to use myReadBufferLastStr during next line reading.


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