![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * G Z F i l e S t r e a m C l a s s e s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2002,2009 by Sander Jansen. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (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 * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXGZFileStream.h,v 1.15 2009/01/06 13:07:24 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifdef HAVE_ZLIB_H 00024 #ifndef FXGZFILESTREAM_H 00025 #define FXGZFILESTREAM_H 00026 00027 #ifndef FXFILESTREAM_H 00028 #include "FXFileStream.h" 00029 #endif 00030 00031 00032 namespace FX { 00033 00034 00035 struct ZBlock; 00036 00037 00038 /// GZIP compressed stream 00039 class FXAPI FXGZFileStream : public FXFileStream { 00040 private: 00041 ZBlock *gz; 00042 int ac; 00043 protected: 00044 virtual FXuval writeBuffer(FXuval count); 00045 virtual FXuval readBuffer(FXuval count); 00046 public: 00047 00048 /// Create GZIP compressed file stream 00049 FXGZFileStream(const FXObject* cont=NULL); 00050 00051 /// Create and open GZIP compressed file stream 00052 FXGZFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); 00053 00054 /// Open file stream 00055 FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL); 00056 00057 /// Flush buffer 00058 virtual FXbool flush(); 00059 00060 /// Close file stream 00061 virtual FXbool close(); 00062 00063 /// Get position 00064 FXlong position() const { return FXStream::position(); } 00065 00066 /// Move to position 00067 virtual FXbool position(FXlong,FXWhence){ return false; } 00068 00069 /// Save single items to stream 00070 FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } 00071 FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } 00072 FXGZFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; } 00073 FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } 00074 FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } 00075 FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } 00076 FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } 00077 FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } 00078 FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } 00079 FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } 00080 FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } 00081 00082 /// Save arrays of items to stream 00083 FXGZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; } 00084 FXGZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; } 00085 FXGZFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; } 00086 FXGZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; } 00087 FXGZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; } 00088 FXGZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; } 00089 FXGZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; } 00090 FXGZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; } 00091 FXGZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; } 00092 FXGZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; } 00093 FXGZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; } 00094 00095 /// Load single items from stream 00096 FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } 00097 FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } 00098 FXGZFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; } 00099 FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } 00100 FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } 00101 FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } 00102 FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } 00103 FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } 00104 FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } 00105 FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } 00106 FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } 00107 00108 /// Load arrays of items from stream 00109 FXGZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; } 00110 FXGZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; } 00111 FXGZFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; } 00112 FXGZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; } 00113 FXGZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; } 00114 FXGZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; } 00115 FXGZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; } 00116 FXGZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; } 00117 FXGZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; } 00118 FXGZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; } 00119 FXGZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; } 00120 00121 /// Save object 00122 FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } 00123 00124 /// Load object 00125 FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } 00126 00127 /// Clean up 00128 virtual ~FXGZFileStream(); 00129 }; 00130 00131 } 00132 00133 00134 #endif 00135 #endif
![]() |