176
|
1 using System;
|
|
2 using System.IO;
|
|
3
|
|
4 namespace Implab.Formats {
|
|
5 public class ReaderScanner: TextScanner {
|
|
6 const int CHUNK_SIZE = 1024;
|
|
7 const int BUFFER_MAX = CHUNK_SIZE*1024;
|
|
8
|
|
9 readonly TextReader m_reader;
|
|
10
|
|
11 public ReaderScanner(TextReader reader, int limit, int chunk) : base(limit, chunk) {
|
|
12 Safe.ArgumentNotNull(reader, "reader");
|
|
13 m_reader = reader;
|
|
14 }
|
|
15
|
|
16 public ReaderScanner(TextReader reader) : this(reader, BUFFER_MAX, CHUNK_SIZE) {
|
|
17 }
|
|
18
|
|
19 protected override int Read(char[] buffer, int offset, int size) {
|
|
20 return m_reader.Read(buffer, offset, size);
|
|
21 }
|
|
22
|
|
23 protected override void Dispose(bool disposing) {
|
|
24 if (disposing)
|
|
25 Safe.Dispose(m_reader);
|
|
26 base.Dispose(disposing);
|
|
27 }
|
|
28 }
|
|
29 }
|
|
30
|