blocxx
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
 TempFileBuffer (const String &dir, size_t bufSize, EKeepFileFlag keepflg=E_DONT_KEEP_FILE)
 Create a new TempFileBuffer object. More...
 
 ~TempFileBuffer ()
 DTOR. More...
 
std::streamsize getSize ()
 
void rewind ()
 Set the read/write position to the beginning of the data. More...
 
void reset ()
 reset puts this stream object back into its initialized state. More...
 
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. More...
 
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 103 of file TempFileStream.hpp.

Member Enumeration Documentation

◆ EKeepFileFlag

Enumerator
E_DONT_KEEP_FILE 
E_KEEP_FILE 

Definition at line 136 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 86 of file TempFileStream.cpp.

References initGetBuffer(), and 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 102 of file TempFileStream.cpp.

References m_buffer.

◆ ~TempFileBuffer()

BLOCXX_NAMESPACE::TempFileBuffer::~TempFileBuffer ( )

DTOR.

Definition at line 137 of file TempFileStream.cpp.

◆ 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 304 of file TempFileStream.cpp.

◆ buffer_in()

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_in ( )
private

Definition at line 265 of file TempFileStream.cpp.

References BLOCXX_THROW.

◆ buffer_out()

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_out ( )
private

Definition at line 162 of file TempFileStream.cpp.

◆ buffer_to_device()

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

Definition at line 282 of file TempFileStream.cpp.

Referenced by initGetBuffer().

◆ getSize()

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

Definition at line 317 of file TempFileStream.cpp.

◆ initBuffers()

void BLOCXX_NAMESPACE::TempFileBuffer::initBuffers ( )
protected

Definition at line 119 of file TempFileStream.cpp.

◆ initGetBuffer()

void BLOCXX_NAMESPACE::TempFileBuffer::initGetBuffer ( )
protected

Definition at line 132 of file TempFileStream.cpp.

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

Referenced by TempFileBuffer().

◆ initPutBuffer()

void BLOCXX_NAMESPACE::TempFileBuffer::initPutBuffer ( )
protected

Definition at line 126 of file TempFileStream.cpp.

Referenced by initGetBuffer(), rewind(), and TempFileBuffer().

◆ operator=()

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

◆ overflow()

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

Definition at line 171 of file TempFileStream.cpp.

◆ 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 381 of file TempFileStream.cpp.

References BLOCXX_NAMESPACE::TempFileStream::m_buffer.

◆ 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 366 of file TempFileStream.cpp.

◆ rewind()

void BLOCXX_NAMESPACE::TempFileBuffer::rewind ( )

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

Definition at line 336 of file TempFileStream.cpp.

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

◆ underflow()

int BLOCXX_NAMESPACE::TempFileBuffer::underflow ( )
protected

Definition at line 229 of file TempFileStream.cpp.

◆ 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 392 of file TempFileStream.cpp.

◆ xsputn()

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

Definition at line 207 of file TempFileStream.cpp.

Member Data Documentation

◆ m_buffer

char* BLOCXX_NAMESPACE::TempFileBuffer::m_buffer
private

Definition at line 216 of file TempFileStream.hpp.

Referenced by initGetBuffer(), and TempFileBuffer().

◆ m_bufSize

size_t BLOCXX_NAMESPACE::TempFileBuffer::m_bufSize
private

Definition at line 215 of file TempFileStream.hpp.

◆ m_dir

String BLOCXX_NAMESPACE::TempFileBuffer::m_dir
private

Definition at line 221 of file TempFileStream.hpp.

◆ m_filePath

String BLOCXX_NAMESPACE::TempFileBuffer::m_filePath
private

Definition at line 223 of file TempFileStream.hpp.

◆ m_isEOF

bool BLOCXX_NAMESPACE::TempFileBuffer::m_isEOF
private

Definition at line 220 of file TempFileStream.hpp.

Referenced by rewind().

◆ m_keepFlag

EKeepFileFlag BLOCXX_NAMESPACE::TempFileBuffer::m_keepFlag
private

Definition at line 222 of file TempFileStream.hpp.

◆ m_readPos

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

Definition at line 218 of file TempFileStream.hpp.

Referenced by rewind().

◆ m_tempFile

File BLOCXX_NAMESPACE::TempFileBuffer::m_tempFile
private

Definition at line 217 of file TempFileStream.hpp.

Referenced by rewind().

◆ m_writePos

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

Definition at line 219 of file TempFileStream.hpp.

Referenced by rewind().


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