blocxx
BLOCXX_NAMESPACE::TempFileBuffer Class Reference

#include <TempFileStream.hpp>

Inheritance diagram for BLOCXX_NAMESPACE::TempFileBuffer:

Public Types

enum  EKeepFileFlag { E_DONT_KEEP_FILE , E_KEEP_FILE }
 

Public Member Functions

 TempFileBuffer (size_t bufSize, EKeepFileFlag keepflg=E_DONT_KEEP_FILE)
 Create a new TempFileBuffer object.
 
 TempFileBuffer (const String &dir, size_t bufSize, EKeepFileFlag keepflg=E_DONT_KEEP_FILE)
 Create a new TempFileBuffer object.
 
 ~TempFileBuffer ()
 DTOR.
 
std::streamsize getSize ()
 
void rewind ()
 Set the read/write position to the beginning of the data.
 
void reset ()
 reset puts this stream object back into its initialized state.
 
String releaseFileAndReset ()
 releaseFileAndReset is like the reset method except it ensures all data has been flused to the underlying file and returned name of the file if the caller requested that it not be deleted.
 
bool usingTempFile () const
 

Protected Member Functions

int underflow ()
 
std::streamsize xsputn (const char *s, std::streamsize n)
 
virtual int overflow (int c)
 
void initBuffers ()
 
void initGetBuffer ()
 
void initPutBuffer ()
 
int buffer_to_device (const char *c, int n)
 
int buffer_from_device (char *c, int n)
 

Private Member Functions

int buffer_in ()
 
int buffer_out ()
 
 TempFileBuffer (const TempFileBuffer &arg)
 
TempFileBufferoperator= (const TempFileBuffer &arg)
 

Private Attributes

size_t m_bufSize
 
char * m_buffer
 
File m_tempFile
 
std::streamsize m_readPos
 
std::streamsize m_writePos
 
bool m_isEOF
 
String m_dir
 
EKeepFileFlag m_keepFlag
 
String m_filePath
 

Detailed Description

Definition at line 73 of file TempFileStream.hpp.

Member Enumeration Documentation

◆ EKeepFileFlag

Enumerator
E_DONT_KEEP_FILE 
E_KEEP_FILE 

Definition at line 76 of file TempFileStream.hpp.

Constructor & Destructor Documentation

◆ TempFileBuffer() [1/3]

BLOCXX_NAMESPACE::TempFileBuffer::TempFileBuffer ( size_t bufSize,
EKeepFileFlag keepflg = E_DONT_KEEP_FILE )

Create a new TempFileBuffer object.

Parameters
bufSizeThe size of the buffer used by this stream.
keepflgIf E_KEEP_FILE is specified the temporary file used by this object will not be deleted on destruction. The caller is responsible for calling releaseFileAnReset to get the file name of the underlying temp file. If releaseFileAndReset is never called this object will attempt to delete the temp file on destruction.

Definition at line 56 of file TempFileStream.cpp.

References initPutBuffer().

◆ TempFileBuffer() [2/3]

BLOCXX_NAMESPACE::TempFileBuffer::TempFileBuffer ( const String & dir,
size_t bufSize,
EKeepFileFlag keepflg = E_DONT_KEEP_FILE )

Create a new TempFileBuffer object.

Parameters
dirThe directory that will contain the temp file used by this object.
bufSizeThe size of the buffer used by this stream.
keepflgIf E_KEEP_FILE is specified the temporary file used by this object will not be deleted on destruction. The caller is responsible for calling releaseFileAndReset to get the file name of the underlying temp file. If releaseFileAndReset is never called this object will attempt to delete the temp file on destruction.

Definition at line 72 of file TempFileStream.cpp.

References initPutBuffer().

◆ ~TempFileBuffer()

BLOCXX_NAMESPACE::TempFileBuffer::~TempFileBuffer ( )

◆ TempFileBuffer() [3/3]

BLOCXX_NAMESPACE::TempFileBuffer::TempFileBuffer ( const TempFileBuffer & arg)
private

Member Function Documentation

◆ buffer_from_device()

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_from_device ( char * c,
int n )
protected

Definition at line 274 of file TempFileStream.cpp.

References m_tempFile, and BLOCXX_NAMESPACE::File::read().

Referenced by buffer_in().

◆ buffer_in()

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_in ( )
private

Definition at line 235 of file TempFileStream.cpp.

References buffer_from_device(), m_buffer, m_bufSize, and m_isEOF.

Referenced by underflow().

◆ buffer_out()

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_out ( )
private

Definition at line 132 of file TempFileStream.cpp.

References buffer_to_device(), initPutBuffer(), and m_buffer.

Referenced by overflow(), releaseFileAndReset(), rewind(), and underflow().

◆ buffer_to_device()

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_to_device ( const char * c,
int n )
protected

◆ getSize()

std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::getSize ( )
Returns
The size of all the data within this object.

Definition at line 287 of file TempFileStream.cpp.

References m_tempFile, m_writePos, and BLOCXX_NAMESPACE::File::size().

◆ initBuffers()

void BLOCXX_NAMESPACE::TempFileBuffer::initBuffers ( )
protected

Definition at line 89 of file TempFileStream.cpp.

References initGetBuffer(), and initPutBuffer().

◆ initGetBuffer()

void BLOCXX_NAMESPACE::TempFileBuffer::initGetBuffer ( )
protected

Definition at line 102 of file TempFileStream.cpp.

References m_buffer.

Referenced by initBuffers(), and rewind().

◆ initPutBuffer()

void BLOCXX_NAMESPACE::TempFileBuffer::initPutBuffer ( )
protected

Definition at line 96 of file TempFileStream.cpp.

References m_buffer, and m_bufSize.

Referenced by buffer_out(), initBuffers(), overflow(), reset(), TempFileBuffer(), and TempFileBuffer().

◆ operator=()

TempFileBuffer & BLOCXX_NAMESPACE::TempFileBuffer::operator= ( const TempFileBuffer & arg)
private

◆ overflow()

int BLOCXX_NAMESPACE::TempFileBuffer::overflow ( int c)
protectedvirtual

◆ releaseFileAndReset()

String BLOCXX_NAMESPACE::TempFileBuffer::releaseFileAndReset ( )

releaseFileAndReset is like the reset method except it ensures all data has been flused to the underlying file and returned name of the file if the caller requested that it not be deleted.

Returns
The name of the underlying temp file if the caller requested that it not be deleted on close.

Definition at line 351 of file TempFileStream.cpp.

References buffer_out(), BLOCXX_NAMESPACE::String::erase(), m_filePath, and reset().

Referenced by ~TempFileBuffer().

◆ reset()

void BLOCXX_NAMESPACE::TempFileBuffer::reset ( )

reset puts this stream object back into its initialized state.

If a tempfile exists, it is deleted. It is not recomended to use this method if you requested the underlying file not be deleted. You should should call releaseFileAndReset under those conditions. This will give you the name of the underlying file that you can delete if you desire.

Definition at line 336 of file TempFileStream.cpp.

References BLOCXX_NAMESPACE::File::close(), initPutBuffer(), m_isEOF, m_readPos, m_tempFile, and m_writePos.

Referenced by releaseFileAndReset().

◆ rewind()

void BLOCXX_NAMESPACE::TempFileBuffer::rewind ( )

Set the read/write position to the beginning of the data.

Definition at line 306 of file TempFileStream.cpp.

References buffer_out(), initGetBuffer(), m_buffer, m_isEOF, m_readPos, m_tempFile, m_writePos, and BLOCXX_NAMESPACE::File::seek().

◆ underflow()

int BLOCXX_NAMESPACE::TempFileBuffer::underflow ( )
protected

◆ usingTempFile()

bool BLOCXX_NAMESPACE::TempFileBuffer::usingTempFile ( ) const
Returns
true if the temp is being used. This could return false if none of the buffered data has been written to disk yet. If this method returns false, it doesn't necessarily mean that a temp file won't be used when the data is flushed.

Definition at line 362 of file TempFileStream.cpp.

References m_tempFile.

◆ xsputn()

std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::xsputn ( const char * s,
std::streamsize n )
protected

Definition at line 177 of file TempFileStream.cpp.

References i.

Member Data Documentation

◆ m_buffer

char* BLOCXX_NAMESPACE::TempFileBuffer::m_buffer
private

◆ m_bufSize

size_t BLOCXX_NAMESPACE::TempFileBuffer::m_bufSize
private

Definition at line 155 of file TempFileStream.hpp.

Referenced by buffer_in(), and initPutBuffer().

◆ m_dir

String BLOCXX_NAMESPACE::TempFileBuffer::m_dir
private

Definition at line 161 of file TempFileStream.hpp.

Referenced by buffer_to_device().

◆ m_filePath

String BLOCXX_NAMESPACE::TempFileBuffer::m_filePath
private

Definition at line 163 of file TempFileStream.hpp.

Referenced by buffer_to_device(), releaseFileAndReset(), and ~TempFileBuffer().

◆ m_isEOF

bool BLOCXX_NAMESPACE::TempFileBuffer::m_isEOF
private

Definition at line 160 of file TempFileStream.hpp.

Referenced by buffer_in(), reset(), rewind(), and underflow().

◆ m_keepFlag

EKeepFileFlag BLOCXX_NAMESPACE::TempFileBuffer::m_keepFlag
private

Definition at line 162 of file TempFileStream.hpp.

Referenced by buffer_to_device().

◆ m_readPos

std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::m_readPos
private

Definition at line 158 of file TempFileStream.hpp.

Referenced by overflow(), reset(), rewind(), and underflow().

◆ m_tempFile

File BLOCXX_NAMESPACE::TempFileBuffer::m_tempFile
private

◆ m_writePos

std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::m_writePos
private

Definition at line 159 of file TempFileStream.hpp.

Referenced by getSize(), overflow(), reset(), rewind(), and underflow().


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