00001 #if !defined(_ZIPBUFFER_HPP) 00002 #define _ZIPBUFFER_HPP 00003 //============================================================================= 00004 // 00005 // XDFLengine library 00006 // 00007 //----------------------------------------------------------------------------- 00008 // ZIPBUFFER.HPP 00009 //----------------------------------------------------------------------------- 00015 //_____________________________________________________________________________ 00016 // 00017 // Copyright (C) 2003 Guillaume Baurand. All Rights Reserved. 00018 // 00019 // This file is part of the XDFLengine project. 00020 // 00021 // The XDFLengine is free software; you can redistribute it and/or modify 00022 // it under the terms of the GNU General Public License as published by 00023 // the Free Software Foundation; either version 2 of the License, or 00024 // (at your option) any later version. 00025 // 00026 // This program is distributed in the hope that it will be useful, 00027 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00028 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00029 // GNU General Public License for more details. 00030 // 00031 // You should have received a copy of the GNU General Public License 00032 // along with this program; if not, write to the Free Software 00033 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00034 // USA. 00035 // 00036 // For more information, 00037 // contact : guillaume@baurand.net 00038 // or visit : http://xdflengine.sourceforge.net 00039 // 00040 //============================================================================= 00041 00042 # include "config/commonincs.hpp" 00043 # include "flow/xmlstreambuffer.hpp" 00044 extern "C"{ 00045 # include "zlib/zlib.h" // Zlib 00046 } 00047 00048 BEGIN_XDFLENGINE_NS 00049 00050 static const char* gs_pszZipBufferTmpDir; 00051 00052 //============================================================================= 00053 // CLASS ZIPBUFFER 00054 //----------------------------------------------------------------------------- 00056 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00057 class XDFLENGINE_EXPORT ZipBuffer: public XMLStreamBuffer 00058 { 00059 00060 00061 private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00062 00063 00064 gzFile m_pOut; 00065 char m_cFN[FILEBUFFER_MAXNAMESIZE]; 00066 char m_cMode[5]; 00067 bool m_bOwnFile; 00068 bool m_bOpened; 00069 unsigned int m_commitwritten; 00070 bool m_boolReadOnly; 00071 unsigned int m_uiBufferSize; 00072 00073 public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00074 00075 // STATIC 00076 00077 //_____________________________________________________________________ 00078 // Settmpdir 00079 //--------------------------------------------------------------------- 00082 //_____________________________________________________________________ 00083 static void setTmpDir( const char* p_pszTmpDir); 00084 00085 // CONSTRUCTOR AND DESTRUCTOR 00086 00087 //_____________________________________________________________________ 00088 // ZIPBUFFER 00089 //--------------------------------------------------------------------- 00094 //_____________________________________________________________________ 00095 ZipBuffer ( const char* p_cFileName=0, bool p_boolReadOnly = false, unsigned int p_uiBufferSize=0); 00096 00097 //_____________________________________________________________________ 00098 // ~ZIPBUFFER 00099 //--------------------------------------------------------------------- 00102 //_____________________________________________________________________ 00103 ~ZipBuffer (); 00104 00105 // STREAM OPERATORS 00106 00107 //_____________________________________________________________________ 00108 // OPERATOR >> 00109 //--------------------------------------------------------------------- 00115 //_____________________________________________________________________ 00116 XMLStreamProvider & operator>> ( XMLStreamConsumer& p_pStreamConsumer); 00117 00118 // DATA 00119 00120 //_____________________________________________________________________ 00121 // WRITE 00122 //--------------------------------------------------------------------- 00127 //_____________________________________________________________________ 00128 void writeData( const char* p_pszData, unsigned int p_uiDataLen); 00129 00130 //_____________________________________________________________________ 00131 // COMMITSTREAM 00132 //--------------------------------------------------------------------- 00133 //_____________________________________________________________________ 00134 bool commitStream(bool fFinal); 00135 00136 //_____________________________________________________________________ 00137 // FLUSH 00138 //--------------------------------------------------------------------- 00141 //_____________________________________________________________________ 00142 void flush (); 00143 00144 00145 00146 00147 00148 private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00149 00150 //_____________________________________________________________________ 00151 // OPENFILE 00152 //--------------------------------------------------------------------- 00155 //_____________________________________________________________________ 00156 void openfile(); 00157 00158 //_____________________________________________________________________ 00159 // CLOSEFILE 00160 //--------------------------------------------------------------------- 00163 //_____________________________________________________________________ 00164 void closefile(); 00165 00166 //_____________________________________________________________________ 00167 // SETMODE 00168 //--------------------------------------------------------------------- 00171 //_____________________________________________________________________ 00172 void setMode ( const char* p_cMode); 00173 00174 //_____________________________________________________________________ 00175 // DELFILE 00176 //--------------------------------------------------------------------- 00178 //_____________________________________________________________________ 00179 void delFile(); 00180 }; 00181 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00182 //============================================================================= 00183 00184 END_XDFLENGINE_NS 00185 00186 #endif 00187