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

FXMemoryStream.h
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,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 FXMEMORYSTREAM_H
22 #define FXMEMORYSTREAM_H
23 
24 #ifndef FXSTREAM_H
25 #include "FXStream.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 class FXAPI FXMemoryStream : public FXStream {
33 protected:
34  virtual FXuval writeBuffer(FXuval count);
35  virtual FXuval readBuffer(FXuval count);
36 private:
38  FXMemoryStream &operator=(const FXMemoryStream&);
39 public:
40 
42  FXMemoryStream(const FXObject* cont=nullptr);
43 
45  FXMemoryStream(FXStreamDirection save_or_load,FXuchar* data=nullptr,FXuval size=~0UL,FXbool owned=false);
46 
58  FXbool open(FXStreamDirection save_or_load,FXuchar* data=nullptr,FXuval size=~0UL,FXbool owned=false);
59 
61  void takeBuffer(FXuchar*& data,FXuval& size);
62 
64  void giveBuffer(FXuchar *data,FXuval size);
65 
67  FXlong position() const { return FXStream::position(); }
68 
70  virtual FXbool position(FXlong offset,FXWhence whence=FXFromStart);
71 
73  FXMemoryStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
74  FXMemoryStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
75  FXMemoryStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; }
76  FXMemoryStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
77  FXMemoryStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
78  FXMemoryStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
79  FXMemoryStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
80  FXMemoryStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
81  FXMemoryStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
82  FXMemoryStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
83  FXMemoryStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
84 
86  FXMemoryStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
87  FXMemoryStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
88  FXMemoryStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; }
89  FXMemoryStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
90  FXMemoryStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
91  FXMemoryStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
92  FXMemoryStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
93  FXMemoryStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
94  FXMemoryStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
95  FXMemoryStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
96  FXMemoryStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
97 
99  FXMemoryStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
100  FXMemoryStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
101  FXMemoryStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; }
102  FXMemoryStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
103  FXMemoryStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
104  FXMemoryStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
105  FXMemoryStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
106  FXMemoryStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
107  FXMemoryStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
108  FXMemoryStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
109  FXMemoryStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
110 
112  FXMemoryStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
113  FXMemoryStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
114  FXMemoryStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; }
115  FXMemoryStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
116  FXMemoryStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
117  FXMemoryStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
118  FXMemoryStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
119  FXMemoryStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
120  FXMemoryStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
121  FXMemoryStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
122  FXMemoryStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
123 
125  FXMemoryStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
126 
129 
131  template<class TYPE>
132  FXMemoryStream& operator>>(TYPE*& obj){ return loadObject(reinterpret_cast<FXObject*&>(obj)); }
133 
135  template<class TYPE>
136  FXMemoryStream& operator<<(const TYPE* obj){ return saveObject(static_cast<const FXObject*>(obj)); }
137 
139  virtual ~FXMemoryStream();
140  };
141 
142 }
143 
144 #endif
FXMemoryStream & operator<<(const FXuchar &v)
Save single items to stream.
Definition: FXMemoryStream.h:73
FXMemoryStream & operator>>(TYPE *&obj)
Load object.
Definition: FXMemoryStream.h:132
FXMemoryStream & loadObject(FXObject *&v)
Load object.
Definition: FXMemoryStream.h:128
Memory Store Definition.
Definition: FXMemoryStream.h:32
FXStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
FXMemoryStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
Definition: FXMemoryStream.h:112
FXMemoryStream & operator>>(FXuchar &v)
Load single items from stream.
Definition: FXMemoryStream.h:99
FXMemoryStream & save(const FXuchar *p, FXuval n)
Save arrays of items to stream.
Definition: FXMemoryStream.h:86
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: FXMemoryStream.h:67
Definition: FX4Splitter.h:28
FXMemoryStream & operator<<(const TYPE *obj)
Save object.
Definition: FXMemoryStream.h:136
FXStream & operator<<(const FXuchar &v)
Save single items to stream.
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.
FXStream & load(FXuchar *p, FXuval n)
Load arrays of items from stream.
FXMemoryStream & saveObject(const FXObject *v)
Save object.
Definition: FXMemoryStream.h:125
FXlong position() const
Get position.
Definition: FXStream.h:164

Copyright © 1997-2022 Jeroen van der Zijp