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

FXBZFileStream.h
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,2023 by Lyle Johnson. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifdef HAVE_BZ2LIB_H
22 #ifndef FXBZFILESTREAM_H
23 #define FXBZFILESTREAM_H
24 
25 #ifndef FXFILESTREAM_H
26 #include "FXFileStream.h"
27 #endif
28 
29 
30 namespace FX {
31 
32 
33 struct BZBlock;
34 
35 
37 class FXAPI FXBZFileStream : public FXFileStream {
38 private:
39  BZBlock *bz;
40  int ac;
41 protected:
42  virtual FXuval writeBuffer(FXuval count);
43  virtual FXuval readBuffer(FXuval count);
44 private:
45  FXBZFileStream(const FXBZFileStream&);
46  FXBZFileStream& operator=(const FXBZFileStream&);
47 public:
48 
50  FXBZFileStream(const FXObject* cont=nullptr);
51 
53  FXBZFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
54 
56  FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
57 
59  virtual FXbool flush();
60 
62  virtual FXbool close();
63 
65  FXlong position() const { return FXStream::position(); }
66 
68  virtual FXbool position(FXlong,FXWhence){ return false; }
69 
71  FXBZFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
72  FXBZFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
73  FXBZFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; }
74  FXBZFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
75  FXBZFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
76  FXBZFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
77  FXBZFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
78  FXBZFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
79  FXBZFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
80  FXBZFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
81  FXBZFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
82 
84  FXBZFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
85  FXBZFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
86  FXBZFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXBZFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
88  FXBZFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
89  FXBZFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
90  FXBZFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
91  FXBZFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
92  FXBZFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
93  FXBZFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
94  FXBZFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
95 
97  FXBZFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
98  FXBZFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
99  FXBZFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; }
100  FXBZFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
101  FXBZFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
102  FXBZFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
103  FXBZFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
104  FXBZFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
105  FXBZFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
106  FXBZFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
107  FXBZFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
108 
110  FXBZFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
111  FXBZFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
112  FXBZFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; }
113  FXBZFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
114  FXBZFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
115  FXBZFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
116  FXBZFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
117  FXBZFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
118  FXBZFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
119  FXBZFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
120  FXBZFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
121 
123  FXBZFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
124 
126  FXBZFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
127 
129  template<class TYPE>
130  FXBZFileStream& operator>>(TYPE*& obj){ loadObject(reinterpret_cast<FXObject*&>(obj)); return *this; }
131 
133  template<class TYPE>
134  FXBZFileStream& operator<<(const TYPE* obj){ saveObject(static_cast<const FXObject*>(obj)); return *this; }
135 
137  virtual ~FXBZFileStream();
138  };
139 
140 
141 }
142 
143 #endif
144 #endif
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
FXStream & operator>>(FXuchar &v)
Load single items from stream.
FXStream & saveObject(const FXObject *v)
Save object.
Definition: FX4Splitter.h:28
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
FXStream & loadObject(FXObject *&v)
Load object.
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
FXlong position() const
Get position.
Definition: FXStream.h:164

Copyright © 1997-2022 Jeroen van der Zijp