Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXGZStream.h

00001 /******************************************************************************** 00002 * * 00003 * G Z S t r e a m C l a s s e s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2002,2004 by Sander Jansen. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXGZStream.h,v 1.4 2004/02/08 17:17:33 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifdef HAVE_ZLIB_H 00025 #ifndef FXGZSTREAM_H 00026 #define FXGZSTREAM_H 00027 00028 #ifndef FXSTREAM_H 00029 #include "FXStream.h" 00030 #endif 00031 00032 00033 namespace FX { 00034 00035 00036 /// GZIP compressed stream 00037 class FXAPI FXGZFileStream : public FXStream { 00038 private: 00039 void *file; 00040 protected: 00041 virtual unsigned long writeBuffer(unsigned long count); 00042 virtual unsigned long readBuffer(unsigned long count); 00043 public: 00044 00045 /// Create GZIP compressed file stream 00046 FXGZFileStream(const FXObject* cont=NULL); 00047 00048 /// Open file stream 00049 FXbool open(const FXString& filename,FXStreamDirection save_or_load,unsigned long size=8192); 00050 00051 /// Close file stream 00052 virtual FXbool close(); 00053 00054 /// Move to position 00055 virtual FXbool position(long,FXWhence){ return FALSE; } 00056 00057 /// Save single items to stream 00058 FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } 00059 FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } 00060 FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } 00061 FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } 00062 FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } 00063 FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } 00064 FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } 00065 FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } 00066 #ifdef FX_LONG 00067 FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } 00068 FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } 00069 #endif 00070 00071 /// Save arrays of items to stream 00072 FXGZFileStream& save(const FXuchar* p,unsigned long n){ FXStream::save(p,n); return *this; } 00073 FXGZFileStream& save(const FXchar* p,unsigned long n){ FXStream::save(p,n); return *this; } 00074 FXGZFileStream& save(const FXushort* p,unsigned long n){ FXStream::save(p,n); return *this; } 00075 FXGZFileStream& save(const FXshort* p,unsigned long n){ FXStream::save(p,n); return *this; } 00076 FXGZFileStream& save(const FXuint* p,unsigned long n){ FXStream::save(p,n); return *this; } 00077 FXGZFileStream& save(const FXint* p,unsigned long n){ FXStream::save(p,n); return *this; } 00078 FXGZFileStream& save(const FXfloat* p,unsigned long n){ FXStream::save(p,n); return *this; } 00079 FXGZFileStream& save(const FXdouble* p,unsigned long n){ FXStream::save(p,n); return *this; } 00080 #ifdef FX_LONG 00081 FXGZFileStream& save(const FXlong* p,unsigned long n){ FXStream::save(p,n); return *this; } 00082 FXGZFileStream& save(const FXulong* p,unsigned long n){ FXStream::save(p,n); return *this; } 00083 #endif 00084 00085 /// Load single items from stream 00086 FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } 00087 FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } 00088 FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } 00089 FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } 00090 FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } 00091 FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } 00092 FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } 00093 FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } 00094 #ifdef FX_LONG 00095 FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } 00096 FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } 00097 #endif 00098 00099 /// Load arrays of items from stream 00100 FXGZFileStream& load(FXuchar* p,unsigned long n){ FXStream::load(p,n); return *this; } 00101 FXGZFileStream& load(FXchar* p,unsigned long n){ FXStream::load(p,n); return *this; } 00102 FXGZFileStream& load(FXushort* p,unsigned long n){ FXStream::load(p,n); return *this; } 00103 FXGZFileStream& load(FXshort* p,unsigned long n){ FXStream::load(p,n); return *this; } 00104 FXGZFileStream& load(FXuint* p,unsigned long n){ FXStream::load(p,n); return *this; } 00105 FXGZFileStream& load(FXint* p,unsigned long n){ FXStream::load(p,n); return *this; } 00106 FXGZFileStream& load(FXfloat* p,unsigned long n){ FXStream::load(p,n); return *this; } 00107 FXGZFileStream& load(FXdouble* p,unsigned long n){ FXStream::load(p,n); return *this; } 00108 #ifdef FX_LONG 00109 FXGZFileStream& load(FXlong* p,unsigned long n){ FXStream::load(p,n); return *this; } 00110 FXGZFileStream& load(FXulong* p,unsigned long n){ FXStream::load(p,n); return *this; } 00111 #endif 00112 00113 /// Save object 00114 FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } 00115 00116 /// Load object 00117 FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } 00118 00119 /// Clean up 00120 virtual ~FXGZFileStream(); 00121 }; 00122 00123 } 00124 00125 00126 #endif 00127 #endif

Copyright © 1997-2004 Jeroen van der Zijp