annotate dmd/OutBuffer.d @ 2:7427ded8caf7

Removed unreferenced modules First step at fixing GC issues - now calling GC.malloc instead of malloc (ditto calloc and realloc), get rid of free
author korDen
date Sun, 25 Oct 2009 03:20:59 +0300
parents 10317f0c89a5
children d706d958e4e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import std.stdarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import std.contracts;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import core.stdc.stdlib;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
9 import dmd.Memory;
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
10
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 class OutBuffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 ubyte* data;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 uint offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 uint size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 // do nothing
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 final void* extractData()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 void* p = cast(void*)data;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 size = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 return p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 void mark()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 final void reserve(uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 if (size - offset < nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 size = (offset + nbytes) * 2;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
44 data = cast(ubyte*)GC.realloc(data, size);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 final void setsize(uint size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 final void reset()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 final void write(const(void)* data, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 reserve(nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 memcpy(this.data + offset, data, nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 offset += nbytes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 final void writebstring(ubyte* string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 final void writestring(const(char)[] string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 write(string_.ptr , string_.length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 final void writedstring(const(char)* string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 final void writedstring(const(wchar)* string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 final void prependstring(const(char)[] string_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 uint len = string_.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 reserve(len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 memmove(data + len, data, offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 memcpy(data, string_.ptr, len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 offset += len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 final void writenl() // write newline
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 final void writeByte(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 reserve(1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 this.data[offset] = cast(ubyte)b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 offset++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 final void writebyte(uint b) { writeByte(b); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 final void writeUTF8(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 reserve(6);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 if (b <= 0x7F)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 this.data[offset] = cast(ubyte)b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 offset++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 else if (b <= 0x7FF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 this.data[offset + 0] = cast(ubyte)((b >> 6) | 0xC0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 this.data[offset + 1] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 offset += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 else if (b <= 0xFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 this.data[offset + 0] = cast(ubyte)((b >> 12) | 0xE0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 this.data[offset + 1] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 this.data[offset + 2] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 offset += 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 else if (b <= 0x1FFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 this.data[offset + 0] = cast(ubyte)((b >> 18) | 0xF0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 this.data[offset + 1] = cast(ubyte)(((b >> 12) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 this.data[offset + 2] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 this.data[offset + 3] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 offset += 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 else if (b <= 0x3FFFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 this.data[offset + 0] = cast(ubyte)((b >> 24) | 0xF8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 this.data[offset + 1] = cast(ubyte)(((b >> 18) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 this.data[offset + 2] = cast(ubyte)(((b >> 12) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 this.data[offset + 3] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 this.data[offset + 4] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 offset += 5;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 else if (b <= 0x7FFFFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 this.data[offset + 0] = cast(ubyte)((b >> 30) | 0xFC);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 this.data[offset + 1] = cast(ubyte)(((b >> 24) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 this.data[offset + 2] = cast(ubyte)(((b >> 18) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 this.data[offset + 3] = cast(ubyte)(((b >> 12) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 this.data[offset + 4] = cast(ubyte)(((b >> 6) & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 this.data[offset + 5] = cast(ubyte)((b & 0x3F) | 0x80);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 offset += 6;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 final void writedchar(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 final void prependbyte(uint b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 final void writeword(uint w)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 reserve(2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 *cast(ushort*)(this.data + offset) = cast(ushort)w;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 offset += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 final void writeUTF16(uint w)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 reserve(4);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 if (w <= 0xFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 *cast(ushort*)(this.data + offset) = cast(ushort)w;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 offset += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 else if (w <= 0x10FFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 *cast(ushort*)(this.data + offset) = cast(ushort)((w >> 10) + 0xD7C0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 *cast(ushort*)(this.data + offset + 2) = cast(ushort)((w & 0x3FF) | 0xDC00);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 offset += 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 final void write4(uint w)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 final void write(OutBuffer buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 if (buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 reserve(buf.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 memcpy(data + offset, buf.data, buf.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 offset += buf.offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 final void write(Object obj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 final void fill0(uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 reserve(nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 memset(data + offset, 0, nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 offset += nbytes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 final void align_(uint size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 void vprintf(const(char)* format, va_list args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 void printf(T...)(string format, T t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 string s = std.string.format(format, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 writestring(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 version (M_UNICODE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 /// void vprintf(const uint short *format, va_list args);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 /// void printf(const uint short *format, ...);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 final void bracket(char left, char right)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 final uint bracket(uint i, const(char)* left, uint j, const(char)* right)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 final void spread(uint offset, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 final uint insert(uint offset, const(void)* data, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 final void remove(uint offset, uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 string toChars()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 return getString().idup;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 final string extractString()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 char[] s = getString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 size = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 return assumeUnique(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 final char[] getString()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 char* s = cast(char*)data;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 return s[0..offset];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 }