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

FXMemoryStream.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * M e m o r y S t r e a m C l a s s e 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: FXMemoryStream.h,v 1.11 2006/01/22 17:58:06 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXMEMORYSTREAM_H
25 #define FXMEMORYSTREAM_H
26 
27 #ifndef FXSTREAM_H
28 #include "FXStream.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Memory Store Definition
35 class FXAPI FXMemoryStream : public FXStream {
36 protected:
37  virtual FXuval writeBuffer(FXuval count);
38  virtual FXuval readBuffer(FXuval count);
39 public:
40 
41  /// Create memory store
42  FXMemoryStream(const FXObject* cont=NULL);
43 
44  /// Open file store
45  bool open(FXStreamDirection save_or_load,FXuchar* data);
46 
47  /// Open memory store
48  bool open(FXStreamDirection save_or_load,FXuval size,FXuchar* data);
49 
50  /// Take buffer away from stream
51  void takeBuffer(FXuchar*& data,FXuval& size);
52 
53  /// Give buffer to stream
54  void giveBuffer(FXuchar *data,FXuval size);
55 
56  /// Close memory store
57  virtual bool close();
58 
59  /// Get position
60  FXlong position() const { return FXStream::position(); }
61 
62  /// Move to position
63  virtual bool position(FXlong offset,FXWhence whence=FXFromStart);
64 
65  /// Save single items to stream
66  FXMemoryStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
67  FXMemoryStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
68  FXMemoryStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
69  FXMemoryStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
70  FXMemoryStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
71  FXMemoryStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
72  FXMemoryStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
73  FXMemoryStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
74  FXMemoryStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
75  FXMemoryStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
76 
77  /// Save arrays of items to stream
78  FXMemoryStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
79  FXMemoryStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
80  FXMemoryStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
81  FXMemoryStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
82  FXMemoryStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
83  FXMemoryStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
84  FXMemoryStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
85  FXMemoryStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
86  FXMemoryStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXMemoryStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
88 
89  /// Load single items from stream
97  FXMemoryStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
98  FXMemoryStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
99  FXMemoryStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
101  /// Load arrays of items from stream
102  FXMemoryStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
103  FXMemoryStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
104  FXMemoryStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
105  FXMemoryStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
106  FXMemoryStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
107  FXMemoryStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
108  FXMemoryStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
109  FXMemoryStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
110  FXMemoryStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
111  FXMemoryStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
112 
113  /// Save object
114  FXMemoryStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
115 
116  /// Load object
117  FXMemoryStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
118  };
119 
120 }
121 
122 #endif
FXMemoryStream & load(FXint *p, FXuval n)
Definition: FXMemoryStream.h:104
FXStream & operator>>(FXStream &store, FXDate &d)
FXMemoryStream & save(const FXshort *p, FXuval n)
Definition: FXMemoryStream.h:78
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
Memory Store Definition.
Definition: FXMemoryStream.h:35
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
unsigned int FXuint
Definition: fxdefs.h:396
FXMemoryStream & operator>>(FXshort &v)
Definition: FXMemoryStream.h:90
#define FXAPI
Definition: fxdefs.h:122
FXMemoryStream & load(FXdouble *p, FXuval n)
Definition: FXMemoryStream.h:106
Seek from start position.
Definition: FXStream.h:66
FXMemoryStream & save(const FXuint *p, FXuval n)
Definition: FXMemoryStream.h:79
FXStream & operator>>(FXuchar &v)
Load single items from stream.
FXMemoryStream & operator>>(FXulong &v)
Definition: FXMemoryStream.h:96
FXMemoryStream & operator<<(const FXint &v)
Definition: FXMemoryStream.h:68
FXMemoryStream & operator<<(const FXfloat &v)
Definition: FXMemoryStream.h:69
#define NULL
Definition: fxdefs.h:41
FXMemoryStream & operator<<(const FXdouble &v)
Definition: FXMemoryStream.h:70
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
FXMemoryStream & operator<<(const FXulong &v)
Definition: FXMemoryStream.h:72
FXWhence
Stream seeking.
Definition: FXStream.h:65
double FXdouble
Definition: fxdefs.h:399
FXMemoryStream & load(FXshort *p, FXuval n)
Definition: FXMemoryStream.h:102
FXMemoryStream & load(FXuint *p, FXuval n)
Definition: FXMemoryStream.h:103
FXMemoryStream & save(const FXfloat *p, FXuval n)
Definition: FXMemoryStream.h:81
int FXint
Definition: fxdefs.h:397
FXMemoryStream & save(const FXint *p, FXuval n)
Definition: FXMemoryStream.h:80
FXMemoryStream & operator>>(FXuint &v)
Definition: FXMemoryStream.h:91
FXMemoryStream & operator<<(const FXlong &v)
Definition: FXMemoryStream.h:71
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
FXMemoryStream & load(FXulong *p, FXuval n)
Definition: FXMemoryStream.h:108
FXMemoryStream & operator>>(FXint &v)
Definition: FXMemoryStream.h:92
FXMemoryStream & save(const FXulong *p, FXuval n)
Definition: FXMemoryStream.h:84
FXMemoryStream & operator>>(FXdouble &v)
Definition: FXMemoryStream.h:94
FXMemoryStream & save(const FXdouble *p, FXuval n)
Definition: FXMemoryStream.h:82
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
FXMemoryStream & load(FXlong *p, FXuval n)
Definition: FXMemoryStream.h:107
unsigned char FXuchar
Definition: fxdefs.h:392
float FXfloat
Definition: fxdefs.h:398
FXStreamDirection
Stream data flow direction.
Definition: FXStream.h:35
FXMemoryStream & operator<<(const FXshort &v)
Definition: FXMemoryStream.h:66
FXStream & loadObject(FXObject *&v)
Load object.
FXMemoryStream & save(const FXlong *p, FXuval n)
Definition: FXMemoryStream.h:83
FXMemoryStream & operator<<(const FXuint &v)
Definition: FXMemoryStream.h:67
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
FXMemoryStream & operator>>(FXfloat &v)
Definition: FXMemoryStream.h:93
FXMemoryStream & operator>>(FXlong &v)
Definition: FXMemoryStream.h:95
unsigned long FXuval
Definition: fxdefs.h:436
FXStream & operator<<(FXStream &store, const FXDate &d)
FXMemoryStream & load(FXfloat *p, FXuval n)
Definition: FXMemoryStream.h:105

Copyright © 1997-2005 Jeroen van der Zijp