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

FXFileStream.h
1 /********************************************************************************
2 * *
3 * F i l e S t r e a m C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2024 by Jeroen van der Zijp. 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 #ifndef FXFILESTREAM_H
22 #define FXFILESTREAM_H
23 
24 #ifndef FXSTREAM_H
25 #include "FXStream.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 class FXAPI FXFileStream : public FXStream {
33 protected:
34  FXFile file;
35 protected:
36  virtual FXuval writeBuffer(FXuval count);
37  virtual FXuval readBuffer(FXuval count);
38 private:
39  FXFileStream(const FXFileStream&);
40  FXFileStream& operator=(const FXFileStream&);
41 public:
42 
44  FXFileStream(const FXObject* cont=nullptr);
45 
47  FXFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
48 
53  FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
54 
56  virtual FXbool close();
57 
59  FXlong position() const { return FXStream::position(); }
60 
62  virtual FXbool position(FXlong offset,FXWhence whence=FXFromStart);
63 
65  FXFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
66  FXFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
67  FXFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; }
68  FXFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
69  FXFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
70  FXFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
71  FXFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
72  FXFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
73  FXFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
74  FXFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
75  FXFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
76 
78  FXFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
79  FXFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
80  FXFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; }
81  FXFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
82  FXFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
83  FXFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
84  FXFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
85  FXFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
86  FXFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
88  FXFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
89 
91  FXFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
92  FXFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
93  FXFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; }
94  FXFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
95  FXFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
96  FXFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
97  FXFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
98  FXFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
99  FXFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
100  FXFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
101  FXFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
102 
104  FXFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
105  FXFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
106  FXFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; }
107  FXFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
108  FXFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
109  FXFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
110  FXFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
111  FXFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
112  FXFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
113  FXFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
114  FXFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
115 
117  FXFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
118 
121 
123  template<class TYPE>
124  FXFileStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast<FXObject*&>(obj)); }
125 
127  template<class TYPE>
128  FXFileStream& operator<<(const TYPE* obj){ return saveObject(static_cast<const FXObject*>(obj)); }
129 
131  virtual ~FXFileStream();
132  };
133 
134 }
135 
136 #endif
FXFileStream & operator>>(TYPE *&obj)
Load object.
Definition: FXFileStream.h:124
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
FXFileStream & operator<<(const TYPE *obj)
Save object.
Definition: FXFileStream.h:128
FXStream & operator>>(FXuchar &v)
Load single items from stream.
FXStream & saveObject(const FXObject *v)
Save object.
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXlong position() const
Get position.
Definition: FXFileStream.h:59
FXFileStream & operator>>(FXuchar &v)
Load single items from stream.
Definition: FXFileStream.h:91
Definition: FX4Splitter.h:28
FXFileStream & saveObject(const FXObject *v)
Save object.
Definition: FXFileStream.h:117
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
File Store Definition.
Definition: FXFileStream.h:32
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
FXStream & loadObject(FXObject *&v)
Load object.
FXFileStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
Definition: FXFileStream.h:104
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
Low level file access.
Definition: FXFile.h:34
FXlong position() const
Get position.
Definition: FXStream.h:164
FXFileStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
Definition: FXFileStream.h:78
FXFileStream & loadObject(FXObject *&v)
Load object.
Definition: FXFileStream.h:120
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42
FXFileStream & operator<<(const FXuchar &v)
Save single items to stream.
Definition: FXFileStream.h:65

Copyright © 1997-2022 Jeroen van der Zijp