00001 #if !defined(_FILEBUFFER_HPP) 00002 #define _FILEBUFFER_HPP 00003 //============================================================================= 00004 // 00005 // XDFLengine library 00006 // 00007 //----------------------------------------------------------------------------- 00008 // FILEBUFFER.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 00045 BEGIN_XDFLENGINE_NS 00046 00047 static const char* gs_pszFileBufferTmpDir; 00048 00049 //============================================================================= 00050 // CLASS FILEBUFFER 00051 //----------------------------------------------------------------------------- 00053 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00054 class XDFLENGINE_EXPORT FileBuffer: public XMLStreamBuffer 00055 { 00056 00057 private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00058 FILE* m_pOut; 00059 char m_cFN[FILEBUFFER_MAXNAMESIZE]; 00060 char m_cMode[5]; 00061 bool m_bOwnFile; 00062 bool m_bOpened; 00063 int m_intSize; 00064 bool m_boolReadOnly; 00065 unsigned int m_uiBufferSize; 00066 unsigned int m_commitwritten; 00067 00068 public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00069 00070 //_____________________________________________________________________ 00071 // Settmpdir 00072 //--------------------------------------------------------------------- 00075 //_____________________________________________________________________ 00076 static void setTmpDir( const char* p_pszTmpDir) ; 00077 00078 // CONSTRUCTOR AND DESTRUCTOR 00079 00080 //_____________________________________________________________________ 00081 // FILEBUFFER 00082 //--------------------------------------------------------------------- 00088 //_____________________________________________________________________ 00089 FileBuffer ( const char* p_cFileName=0, bool p_boolReadOnly = false, unsigned int p_uiBufferSize=0); 00090 00091 //_____________________________________________________________________ 00092 // ~FILEBUFFER 00093 //--------------------------------------------------------------------- 00096 //_____________________________________________________________________ 00097 ~FileBuffer (); 00098 00099 // XMLSTREAMPROVIDER 00100 00101 //_____________________________________________________________________ 00102 // OPERATOR >> 00103 //--------------------------------------------------------------------- 00104 XMLStreamProvider & operator>> ( XMLStreamConsumer& p_pStreamConsumer); 00105 00106 // XMLSTREAMCONSUMER 00107 00108 //_____________________________________________________________________ 00109 // WRITEDATA 00110 //--------------------------------------------------------------------- 00111 //_____________________________________________________________________ 00112 void writeData( const char* p_pszData, unsigned int p_uiDataLen); 00113 00114 //_____________________________________________________________________ 00115 // COMMITSTREAM 00116 //--------------------------------------------------------------------- 00117 //_____________________________________________________________________ 00118 bool commitStream(bool fFinal = false); 00119 00120 // FILEBUFFER 00121 00122 //_____________________________________________________________________ 00123 // FLUSH 00124 //--------------------------------------------------------------------- 00127 //_____________________________________________________________________ 00128 void flush (); 00129 00130 private: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00131 00132 //_____________________________________________________________________ 00133 // OPENFILE 00134 //--------------------------------------------------------------------- 00137 //_____________________________________________________________________ 00138 void openfile(); 00139 00140 //_____________________________________________________________________ 00141 // CLOSEFILE 00142 //--------------------------------------------------------------------- 00145 //_____________________________________________________________________ 00146 void closefile(); 00147 00148 //_____________________________________________________________________ 00149 // SETMODE 00150 //--------------------------------------------------------------------- 00153 //_____________________________________________________________________ 00154 void setMode ( const char* p_cMode); 00155 00156 //_____________________________________________________________________ 00157 // DELFILE 00158 //--------------------------------------------------------------------- 00160 //_____________________________________________________________________ 00161 void delFile(); 00162 00163 }; 00164 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00165 //============================================================================= 00166 00167 END_XDFLENGINE_NS 00168 00169 #endif