Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/emulator/xnes/snes9x/jma/iiostrm.h
28798 views
1
/*
2
Copyright (C) 2005-2006 NSRT Team ( http://nsrt.edgeemu.com )
3
Copyright (C) 2002 Andrea Mazzoleni ( http://advancemame.sf.net )
4
Copyright (C) 2001-4 Igor Pavlov ( http://www.7-zip.org )
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License version 2.1 as published by the Free Software Foundation.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*/
19
20
#ifndef __IINOUTSTREAMS_H
21
#define __IINOUTSTREAMS_H
22
23
#include <string>
24
#include <fstream>
25
26
#include "portable.h"
27
28
29
class ISequentialInStream
30
{
31
public:
32
virtual HRESULT Read(void *, UINT32, UINT32 *) = 0;
33
34
virtual ~ISequentialInStream() {}
35
};
36
37
38
class ISequentialInStream_Array : public ISequentialInStream
39
{
40
const char *data;
41
unsigned int size;
42
public:
43
ISequentialInStream_Array(const char *Adata, unsigned Asize) : data(Adata), size(Asize) { }
44
45
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
46
47
virtual ~ISequentialInStream_Array() {}
48
};
49
50
class ISequentialInStream_String : public ISequentialInStream
51
{
52
std::string& data;
53
public:
54
ISequentialInStream_String(std::string& Adata) : data(Adata) { }
55
56
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
57
58
virtual ~ISequentialInStream_String() {}
59
};
60
61
class ISequentialInStream_Istream : public ISequentialInStream
62
{
63
std::istream& data;
64
public:
65
ISequentialInStream_Istream(std::istream& Adata) : data(Adata) { }
66
67
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
68
69
virtual ~ISequentialInStream_Istream() {}
70
};
71
72
73
74
class ISequentialOutStream
75
{
76
public:
77
virtual bool overflow_get() const = 0;
78
virtual unsigned int size_get() const = 0;
79
80
virtual HRESULT Write(const void *, UINT32, UINT32 *) = 0;
81
82
virtual ~ISequentialOutStream() {}
83
};
84
85
86
class ISequentialOutStream_Array : public ISequentialOutStream
87
{
88
char *data;
89
unsigned int size;
90
bool overflow;
91
unsigned int total;
92
public:
93
ISequentialOutStream_Array(char *Adata, unsigned Asize) : data(Adata), size(Asize), overflow(false), total(0) { }
94
95
bool overflow_get() const { return(overflow); }
96
unsigned int size_get() const { return(total); }
97
98
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
99
100
virtual ~ISequentialOutStream_Array() {}
101
};
102
103
class ISequentialOutStream_String : public ISequentialOutStream
104
{
105
std::string& data;
106
unsigned int total;
107
public:
108
ISequentialOutStream_String(std::string& Adata) : data(Adata), total(0) { }
109
110
bool overflow_get() const { return(false); }
111
unsigned int size_get() const { return(total); }
112
113
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
114
115
virtual ~ISequentialOutStream_String() {}
116
};
117
118
119
class ISequentialOutStream_Ostream : public ISequentialOutStream
120
{
121
std::ostream& data;
122
unsigned int total;
123
public:
124
ISequentialOutStream_Ostream(std::ostream& Adata) : data(Adata), total(0) { }
125
126
bool overflow_get() const { return(false); }
127
unsigned int size_get() const { return(total); }
128
129
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
130
131
virtual ~ISequentialOutStream_Ostream() {}
132
};
133
134
135
136
class ISequentialStreamCRC32
137
{
138
protected:
139
unsigned int crc32;
140
public:
141
ISequentialStreamCRC32() : crc32(0) {}
142
unsigned int crc32_get() const { return(crc32); }
143
144
virtual ~ISequentialStreamCRC32() {}
145
};
146
147
148
class ISequentialInStreamCRC32_Array : public ISequentialInStream_Array, public ISequentialStreamCRC32
149
{
150
public:
151
ISequentialInStreamCRC32_Array(const char *Adata, unsigned Asize) : ISequentialInStream_Array(Adata, Asize) { }
152
153
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
154
155
virtual ~ISequentialInStreamCRC32_Array() {}
156
};
157
158
class ISequentialInStreamCRC32_String : public ISequentialInStream_String, public ISequentialStreamCRC32
159
{
160
public:
161
ISequentialInStreamCRC32_String(std::string& Adata) : ISequentialInStream_String(Adata) { }
162
163
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
164
165
virtual ~ISequentialInStreamCRC32_String() {}
166
};
167
168
class ISequentialInStreamCRC32_Istream : public ISequentialInStream_Istream, public ISequentialStreamCRC32
169
{
170
public:
171
ISequentialInStreamCRC32_Istream(std::istream& Adata) : ISequentialInStream_Istream(Adata) { }
172
173
HRESULT Read(void *aData, UINT32 aSize, UINT32 *aProcessedSize);
174
175
virtual ~ISequentialInStreamCRC32_Istream() {}
176
};
177
178
179
class ISequentialOutStreamCRC32_Array : public ISequentialOutStream_Array, public ISequentialStreamCRC32
180
{
181
public:
182
ISequentialOutStreamCRC32_Array(char *Adata, unsigned Asize) : ISequentialOutStream_Array(Adata, Asize) { }
183
184
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
185
186
virtual ~ISequentialOutStreamCRC32_Array() {}
187
};
188
189
class ISequentialOutStreamCRC32_String : public ISequentialOutStream_String, public ISequentialStreamCRC32
190
{
191
public:
192
ISequentialOutStreamCRC32_String(std::string& Adata) : ISequentialOutStream_String(Adata) { }
193
194
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
195
196
virtual ~ISequentialOutStreamCRC32_String() {}
197
};
198
199
200
class ISequentialOutStreamCRC32_Ostream : public ISequentialOutStream_Ostream, public ISequentialStreamCRC32
201
{
202
public:
203
ISequentialOutStreamCRC32_Ostream(std::ostream& Adata) : ISequentialOutStream_Ostream(Adata) { }
204
205
HRESULT Write(const void *aData, UINT32 aSize, UINT32 *aProcessedSize);
206
207
virtual ~ISequentialOutStreamCRC32_Ostream() {}
208
};
209
210
#endif
211
212