176
|
1 using System;
|
|
2
|
|
3 namespace Implab.Formats {
|
|
4 public class StringScanner: TextScanner {
|
|
5 const int CHUNK_SIZE = 1024;
|
|
6
|
|
7 readonly string m_text;
|
|
8 int m_pos;
|
|
9
|
|
10 public StringScanner(string text) : base(text.Length, text.Length < CHUNK_SIZE ? text.Length : CHUNK_SIZE) {
|
|
11 m_text = text;
|
|
12 Feed();
|
|
13 }
|
|
14
|
|
15 protected override int Read(char[] buffer, int offset, int size) {
|
|
16 var actual = size + m_pos > m_text.Length ? m_text.Length - m_pos : size;
|
|
17
|
|
18 m_text.CopyTo(m_pos,buffer,offset, actual);
|
|
19
|
|
20 m_pos += actual;
|
|
21
|
|
22 return actual;
|
|
23 }
|
|
24 }
|
|
25 }
|
|
26
|