Mercurial > repos > IBBoard
annotate IO/BinaryReaderBigEndian.cs @ 43:2baf3f949cfb
* Make sure that we use "." as our decimal separator when parsing doubles from XML (should fix warfoundry:#185 for Europe)
* Automated cleanups
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Oct 2009 09:47:16 +0000 |
parents | 267cd5ce66ff |
children |
rev | line source |
---|---|
30
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (FileStreamstream.cs) is a part of the IBBoard project and is copyright 2009 IBBoard |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 // |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 using System.Collections.Generic; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using System.IO; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using System.Text; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 namespace IBBoard |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 /// <summary> |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 /// A custom replacement for the BinaryReader that reads numbers as big-endian and also provides methods to read byte delimited strings. |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 /// </summary> |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 public class BinaryReaderBigEndian |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 private Stream stream; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 private Encoding encoding; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 public BinaryReaderBigEndian(Stream input) : this(input, Encoding.UTF8) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 public BinaryReaderBigEndian(Stream input, Encoding encoding) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 stream = input; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 this.encoding = encoding; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 public byte[] ReadBytes(int byteCount) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 byte[] bytes = new byte[byteCount]; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 stream.Read(bytes, 0, byteCount); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 return bytes; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 private byte[] ReadBytesForNumber(int byteCount) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 byte[] bytes = ReadBytes(byteCount); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 int halfCount = byteCount / 2; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 for (int i = 0, j = byteCount - 1; i < halfCount; i++, j--) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 byte temp = bytes[i]; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 bytes[i] = bytes[j]; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 bytes[j] = temp; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 return bytes; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 public byte ReadByte() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 return (byte)stream.ReadByte(); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 public short ReadShort() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 return BitConverter.ToInt16(ReadBytesForNumber(2), 0); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 public ushort ReadUShort() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 return BitConverter.ToUInt16(ReadBytesForNumber(2), 0); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 public int ReadInt() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 return BitConverter.ToInt32(ReadBytesForNumber(4), 0); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 public uint ReadUInt() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 return BitConverter.ToUInt32(ReadBytesForNumber(4), 0); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 public string ReadDelimitedString(byte delimiter) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 List<byte> bytes = new List<byte>(); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 while (!EndOfStream) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 byte b = ReadByte(); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 if (b!=delimiter) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 bytes.Add(b); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 else |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 break; |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 return encoding.GetString(bytes.ToArray()); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 public string ReadString(int length) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 byte[] bytes = ReadBytes(length); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 return encoding.GetString(bytes); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 public string ReadUShortLengthString() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
107 ushort length = ReadUShort(); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 return ReadString(length); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
111 public string ReadIntLengthString() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 int length = ReadInt(); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 return ReadString(length); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 public void Seek(int distance) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 stream.Seek(distance, SeekOrigin.Begin); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 public void Move(int distance) |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
123 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 stream.Seek(distance, SeekOrigin.Current); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 public void Close() |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 stream.Close(); |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 public bool EndOfStream |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 { |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 get { return stream.Length - 1 == stream.Position; } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 } |
32
267cd5ce66ff
Add "Position" property to Big-Endian binary reader
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
136 |
267cd5ce66ff
Add "Position" property to Big-Endian binary reader
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
137 public long Position |
267cd5ce66ff
Add "Position" property to Big-Endian binary reader
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
138 { |
267cd5ce66ff
Add "Position" property to Big-Endian binary reader
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
139 get { return stream.Position; } |
267cd5ce66ff
Add "Position" property to Big-Endian binary reader
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
140 } |
30
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 } |
23fd4247fc1c
* Add "big-endian" binary reader that reads ints/shorts in big-endian format
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 } |