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

FXFileStream.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * F i l e S t r e a m C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. 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: FXFileStream.h,v 1.15 2006/01/22 17:58:01 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXFILESTREAM_H
25 #define FXFILESTREAM_H
26 
27 #ifndef FXSTREAM_H
28 #include "FXStream.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// File Store Definition
35 class FXAPI FXFileStream : public FXStream {
36 protected:
37  FXFile file;
38 protected:
39  virtual FXuval writeBuffer(FXuval count);
40  virtual FXuval readBuffer(FXuval count);
41 public:
42 
43  /// Create file store
44  FXFileStream(const FXObject* cont=NULL);
45 
46  /**
47  * Open binary data file stream; allocate a buffer of the given size
48  * for the file I/O; the buffer must be at least 16 bytes.
49  */
50  bool open(const FXString& filename,FXStreamDirection save_or_load,FXuval size=8192);
51 
52  /// Close file store
53  virtual bool close();
54 
55  /// Get position
56  FXlong position() const { return FXStream::position(); }
57 
58  /// Move to position
59  virtual bool position(FXlong offset,FXWhence whence=FXFromStart);
60 
61  /// Save single items to stream
62  FXFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
63  FXFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
64  FXFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
65  FXFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
66  FXFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
67  FXFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
68  FXFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
69  FXFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
70  FXFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
71  FXFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
72 
73  /// Save arrays of items to stream
74  FXFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
75  FXFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
76  FXFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
77  FXFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
78  FXFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
79  FXFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
80  FXFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
81  FXFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
82  FXFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
83  FXFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
84 
85  /// Load single items from stream
91  FXFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
92  FXFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
94  FXFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
95  FXFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
96 
97  /// Load arrays of items from stream
98  FXFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
99  FXFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
100  FXFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
101  FXFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
102  FXFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
103  FXFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
104  FXFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
105  FXFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
106  FXFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
107  FXFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
109  /// Save object
110  FXFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
111 
112  /// Load object
113  FXFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
114 
115  /// Destructor
116  virtual ~FXFileStream();
117  };
118 
119 }
120 
121 #endif
FXStream & operator>>(FXStream &store, FXDate &d)
unsigned short FXushort
Definition: fxdefs.h:394
FXFileStream & load(FXint *p, FXuval n)
Definition: FXFileStream.h:98
char FXchar
Definition: fxdefs.h:387
FXFileStream & load(FXlong *p, FXuval n)
Definition: FXFileStream.h:101
FXFileStream & load(FXfloat *p, FXuval n)
Definition: FXFileStream.h:99
short FXshort
Definition: fxdefs.h:395
FXFileStream & operator<<(const FXlong &v)
Definition: FXFileStream.h:65
FXFileStream & operator<<(const FXint &v)
Definition: FXFileStream.h:62
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
Seek from start position.
Definition: FXStream.h:66
FXStream & operator>>(FXuchar &v)
Load single items from stream.
FXFileStream & operator>>(FXlong &v)
Definition: FXFileStream.h:89
#define NULL
Definition: fxdefs.h:41
FXStream & saveObject(const FXObject *v)
Save object.
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
FXFileStream & operator>>(FXdouble &v)
Definition: FXFileStream.h:88
FXFileStream & operator<<(const FXulong &v)
Definition: FXFileStream.h:66
FXFileStream & operator<<(const FXfloat &v)
Definition: FXFileStream.h:63
FXFileStream & load(FXdouble *p, FXuval n)
Definition: FXFileStream.h:100
FXWhence
Stream seeking.
Definition: FXStream.h:65
double FXdouble
Definition: fxdefs.h:399
int FXint
Definition: fxdefs.h:397
FXFileStream & operator>>(FXfloat &v)
Definition: FXFileStream.h:87
FXFileStream & operator>>(FXint &v)
Definition: FXFileStream.h:86
FXFileStream & save(const FXint *p, FXuval n)
Definition: FXFileStream.h:74
FXFileStream & load(FXulong *p, FXuval n)
Definition: FXFileStream.h:102
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
File Store Definition.
Definition: FXFileStream.h:35
FXFileStream & save(const FXlong *p, FXuval n)
Definition: FXFileStream.h:77
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
FXFileStream & save(const FXulong *p, FXuval n)
Definition: FXFileStream.h:78
unsigned char FXuchar
Definition: fxdefs.h:392
FXFileStream & save(const FXdouble *p, FXuval n)
Definition: FXFileStream.h:76
FXFileStream & operator>>(FXulong &v)
Definition: FXFileStream.h:90
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)
Low level file access.
Definition: FXFile.h:38
FXFileStream & operator<<(const FXdouble &v)
Definition: FXFileStream.h:64
FXFileStream & save(const FXfloat *p, FXuval n)
Definition: FXFileStream.h:75
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp