mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
41 lines
909 B
C#
41 lines
909 B
C#
namespace UglyToad.Pdf.IO
|
|
{
|
|
using System.Collections.Generic;
|
|
|
|
public class ByteArrayInputBytes : IInputBytes
|
|
{
|
|
private readonly IReadOnlyList<byte> bytes;
|
|
|
|
public ByteArrayInputBytes(IReadOnlyList<byte> bytes)
|
|
{
|
|
this.bytes = bytes;
|
|
CurrentOffset = -1;
|
|
}
|
|
|
|
public int CurrentOffset { get; private set; }
|
|
|
|
public bool MoveNext()
|
|
{
|
|
if (CurrentOffset == bytes.Count - 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
CurrentOffset++;
|
|
CurrentByte = bytes[CurrentOffset];
|
|
return true;
|
|
}
|
|
|
|
public byte CurrentByte { get; private set; }
|
|
|
|
public byte? Peek()
|
|
{
|
|
if (CurrentOffset == bytes.Count - 1)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return bytes[CurrentOffset + 1];
|
|
}
|
|
}
|
|
} |