blocxx
Public Member Functions | Private Member Functions | Private Attributes

BLOCXX_NAMESPACE::TempFileStream Class Reference

TempFileStream is an iostream that uses an underlying temp file to hold its content to reduce memory requirements. More...

#include <TempFileStream.hpp>

List of all members.

Public Member Functions

 TempFileStream (size_t bufSize=4096, TempFileBuffer::EKeepFileFlag keepflg=TempFileBuffer::E_DONT_KEEP_FILE)
 Create a new TempFileStream object.
 TempFileStream (const String &dir, size_t bufSize=4096, TempFileBuffer::EKeepFileFlag keepflg=TempFileBuffer::E_DONT_KEEP_FILE)
 Create a new TempFileStream object.
std::streamsize getSize ()
void rewind ()
 Set the read/write position to the beginning of the data.
void reset ()
 reset puts the underlying 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

Private Member Functions

 TempFileStream (const TempFileStream &)
TempFileStreamoperator= (const TempFileStream &)

Private Attributes

AutoPtr< TempFileBufferm_buffer

Detailed Description

TempFileStream is an iostream that uses an underlying temp file to hold its content to reduce memory requirements.

The amount of data kept in memory is specified by a user supplied buffer size.

Definition at line 179 of file TempFileStream.hpp.


Constructor & Destructor Documentation

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

Create a new TempFileStream object.

Parameters:
bufSizeThe desired size of the in memory buffer. This buffer becomes full, the data is written to a temp file. The default bufSize is 4K if not specified.
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. The default behaviour is to delete the temp file when it is closed.

Definition at line 367 of file TempFileStream.cpp.

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

Create a new TempFileStream object.

Parameters:
dirThis specifies where the temp file will be located.
bufSizeThe desired size of the in memory buffer. This buffer becomes full, the data is written to a temp file. The default bufSize is 4K if not specified.
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. The default behaviour is to delete the temp file when it is closed.

Definition at line 374 of file TempFileStream.cpp.

BLOCXX_NAMESPACE::TempFileStream::TempFileStream ( const TempFileStream ) [private]

Member Function Documentation

std::streamsize BLOCXX_NAMESPACE::TempFileStream::getSize ( ) [inline]
Returns:
the size of the data currently in the underlying buffer (this includes the temp file data if it exists).

Definition at line 216 of file TempFileStream.hpp.

TempFileStream& BLOCXX_NAMESPACE::TempFileStream::operator= ( const TempFileStream ) [private]
String BLOCXX_NAMESPACE::TempFileStream::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 397 of file TempFileStream.cpp.

References m_buffer.

void BLOCXX_NAMESPACE::TempFileStream::reset ( )

reset puts the underlying stream object back into its initialized state.

see TempFileBuffer reset.

Definition at line 390 of file TempFileStream.cpp.

References m_buffer, and BLOCXX_NAMESPACE::AutoPtr< X >::reset().

Referenced by BLOCXX_NAMESPACE::TempFileEnumerationImplBase::clear().

void BLOCXX_NAMESPACE::TempFileStream::rewind ( )

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

Definition at line 382 of file TempFileStream.cpp.

References m_buffer.

bool BLOCXX_NAMESPACE::TempFileStream::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 405 of file TempFileStream.cpp.

References m_buffer.

Referenced by BLOCXX_NAMESPACE::TempFileEnumerationImplBase::usingTempFile().


Member Data Documentation

Definition at line 249 of file TempFileStream.hpp.

Referenced by releaseFileAndReset(), reset(), rewind(), and usingTempFile().


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