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,2005 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.9 2005/01/16 16:06:06 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 /// Get position 00055 FXlong position() const { return FXStream::position(); } 00056 00057 /// Move to position 00058 virtual FXbool position(FXlong,FXWhence){ return FALSE; } 00059 00060 /// Save single items to stream 00061 FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } 00062 FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } 00063 FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } 00064 FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } 00065 FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } 00066 FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } 00067 FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } 00068 FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } 00069 FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } 00070 FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } 00071 00072 /// Save arrays of items to stream 00073 FXGZFileStream& save(const FXuchar* p,unsigned long n){ FXStream::save(p,n); return *this; } 00074 FXGZFileStream& save(const FXchar* p,unsigned long n){ FXStream::save(p,n); return *this; } 00075 FXGZFileStream& save(const FXushort* p,unsigned long n){ FXStream::save(p,n); return *this; } 00076 FXGZFileStream& save(const FXshort* p,unsigned long n){ FXStream::save(p,n); return *this; } 00077 FXGZFileStream& save(const FXuint* p,unsigned long n){ FXStream::save(p,n); return *this; } 00078 FXGZFileStream& save(const FXint* p,unsigned long n){ FXStream::save(p,n); return *this; } 00079 FXGZFileStream& save(const FXfloat* p,unsigned long n){ FXStream::save(p,n); return *this; } 00080 FXGZFileStream& save(const FXdouble* p,unsigned long n){ FXStream::save(p,n); return *this; } 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 00084 /// Load single items from stream 00085 FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } 00086 FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } 00087 FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } 00088 FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } 00089 FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } 00090 FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } 00091 FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } 00092 FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } 00093 FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } 00094 FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } 00095 00096 /// Load arrays of items from stream 00097 FXGZFileStream& load(FXuchar* p,unsigned long n){ FXStream::load(p,n); return *this; } 00098 FXGZFileStream& load(FXchar* p,unsigned long n){ FXStream::load(p,n); return *this; } 00099 FXGZFileStream& load(FXushort* p,unsigned long n){ FXStream::load(p,n); return *this; } 00100 FXGZFileStream& load(FXshort* p,unsigned long n){ FXStream::load(p,n); return *this; } 00101 FXGZFileStream& load(FXuint* p,unsigned long n){ FXStream::load(p,n); return *this; } 00102 FXGZFileStream& load(FXint* p,unsigned long n){ FXStream::load(p,n); return *this; } 00103 FXGZFileStream& load(FXfloat* p,unsigned long n){ FXStream::load(p,n); return *this; } 00104 FXGZFileStream& load(FXdouble* p,unsigned long n){ FXStream::load(p,n); return *this; } 00105 FXGZFileStream& load(FXlong* p,unsigned long n){ FXStream::load(p,n); return *this; } 00106 FXGZFileStream& load(FXulong* p,unsigned long n){ FXStream::load(p,n); return *this; } 00107 00108 /// Save object 00109 FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } 00110 00111 /// Load object 00112 FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } 00113 00114 /// Clean up 00115 virtual ~FXGZFileStream(); 00116 }; 00117 00118 } 00119 00120 00121 #endif 00122 #endif

Copyright © 1997-2005 Jeroen van der Zijp