blocxx
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

BLOCXX_NAMESPACE::TempFileBuffer Class Reference

#include <TempFileStream.hpp>

List of all members.

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

Enumerator:
E_DONT_KEEP_FILE 
E_KEEP_FILE 

Definition at line 76 of file TempFileStream.hpp.


Constructor & Destructor Documentation

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().

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().

BLOCXX_NAMESPACE::TempFileBuffer::~TempFileBuffer ( )
BLOCXX_NAMESPACE::TempFileBuffer::TempFileBuffer ( const TempFileBuffer arg) [private]

Member Function Documentation

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().

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().

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().

int BLOCXX_NAMESPACE::TempFileBuffer::buffer_to_device ( const char *  c,
int  n 
) [protected]
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().

void BLOCXX_NAMESPACE::TempFileBuffer::initBuffers ( ) [protected]

Definition at line 89 of file TempFileStream.cpp.

References initGetBuffer(), and initPutBuffer().

void BLOCXX_NAMESPACE::TempFileBuffer::initGetBuffer ( ) [protected]

Definition at line 102 of file TempFileStream.cpp.

References m_buffer.

Referenced by initBuffers(), and rewind().

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(), and TempFileBuffer().

TempFileBuffer& BLOCXX_NAMESPACE::TempFileBuffer::operator= ( const TempFileBuffer arg) [private]
int BLOCXX_NAMESPACE::TempFileBuffer::overflow ( int  c) [protected, virtual]
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().

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().

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().

int BLOCXX_NAMESPACE::TempFileBuffer::underflow ( ) [protected]
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.

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

Definition at line 155 of file TempFileStream.hpp.

Referenced by buffer_in(), and initPutBuffer().

Definition at line 161 of file TempFileStream.hpp.

Referenced by buffer_to_device().

Definition at line 163 of file TempFileStream.hpp.

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

Definition at line 160 of file TempFileStream.hpp.

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

Definition at line 162 of file TempFileStream.hpp.

Referenced by buffer_to_device().

Definition at line 158 of file TempFileStream.hpp.

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

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: