BINFilter.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Crosswalk team
00004 //
00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.  
00006 // Use of this software is subject to the terms of the Autodesk license agreement 
00007 // provided at the time of installation or download, or which otherwise accompanies 
00008 // this software in either electronic or hard copy form.
00009 //
00010 //***************************************************************************************
00011 
00012 #ifndef _BINFILTER_H_
00013 #define _BINFILTER_H_
00014 
00015 #include <SIBCUtil.h>
00016 #include <SIBCString.h>
00017 
00018 #include "CXSIFilter.h"
00019 
00020 #define BIN_FILTER_NAME "Binary"
00021 #define BIN_FILTER_ID       "bin"
00022 #define GROW_BUFFER_MULTIPLIER      0.1f
00023 #define GROW_BUFFER_BYTE_AMOUNT     14
00024 
00026 /*
00027  * This supports 3.0 compression (entire file at once) and 3.5 and up where we compress
00028  * one chunk at a time therefore reducing the overall memory usage
00029  */
00030 class CBINFilter : public CXSIFilter
00031 {
00032 public:
00037     CBINFilter( bool in_bLegacy );
00041     virtual ~CBINFilter();
00042 
00047     int Open ( CSIBCString in_szFilename,  _SI_FILE_MODE in_Mode );
00050     int Close ();
00051     
00057     int Read ( SI_Char * out_pBuffer, SI_Long in_lSize );
00063     int Write( SI_Char * in_pBuffer,  SI_Long in_lSize );
00064 
00065 
00069     int Eof();
00073     int Tell();
00074 
00075 
00076 private:
00077     void ReadBlock();
00078 
00079     void AdjustBuffer( SI_Long in_lSize );
00080 
00081     SI_UByte    * m_pBytes;
00082     SI_UByte    * m_pCompressedBuffer;
00083     SI_Long     m_lCompressedBufferSize;
00084     SI_Long     m_lPosition, m_lSize;
00085     bool        m_bLegacy;
00086     bool        m_bEof;
00087 };
00088 
00089 #endif