blocxx
|
#include <TempFileStream.hpp>
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) | |
TempFileBuffer & | operator= (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 |
Definition at line 73 of file TempFileStream.hpp.
Definition at line 76 of file TempFileStream.hpp.
BLOCXX_NAMESPACE::TempFileBuffer::TempFileBuffer | ( | size_t | bufSize, |
EKeepFileFlag | keepflg = E_DONT_KEEP_FILE |
||
) |
Create a new TempFileBuffer object.
bufSize | The size of the buffer used by this stream. |
keepflg | If 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.
dir | The directory that will contain the temp file used by this object. |
bufSize | The size of the buffer used by this stream. |
keepflg | If 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 | ( | ) |
DTOR.
Definition at line 107 of file TempFileStream.cpp.
References BLOCXX_NAMESPACE::String::length(), m_buffer, m_filePath, releaseFileAndReset(), and BLOCXX_NAMESPACE::FileSystem::removeFile().
BLOCXX_NAMESPACE::TempFileBuffer::TempFileBuffer | ( | const TempFileBuffer & | arg | ) | [private] |
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] |
Definition at line 252 of file TempFileStream.cpp.
References BLOCXX_THROW, BLOCXX_NAMESPACE::FileSystem::createAutoDeleteTempFile(), BLOCXX_NAMESPACE::FileSystem::createTempFile(), E_KEEP_FILE, m_dir, m_filePath, m_keepFlag, m_tempFile, and BLOCXX_NAMESPACE::File::write().
Referenced by buffer_out().
std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::getSize | ( | ) |
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] |
Definition at line 141 of file TempFileStream.cpp.
References buffer_out(), initPutBuffer(), m_readPos, m_tempFile, m_writePos, BLOCXX_NAMESPACE::File::seek(), and BLOCXX_NAMESPACE::File::tell().
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.
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] |
Definition at line 199 of file TempFileStream.cpp.
References buffer_in(), buffer_out(), m_buffer, m_isEOF, m_readPos, m_tempFile, m_writePos, BLOCXX_NAMESPACE::File::seek(), and BLOCXX_NAMESPACE::File::tell().
bool BLOCXX_NAMESPACE::TempFileBuffer::usingTempFile | ( | ) | const |
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.
char* BLOCXX_NAMESPACE::TempFileBuffer::m_buffer [private] |
Definition at line 156 of file TempFileStream.hpp.
Referenced by buffer_in(), buffer_out(), initGetBuffer(), initPutBuffer(), rewind(), underflow(), and ~TempFileBuffer().
size_t BLOCXX_NAMESPACE::TempFileBuffer::m_bufSize [private] |
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().
bool BLOCXX_NAMESPACE::TempFileBuffer::m_isEOF [private] |
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().
std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::m_readPos [private] |
Definition at line 158 of file TempFileStream.hpp.
Referenced by overflow(), reset(), rewind(), and underflow().
Definition at line 157 of file TempFileStream.hpp.
Referenced by buffer_from_device(), buffer_to_device(), getSize(), overflow(), reset(), rewind(), underflow(), and usingTempFile().
std::streamsize BLOCXX_NAMESPACE::TempFileBuffer::m_writePos [private] |
Definition at line 159 of file TempFileStream.hpp.
Referenced by getSize(), overflow(), reset(), rewind(), and underflow().