#include <ccbhfile.h>
Inheritance diagram for CCBinHexFile:
Public Member Functions | |
CCBinHexFile (CCLexFile *pCCFile, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE) | |
virtual | ~CCBinHexFile () |
virtual BOOL | setMode (INT32 fileMode=0) |
virtual BOOL | isOpen () const |
virtual CCFile & | seekIn (FilePos Pos) |
virtual CCFile & | seekIn (INT32 Offset, ios::seekdir Dir) |
virtual FilePos | tellIn () |
virtual CCFile & | seek (FilePos pos) |
virtual FilePos | tell () |
virtual CCFile & | read (void *buf, UINT32 length=1) |
virtual CCFile & | read (StringBase *buf) |
virtual CCFile & | read (char &buf) |
virtual CCFile & | write (const void *buf, UINT32 length=1) |
Writes the buffer to the file. | |
virtual CCFile & | write (const StringBase &buf, UINT32 length=0) |
Writes the buffer to the file. | |
virtual CCFile & | write (char &buf) |
Writes the char to the file. | |
virtual size_t | Size () |
virtual BOOL | eof () const |
virtual void | close () |
virtual BOOL | good () const |
Simple base implentation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function). | |
virtual BOOL | bad () const |
Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function). | |
virtual BOOL | fail () const |
Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function). | |
virtual void | SetBadState () |
virtual void | SetGoodState () |
virtual iostream * | GetIOFile () |
virtual CCFile & | flush () |
Flushes a file's buffers. By default it does nothing - override it if you want it to do anything. (The CCDiskFile class overrides this function.). | |
virtual filedesc | GetFileHandle () const |
virtual BOOL | IsCompressionSet () |
Allow the reading of the compression flag to see if all output data is compressed or not. | |
virtual BOOL | SetCompression (BOOL) |
Allow the setting of the compression flag so that all output data is compressed. | |
virtual BOOL | InitCompression (BOOL Header=FALSE) |
virtual BOOL | StartCompression () |
virtual BOOL | StopCompression () |
Protected Member Functions | |
void | ByteToHex (BYTE b, char *pPtr) |
Translates the byte to hex (always writes two chars). | |
Protected Attributes | |
CCLexFile * | m_pFile |
BYTE | m_Buffer [BinHexMaxLineLength] |
Private Member Functions | |
CC_DECLARE_DYNAMIC (CCBinHexFile) |
Definition at line 119 of file ccbhfile.h.
|
Definition at line 124 of file ccbhfile.h.
|
|
Definition at line 126 of file ccbhfile.h.
|
|
Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
Reimplemented from CCFile. Definition at line 177 of file ccbhfile.h.
|
|
Translates the byte to hex (always writes two chars).
Definition at line 254 of file ccbhfile.cpp. 00255 { 00256 char nibble = (b >> 4); 00257 if (nibble > 9) 00258 nibble += 55; // ('A' - 10) 00259 else 00260 nibble += '0'; 00261 pPtr[0] = nibble; 00262 nibble = b & 0xF; 00263 if (nibble > 9) 00264 nibble += 55; // ('A' - 10) 00265 else 00266 nibble += '0'; 00267 pPtr[1] = nibble; 00268 }
|
|
|
|
Implements CCFile. Definition at line 173 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 170 of file ccbhfile.h.
|
|
Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
Reimplemented from CCFile. Definition at line 178 of file ccbhfile.h.
|
|
Flushes a file's buffers. By default it does nothing - override it if you want it to do anything. (The CCDiskFile class overrides this function.).
Reimplemented from CCFile. Definition at line 190 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 193 of file ccbhfile.h. 00193 { return(m_pFile->GetFileHandle()); };
|
|
Implements CCFile. Definition at line 187 of file ccbhfile.h.
|
|
Simple base implentation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
Reimplemented from CCFile. Definition at line 176 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 199 of file ccbhfile.h. 00199 { return(TRUE); };
|
|
Allow the reading of the compression flag to see if all output data is compressed or not.
Reimplemented from CCFile. Definition at line 196 of file ccbhfile.h. 00196 { return(FALSE); };
|
|
Implements CCFile. Definition at line 135 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 156 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 152 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 148 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 144 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 139 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 138 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 181 of file ccbhfile.h. 00181 { m_pFile->SetBadState(); };
|
|
Allow the setting of the compression flag so that all output data is compressed.
Reimplemented from CCFile. Definition at line 197 of file ccbhfile.h. 00197 { return(FALSE); };
|
|
Implements CCFile. Definition at line 182 of file ccbhfile.h. 00182 { m_pFile->SetGoodState(); };
|
|
Implements CCFile. Definition at line 129 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 167 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 200 of file ccbhfile.h. 00200 { return(TRUE); };
|
|
Implements CCFile. Definition at line 201 of file ccbhfile.h. 00201 { return(TRUE); };
|
|
Implements CCFile. Definition at line 145 of file ccbhfile.h.
|
|
Implements CCFile. Definition at line 143 of file ccbhfile.h.
|
|
Writes the char to the file.
Implements CCFile. Definition at line 285 of file ccbhfile.cpp. 00286 { 00287 char Trans[2]; 00288 00289 ByteToHex((BYTE)buf, Trans); 00290 00291 return(m_pFile->write(Trans, 2)); 00292 }
|
|
Writes the buffer to the file.
Implements CCFile. Definition at line 184 of file ccbhfile.cpp. 00185 { 00186 if (length == 0) 00187 length = buf.Length(); 00188 00189 00190 #if 0 != wxUSE_UNICODE 00191 size_t cchTCSrc = camWcstombs( NULL, (const TCHAR *)buf, 0 ) + 1; 00192 PSTR pTCSrc = PSTR( alloca( cchTCSrc ) ); 00193 camWcstombs( pTCSrc, (const TCHAR *)buf, cchTCSrc ); 00194 #else 00195 const char* pTCSrc = buf; 00196 #endif 00197 00198 const char* pSrc = (const char*) pTCSrc; 00199 00200 // Number of chars we can translate in one go (max half of buffer size) 00201 UINT32 Blocklen = BinHexMaxLineLength / 2; 00202 UINT32 Index; 00203 char* pPtr; 00204 BOOL bCRLF = (length > Blocklen); 00205 00206 while (length > 0) 00207 { 00208 if (Blocklen > length) 00209 Blocklen = length; 00210 00211 if (bCRLF) 00212 { 00213 if (m_pFile->write("\r\n", 2).fail()) 00214 { 00215 GotError(_R(IDE_FILE_WRITE_ERROR)); 00216 break; 00217 } 00218 } 00219 00220 pPtr = (char*)m_Buffer; 00221 00222 for (Index = 0; Index < Blocklen; Index++) 00223 { 00224 ByteToHex(*pSrc, pPtr); 00225 pSrc += 1; 00226 pPtr += 2; 00227 } 00228 00229 if (m_pFile->write(m_Buffer, Blocklen * 2).fail()) 00230 { 00231 GotError(_R(IDE_FILE_WRITE_ERROR)); 00232 break; 00233 } 00234 00235 length -= Blocklen; 00236 } 00237 00238 return(*this); 00239 }
|
|
Writes the buffer to the file.
Implements CCFile. Definition at line 127 of file ccbhfile.cpp. 00128 { 00129 // Number of bytes we can translate in one go (half the buffer) 00130 UINT32 Blocklen = BinHexMaxLineLength / 2; 00131 UINT32 Index; 00132 char* pPtr; 00133 BYTE* pSrc = (BYTE*)buf; 00134 BOOL bCRLF = (length > Blocklen); 00135 00136 while (length > 0) 00137 { 00138 if (Blocklen > length) 00139 Blocklen = length; 00140 00141 if (bCRLF) 00142 { 00143 if (m_pFile->write("\r\n", 2).fail()) 00144 { 00145 GotError(_R(IDE_FILE_WRITE_ERROR)); 00146 break; 00147 } 00148 } 00149 00150 pPtr = (char*)m_Buffer; 00151 00152 for (Index = 0; Index < Blocklen; Index++) 00153 { 00154 ByteToHex(*pSrc, pPtr); 00155 pSrc += 1; 00156 pPtr += 2; 00157 } 00158 00159 if (m_pFile->write(m_Buffer, Blocklen * 2).fail()) 00160 { 00161 GotError(_R(IDE_FILE_WRITE_ERROR)); 00162 break; 00163 } 00164 00165 length -= Blocklen; 00166 } 00167 00168 return(*this); 00169 }
|
|
Definition at line 209 of file ccbhfile.h. |
|
Definition at line 207 of file ccbhfile.h. |