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

FXBZFileStream.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * B Z F i l e S t r e a m C l a s s e s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2006 by Lyle Johnson. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXBZFileStream.h,v 1.5.2.1 2007/09/28 16:42:19 fox Exp $ *
23 ********************************************************************************/
24 #ifdef HAVE_BZ2LIB_H
25 #ifndef FXBZFILESTREAM_H
26 #define FXBZFILESTREAM_H
27 
28 #ifndef FXFILESTREAM_H
29 #include "FXFileStream.h"
30 #endif
31 
32 
33 namespace FX {
34 
35 
36 struct BZBlock;
37 
38 
39 /// BZIP2 compressed file stream
40 class FXAPI FXBZFileStream : public FXFileStream {
41 private:
42  BZBlock *bz;
43  int ac;
44 protected:
45  virtual FXuval writeBuffer(FXuval count);
46  virtual FXuval readBuffer(FXuval count);
47 public:
48 
49  /// Create BZIP2 file stream
50  FXBZFileStream(const FXObject* cont=NULL);
51 
52  /// Open file stream
53  bool open(const FXString& filename,FXStreamDirection save_or_load,FXuval size=8192);
54 
55  /// Flush buffer
56  virtual bool flush();
57 
58  /// Close file stream
59  virtual bool close();
60 
61  /// Get position
62  FXlong position() const { return FXStream::position(); }
63 
64  /// Move to position
65  virtual bool position(FXlong,FXWhence){ return FALSE; }
66 
67  /// Save single items to stream
68  FXBZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
69  FXBZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
70  FXBZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
71  FXBZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
72  FXBZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
73  FXBZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
74  FXBZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
75  FXBZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
76  FXBZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
77  FXBZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
78 
79  /// Save arrays of items to stream
80  FXBZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
81  FXBZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
82  FXBZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
83  FXBZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
84  FXBZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
85  FXBZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
86  FXBZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXBZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
88  FXBZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
89  FXBZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
90 
91  /// Load single items from stream
92  FXBZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
93  FXBZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
94  FXBZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
95  FXBZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
96  FXBZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
97  FXBZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
98  FXBZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
99  FXBZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
100  FXBZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
101  FXBZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
102 
103  /// Load arrays of items from stream
104  FXBZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
105  FXBZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
106  FXBZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
107  FXBZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
108  FXBZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
109  FXBZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
110  FXBZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
111  FXBZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
112  FXBZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
113  FXBZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
114 
115  /// Save object
116  FXBZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
117 
118  /// Load object
119  FXBZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
120 
121  /// Clean up
122  virtual ~FXBZFileStream();
123  };
124 
125 
126 }
127 
128 #endif
129 #endif
FXStream & operator>>(FXStream &store, FXDate &d)
unsigned short FXushort
Definition: fxdefs.h:394
char FXchar
Definition: fxdefs.h:387
short FXshort
Definition: fxdefs.h:395
FXlong position() const
Get position.
Definition: FXStream.h:146
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
unsigned int FXuint
Definition: fxdefs.h:396
#define FXAPI
Definition: fxdefs.h:122
FXStream & operator>>(FXuchar &v)
Load single items from stream.
#define NULL
Definition: fxdefs.h:41
FXStream & saveObject(const FXObject *v)
Save object.
FXWhence
Stream seeking.
Definition: FXStream.h:65
double FXdouble
Definition: fxdefs.h:399
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
#define FALSE
Definition: fxdefs.h:35
unsigned char FXuchar
Definition: fxdefs.h:392
float FXfloat
Definition: fxdefs.h:398
FXStreamDirection
Stream data flow direction.
Definition: FXStream.h:35
FXStream & loadObject(FXObject *&v)
Load object.
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
unsigned long FXuval
Definition: fxdefs.h:436
FXStream & operator<<(FXStream &store, const FXDate &d)

Copyright © 1997-2005 Jeroen van der Zijp