Debian Codegraph @

mednafen/MemoryStream.h

raw symbols SCIP
1 /* Mednafen - Multi-system Emulator
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 // TODO/WIP
19
20 #ifndef _MEMORY_STREAM_H
21 #define _MEMORY_STREAM_H
22
23 #include "Stream.h"
24
25 class MemoryStream : public Stream
26 {
27 public:
28
29 MemoryStream();
30 MemoryStream(uint64 size_hint);
31 MemoryStream(Stream *stream); // Will create a MemoryStream equivalent of the contents of "stream", and then "delete stream".
32 // Will only work if stream->tell() == 0, or if "stream" is seekable.
33 // stream will be deleted even if this constructor throws.
34
35 MemoryStream(const MemoryStream &zs);
36 MemoryStream & operator=(const MemoryStream &zs);
37
38 virtual ~MemoryStream();
39
40 virtual uint64 attributes(void);
41
42 virtual uint8 *map(void);
43 virtual void unmap(void);
44
45 virtual uint64 read(void *data, uint64 count, bool error_on_eos = true);
46 virtual void write(const void *data, uint64 count);
47 virtual void seek(int64 offset, int whence);
48 virtual int64 tell(void);
49 virtual int64 size(void);
50 virtual void close(void);
51
52 virtual int get_line(std::string &str);
53
54 private:
55 uint8 *data_buffer;
56 uint64 data_buffer_size;
57 uint64 data_buffer_alloced;
58
59 int64 position;
60
61 void grow_if_necessary(uint64 new_required_size);
62 };
63
64 #endif