Mercurial > audlegacy
annotate Plugins/Input/console/abstract_file.h @ 1702:002a5743e4b6 trunk
[svn] - if a pkg-config module is unavailable, report this
author | nenolod |
---|---|
date | Fri, 15 Sep 2006 16:36:30 -0700 |
parents | c04dff121e1d |
children | 2e7c9f6d9923 |
rev | line source |
---|---|
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
1 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
2 // Abstract file access interfaces |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
3 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
4 #ifndef ABSTRACT_FILE_H |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
5 #define ABSTRACT_FILE_H |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
6 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
7 #include <stdio.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
8 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
9 // Supports reading and finding out how many bytes are remaining |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
10 class Data_Reader { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
11 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
12 Data_Reader() { } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
13 virtual ~Data_Reader() { } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
14 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
15 // NULL on success, otherwise error string |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
16 typedef const char* error_t; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
17 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
18 // Read at most 'n' bytes. Return number of bytes read, zero or negative |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
19 // if error. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
20 virtual long read_avail( void*, long n ) = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
21 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
22 // Read exactly 'n' bytes (error if fewer are available). |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
23 virtual error_t read( void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
24 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
25 // Number of bytes remaining |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
26 virtual long remain() const = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
27 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
28 // Skip forwards by 'n' bytes. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
29 virtual error_t skip( long n ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
30 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
31 // to do: bytes remaining = LONG_MAX when unknown? |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
32 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
33 private: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
34 // noncopyable |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
35 Data_Reader( const Data_Reader& ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
36 Data_Reader& operator = ( const Data_Reader& ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
37 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
38 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
39 // Adds seeking operations |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
40 class File_Reader : public Data_Reader { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
41 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
42 // Size of file |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
43 virtual long size() const = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
44 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
45 // Current position in file |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
46 virtual long tell() const = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
47 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
48 // Change position in file |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
49 virtual error_t seek( long ) = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
50 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
51 virtual long remain() const; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
52 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
53 error_t skip( long n ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
54 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
55 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
56 // Limit access to a subset of data |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
57 class Subset_Reader : public Data_Reader { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
58 Data_Reader* in; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
59 long remain_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
60 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
61 Subset_Reader( Data_Reader*, long size ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
62 long remain() const; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
63 long read_avail( void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
64 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
65 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
66 // Treat range of memory as a file |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
67 class Mem_File_Reader : public File_Reader { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
68 const char* const begin; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
69 long pos; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
70 const long size_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
71 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
72 Mem_File_Reader( const void*, long size ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
73 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
74 long size() const; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
75 long read_avail( void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
76 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
77 long tell() const; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
78 error_t seek( long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
79 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
80 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
81 // File reader based on C FILE |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
82 class Std_File_Reader : public File_Reader { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
83 FILE* file_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
84 protected: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
85 void reset( FILE* f ) { file_ = f; } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
86 //FILE* owned_file; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
87 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
88 Std_File_Reader(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
89 ~Std_File_Reader(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
90 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
91 error_t open( const char* ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
92 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
93 FILE* file() const { return file_; } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
94 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
95 // Forward read requests to file. Caller must close file later. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
96 //void forward( FILE* ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
97 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
98 long size() const; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
99 long read_avail( void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
100 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
101 long tell() const; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
102 error_t seek( long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
103 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
104 void close(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
105 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
106 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
107 // Supports writing |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
108 class Data_Writer { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
109 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
110 Data_Writer() { } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
111 virtual ~Data_Writer() { } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
112 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
113 typedef const char* error_t; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
114 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
115 // Write 'n' bytes. NULL on success, otherwise error string. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
116 virtual error_t write( const void*, long n ) = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
117 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
118 void satisfy_lame_linker_(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
119 private: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
120 // noncopyable |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
121 Data_Writer( const Data_Writer& ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
122 Data_Writer& operator = ( const Data_Writer& ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
123 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
124 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
125 class Std_File_Writer : public Data_Writer { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
126 FILE* file_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
127 protected: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
128 void reset( FILE* f ) { file_ = f; } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
129 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
130 Std_File_Writer(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
131 ~Std_File_Writer(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
132 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
133 error_t open( const char* ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
134 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
135 FILE* file() const { return file_; } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
136 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
137 // Forward writes to file. Caller must close file later. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
138 //void forward( FILE* ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
139 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
140 error_t write( const void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
141 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
142 void close(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
143 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
144 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
145 // Write data to memory |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
146 class Mem_Writer : public Data_Writer { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
147 char* data_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
148 long size_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
149 long allocated; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
150 enum { expanding, fixed, ignore_excess } mode; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
151 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
152 // Keep all written data in expanding block of memory |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
153 Mem_Writer(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
154 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
155 // Write to fixed-size block of memory. If ignore_excess is false, returns |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
156 // error if more than 'size' data is written, otherwise ignores any excess. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
157 Mem_Writer( void*, long size, int ignore_excess = 0 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
158 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
159 error_t write( const void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
160 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
161 // Pointer to beginning of written data |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
162 char* data() { return data_; } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
163 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
164 // Number of bytes written |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
165 long size() const { return size_; } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
166 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
167 ~Mem_Writer(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
168 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
169 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
170 // Written data is ignored |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
171 class Null_Writer : public Data_Writer { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
172 public: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
173 error_t write( const void*, long ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
174 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
175 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
176 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
177 |