#include <ccbuffil.h>
Inheritance diagram for CCBufferFile:
Public Types | |
enum | { DEFAULT_BUFSIZ = BUFSIZ } |
Public Member Functions | |
CCBufferFile (CCLexFile *pFile, BOOL bReportErrors=FALSE, BOOL bThrowExceptions=FALSE) | |
Provides objects representing in-memory files. | |
virtual void | init (BYTE *pBuffer, FilePos size) |
Initializes the buffer associated with this CCBufferFile Having constructed a CCBufferFile object a user can initialize the buffer associated with it. Useful for BitmapSources. | |
virtual | ~CCBufferFile () |
Destructor - stops the base class destructor from deleting the stream we borrowed. | |
virtual BOOL | setMode (INT32 fileMode=ios::binary) |
Provides dummy implementation for pure function. | |
virtual CCFile & | read (void *pBuffer, UINT32 length=1) |
Attempts to read the given number of bytes into the given buffer while at the same time builds up the whole stream in the buffer given in the constructor or via init(). | |
virtual CCFile & | write (const void *pBuffer, UINT32 length=1) |
Mimics the functionality of the stream class bad() functionMimics the functionality of the stream class fail() functionAttempts to write out the given number of bytes to the CCFile given in the constructor. Supplying a pBuffer will cause the data in the given buffer to be copied to the internal buffer before it is written out. If the write to file is unsuccessful therefore, the internal buffer can be considered corrupt (much as the file would be). | |
BOOL | IsAllWritten () const |
Determines whether write() has been called sufficiently often to have written out the whole buffer. | |
Protected Attributes | |
ADDR | m_pBuffer |
ADDR | m_pBufferFillPosition |
OFFSET | m_BytesToFillBuffer |
ADDR | m_pBufferWritePosition |
OFFSET | m_BytesToWrite |
CCLexFile * | m_pTrueFile |
Private Member Functions | |
CC_DECLARE_DYNAMIC (CCBufferFile) |
Definition at line 120 of file ccbuffil.h.
|
Definition at line 143 of file ccbuffil.h. 00144 { 00145 DEFAULT_BUFSIZ = BUFSIZ 00146 };
|
|
Provides objects representing in-memory files.
Definition at line 132 of file ccbuffil.cpp. 00133 : CCStreamFile(pFile->GetIOFile(), 0, bReportErrors, bThrowExceptions) 00134 { 00135 m_pTrueFile = pFile; 00136 00137 m_pBuffer = NULL; 00138 00139 m_pBufferFillPosition = NULL; 00140 m_BytesToFillBuffer = 0; 00141 00142 m_pBufferWritePosition = NULL; 00143 m_BytesToWrite = 0; 00144 }
|
|
Destructor - stops the base class destructor from deleting the stream we borrowed.
Definition at line 158 of file ccbuffil.cpp.
|
|
|
|
Initializes the buffer associated with this CCBufferFile Having constructed a CCBufferFile object a user can initialize the buffer associated with it. Useful for BitmapSources.
Definition at line 174 of file ccbuffil.cpp. 00175 { 00176 m_pBuffer = pBuffer; 00177 00178 m_pBufferFillPosition = pBuffer; 00179 m_BytesToFillBuffer = size; 00180 00181 m_pBufferWritePosition = pBuffer; 00182 m_BytesToWrite = size; 00183 }
|
|
Determines whether write() has been called sufficiently often to have written out the whole buffer.
Definition at line 332 of file ccbuffil.cpp. 00333 { 00334 return (m_BytesToWrite == 0); 00335 }
|
|
Attempts to read the given number of bytes into the given buffer while at the same time builds up the whole stream in the buffer given in the constructor or via init().
Reimplemented from CCStreamFile. Definition at line 215 of file ccbuffil.cpp. 00216 { 00217 // Read in as many bytes as the internal buffer can take up to a maximum of the 00218 // number given in length 00219 INT32 BytesToRead = m_BytesToFillBuffer > length ? length : m_BytesToFillBuffer; 00220 00221 ERROR3IF(m_pBufferFillPosition == NULL, "m_pBufferFillPosition == NULL"); 00222 00223 m_pTrueFile->read((BYTE*)m_pBufferFillPosition, BytesToRead); 00224 00225 // Find the number of bytes actually read 00226 INT32 BytesRead = IOFile->gcount(); 00227 00228 // Copy the read data to the given buffer if any 00229 if (pBuffer != NULL) 00230 { 00231 memcpy(pBuffer, m_pBufferFillPosition, BytesRead); 00232 } 00233 00234 // Update the internal buffer details 00235 m_pBufferFillPosition += BytesRead; 00236 m_BytesToFillBuffer -= BytesRead; 00237 00238 return *this; 00239 }
|
|
Provides dummy implementation for pure function.
Reimplemented from CCStreamFile. Definition at line 196 of file ccbuffil.cpp. 00197 { 00198 return TRUE; 00199 }
|
|
Mimics the functionality of the stream class bad() functionMimics the functionality of the stream class fail() functionAttempts to write out the given number of bytes to the CCFile given in the constructor. Supplying a pBuffer will cause the data in the given buffer to be copied to the internal buffer before it is written out. If the write to file is unsuccessful therefore, the internal buffer can be considered corrupt (much as the file would be).
Reimplemented from CCStreamFile. Definition at line 295 of file ccbuffil.cpp. 00296 { 00297 // Write as many bytes as the internal buffer will allow up to a maximum of the 00298 // number given in length 00299 INT32 BytesToWrite = m_BytesToWrite > length ? length : m_BytesToWrite; 00300 00301 ERROR3IF(m_pBufferWritePosition == NULL, "m_pBufferWritePosition == NULL"); 00302 00303 if (pBuffer != NULL) 00304 { 00305 // Overwrite the data in the internal buffer with that in the given buffer 00306 memcpy(m_pBufferWritePosition, pBuffer, BytesToWrite); 00307 } 00308 // Write out whatever's in that position 00309 m_pTrueFile->write((BYTE*)m_pBufferWritePosition, BytesToWrite); 00310 00311 00312 // Update the internal buffer details 00313 m_pBufferWritePosition += BytesToWrite; 00314 m_BytesToWrite -= BytesToWrite; 00315 00316 return *this; 00317 }
|
|
Definition at line 153 of file ccbuffil.h. |
|
Definition at line 156 of file ccbuffil.h. |
|
Definition at line 150 of file ccbuffil.h. |
|
Definition at line 152 of file ccbuffil.h. |
|
Definition at line 155 of file ccbuffil.h. |
|
Definition at line 158 of file ccbuffil.h. |