예제 #1
0
 /// <summary>   Constructor. </summary>
 /// <param name="source">   Source for the. </param>
 public CharStream(Stream source)
 {
     sourceReader = new BinaryReader(source, Encoding);
     memory       = new MemoryStream();
     memoryReader = new BinaryReader(memory, Encoding);
     memoryWriter = new BinaryWriter(memory, Encoding);
     Position     = new CharStreamPosition(0, 1, 1);
 }
예제 #2
0
 private CharStream(MemoryStream memory, BinaryReader memoryReader, BinaryWriter memoryWriter,
                    BinaryReader sourceReader, CharStreamPosition position)
 {
     this.sourceReader = sourceReader;
     this.memory       = memory;
     this.memoryReader = memoryReader;
     this.memoryWriter = memoryWriter;
     Position          = position;
 }
예제 #3
0
 /// <summary>   At position. </summary>
 /// <param name="position"> The position. </param>
 /// <returns>   A CharStream. </returns>
 public CharStream AtPosition(CharStreamPosition position)
 {
     return(new CharStream(memory, memoryReader, memoryWriter, sourceReader, position));
 }
예제 #4
0
 private long CharsNeeded(long count, CharStreamPosition pos)
 {
     return(Math.Max(0, count - CharsAvalaible(pos)));
 }
예제 #5
0
 private long CharsAvalaible(CharStreamPosition pos)
 {
     return(memory.Length - pos.Index);
 }