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

FXGZFileStream.h

Go to the documentation of this file.
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,2006 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: FXGZFileStream.h,v 1.5 2006/01/22 17:58:04 fox Exp $                     *
00023 ********************************************************************************/
00024 #ifdef HAVE_ZLIB_H
00025 #ifndef FXGZFILESTREAM_H
00026 #define FXGZFILESTREAM_H
00027 
00028 #ifndef FXFILESTREAM_H
00029 #include "FXFileStream.h"
00030 #endif
00031 
00032 
00033 namespace FX {
00034 
00035 
00036 struct ZBlock;
00037 
00038 
00039 /// GZIP compressed stream
00040 class FXAPI FXGZFileStream : public FXFileStream {
00041 private:
00042   ZBlock *z;
00043   int     f;
00044 protected:
00045   virtual FXuval writeBuffer(FXuval count);
00046   virtual FXuval readBuffer(FXuval count);
00047 public:
00048 
00049   /// Create GZIP compressed file stream
00050   FXGZFileStream(const FXObject* cont=NULL);
00051 
00052   /// Open file stream
00053   bool open(const FXString& filename,FXStreamDirection save_or_load,FXuval size=8192);
00054 
00055   /// Close file stream
00056   virtual bool close();
00057 
00058   /// Get position
00059   FXlong position() const { return FXStream::position(); }
00060 
00061   /// Move to position
00062   virtual bool position(FXlong,FXWhence){ return FALSE; }
00063 
00064   /// Save single items to stream
00065   FXGZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
00066   FXGZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
00067   FXGZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
00068   FXGZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
00069   FXGZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
00070   FXGZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
00071   FXGZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
00072   FXGZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
00073   FXGZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
00074   FXGZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
00075 
00076   /// Save arrays of items to stream
00077   FXGZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
00078   FXGZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
00079   FXGZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
00080   FXGZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
00081   FXGZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
00082   FXGZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
00083   FXGZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
00084   FXGZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
00085   FXGZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
00086   FXGZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
00087 
00088   /// Load single items from stream
00089   FXGZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
00090   FXGZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
00091   FXGZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
00092   FXGZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
00093   FXGZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
00094   FXGZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
00095   FXGZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
00096   FXGZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
00097   FXGZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
00098   FXGZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
00099 
00100   /// Load arrays of items from stream
00101   FXGZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
00102   FXGZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
00103   FXGZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
00104   FXGZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
00105   FXGZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
00106   FXGZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
00107   FXGZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
00108   FXGZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
00109   FXGZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
00110   FXGZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
00111 
00112   /// Save object
00113   FXGZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
00114 
00115   /// Load object
00116   FXGZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
00117 
00118   /// Clean up
00119   virtual ~FXGZFileStream();
00120   };
00121 
00122 }
00123 
00124 
00125 #endif
00126 #endif

Copyright © 1997-2005 Jeroen van der Zijp