1
2
3
4
5
6 using System;
7
8 namespace System.IO
9 {
10 public class Buffer
11 {
12 public nothrow Buffer(long size_) : size(size_), mem(cast<byte*>(MemAlloc(size)))
13 {
14 }
15 suppress Buffer(const Buffer&);
16 suppress void operator=(const Buffer&);
17 public nothrow Buffer(Buffer&& that) : size(that.size), mem(that.mem)
18 {
19 that.size = 0;
20 that.mem = null;
21 }
22 public default nothrow void operator=(Buffer&& that);
23 public ~Buffer()
24 {
25 if (mem != null)
26 {
27 MemFree(mem);
28 }
29 }
30 public inline nothrow long Size() const
31 {
32 return size;
33 }
34 public inline nothrow byte* Mem() const
35 {
36 return mem;
37 }
38 public inline nothrow byte operator[](long index) const
39 {
40 if (index < 0 || index >= size)
41 {
42 ThrowIndexOutOfBoundsException();
43 }
44 return mem[index];
45 }
46 public inline nothrow byte& operator[](long index)
47 {
48 if (index < 0 || index >= size)
49 {
50 ThrowIndexOutOfBoundsException();
51 }
52 return mem[index];
53 }
54 private long size;
55 private byte* mem;
56 }
57 }