C# Class MiscUtil.IO.EndianBinaryReader

Equivalent of System.IO.BinaryReader, but with either endianness, depending on the EndianBitConverter it is constructed with. No data is buffered in the reader; the client may seek within the stream at will.
Inheritance: IDisposable
ファイルを表示 Open project: jadref/buffer_bci Class Usage Examples

Public Methods

Method Description
Close ( ) : void

Closes the reader, including the underlying stream..

Dispose ( ) : void

Disposes of the underlying stream.

EndianBinaryReader ( EndianBitConverter bitConverter, Stream stream ) : System

Equivalent of System.IO.BinaryWriter, but with either endianness, depending on the EndianBitConverter it is constructed with.

EndianBinaryReader ( EndianBitConverter bitConverter, Stream stream, Encoding encoding ) : System

Constructs a new binary reader with the given bit converter, reading to the given stream, using the given encoding.

Read ( ) : int

Reads a single character from the stream, using the character encoding for this reader. If no characters have been fully read by the time the stream ends, -1 is returned.

Read ( byte buffer, int index, int count ) : int

Reads the specified number of bytes into the given buffer, starting at the given index.

Read ( char data, int index, int count ) : int

Reads the specified number of characters into the given buffer, starting at the given index.

Read7BitEncodedInt ( ) : int

Reads a 7-bit encoded integer from the stream. This is stored with the least significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter.

ReadBigEndian7BitEncodedInt ( ) : int

Reads a 7-bit encoded integer from the stream. This is stored with the most significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter.

ReadBoolean ( ) : bool

Reads a boolean from the stream. 1 byte is read.

ReadByte ( ) : byte

Reads a single byte from the stream.

ReadBytes ( int count ) : byte[]

Reads the specified number of bytes, returning them in a new byte array. If not enough bytes are available before the end of the stream, this method will return what is available.

ReadBytesOrThrow ( int count ) : byte[]

Reads the specified number of bytes, returning them in a new byte array. If not enough bytes are available before the end of the stream, this method will throw an IOException.

ReadDecimal ( ) : decimal

Reads a decimal value from the stream, using the bit converter for this reader. 16 bytes are read.

ReadDouble ( ) : double

Reads a double-precision floating-point value from the stream, using the bit converter for this reader. 8 bytes are read.

ReadInt16 ( ) : short

Reads a 16-bit signed integer from the stream, using the bit converter for this reader. 2 bytes are read.

ReadInt32 ( ) : int

Reads a 32-bit signed integer from the stream, using the bit converter for this reader. 4 bytes are read.

ReadInt64 ( ) : long

Reads a 64-bit signed integer from the stream, using the bit converter for this reader. 8 bytes are read.

ReadSByte ( ) : sbyte

Reads a single signed byte from the stream.

ReadSingle ( ) : float

Reads a single-precision floating-point value from the stream, using the bit converter for this reader. 4 bytes are read.

ReadString ( int bytesToRead ) : string

Reads a length-prefixed string from the stream, using the encoding for this reader. A 7-bit encoded integer is first read, which specifies the number of bytes to read from the stream. These bytes are then converted into a string with the encoding for this reader.

ReadUInt16 ( ) : ushort

Reads a 16-bit unsigned integer from the stream, using the bit converter for this reader. 2 bytes are read.

ReadUInt32 ( ) : uint

Reads a 32-bit unsigned integer from the stream, using the bit converter for this reader. 4 bytes are read.

ReadUInt64 ( ) : ulong

Reads a 64-bit unsigned integer from the stream, using the bit converter for this reader. 8 bytes are read.

Seek ( int offset, SeekOrigin origin ) : void

Seeks within the stream.

Private Methods

Method Description
CheckDisposed ( ) : void

Checks whether or not the reader has been disposed, throwing an exception if so.

ReadInternal ( byte data, int size ) : void

Reads the given number of bytes from the stream, throwing an exception if they can't all be read.

TryReadInternal ( byte data, int size ) : int

Reads the given number of bytes from the stream if possible, returning the number of bytes actually read, which may be less than requested if (and only if) the end of the stream is reached.

Method Details

Close() public method

Closes the reader, including the underlying stream..
public Close ( ) : void
return void

Dispose() public method

Disposes of the underlying stream.
public Dispose ( ) : void
return void

EndianBinaryReader() public method

Equivalent of System.IO.BinaryWriter, but with either endianness, depending on the EndianBitConverter it is constructed with.
public EndianBinaryReader ( EndianBitConverter bitConverter, Stream stream ) : System
bitConverter MiscUtil.Conversion.EndianBitConverter Converter to use when reading data
stream Stream Stream to read data from
return System

EndianBinaryReader() public method

Constructs a new binary reader with the given bit converter, reading to the given stream, using the given encoding.
public EndianBinaryReader ( EndianBitConverter bitConverter, Stream stream, Encoding encoding ) : System
bitConverter MiscUtil.Conversion.EndianBitConverter Converter to use when reading data
stream Stream Stream to read data from
encoding System.Text.Encoding Encoding to use when reading character data
return System

Read() public method

Reads a single character from the stream, using the character encoding for this reader. If no characters have been fully read by the time the stream ends, -1 is returned.
public Read ( ) : int
return int

Read() public method

Reads the specified number of bytes into the given buffer, starting at the given index.
public Read ( byte buffer, int index, int count ) : int
buffer byte The buffer to copy data into
index int The first index to copy data into
count int The number of bytes to read
return int

Read() public method

Reads the specified number of characters into the given buffer, starting at the given index.
public Read ( char data, int index, int count ) : int
data char The buffer to copy data into
index int The first index to copy data into
count int The number of characters to read
return int

Read7BitEncodedInt() public method

Reads a 7-bit encoded integer from the stream. This is stored with the least significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter.
public Read7BitEncodedInt ( ) : int
return int

ReadBigEndian7BitEncodedInt() public method

Reads a 7-bit encoded integer from the stream. This is stored with the most significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter.
public ReadBigEndian7BitEncodedInt ( ) : int
return int

ReadBoolean() public method

Reads a boolean from the stream. 1 byte is read.
public ReadBoolean ( ) : bool
return bool

ReadByte() public method

Reads a single byte from the stream.
public ReadByte ( ) : byte
return byte

ReadBytes() public method

Reads the specified number of bytes, returning them in a new byte array. If not enough bytes are available before the end of the stream, this method will return what is available.
public ReadBytes ( int count ) : byte[]
count int The number of bytes to read
return byte[]

ReadBytesOrThrow() public method

Reads the specified number of bytes, returning them in a new byte array. If not enough bytes are available before the end of the stream, this method will throw an IOException.
public ReadBytesOrThrow ( int count ) : byte[]
count int The number of bytes to read
return byte[]

ReadDecimal() public method

Reads a decimal value from the stream, using the bit converter for this reader. 16 bytes are read.
public ReadDecimal ( ) : decimal
return decimal

ReadDouble() public method

Reads a double-precision floating-point value from the stream, using the bit converter for this reader. 8 bytes are read.
public ReadDouble ( ) : double
return double

ReadInt16() public method

Reads a 16-bit signed integer from the stream, using the bit converter for this reader. 2 bytes are read.
public ReadInt16 ( ) : short
return short

ReadInt32() public method

Reads a 32-bit signed integer from the stream, using the bit converter for this reader. 4 bytes are read.
public ReadInt32 ( ) : int
return int

ReadInt64() public method

Reads a 64-bit signed integer from the stream, using the bit converter for this reader. 8 bytes are read.
public ReadInt64 ( ) : long
return long

ReadSByte() public method

Reads a single signed byte from the stream.
public ReadSByte ( ) : sbyte
return sbyte

ReadSingle() public method

Reads a single-precision floating-point value from the stream, using the bit converter for this reader. 4 bytes are read.
public ReadSingle ( ) : float
return float

ReadString() public method

Reads a length-prefixed string from the stream, using the encoding for this reader. A 7-bit encoded integer is first read, which specifies the number of bytes to read from the stream. These bytes are then converted into a string with the encoding for this reader.
public ReadString ( int bytesToRead ) : string
bytesToRead int
return string

ReadUInt16() public method

Reads a 16-bit unsigned integer from the stream, using the bit converter for this reader. 2 bytes are read.
public ReadUInt16 ( ) : ushort
return ushort

ReadUInt32() public method

Reads a 32-bit unsigned integer from the stream, using the bit converter for this reader. 4 bytes are read.
public ReadUInt32 ( ) : uint
return uint

ReadUInt64() public method

Reads a 64-bit unsigned integer from the stream, using the bit converter for this reader. 8 bytes are read.
public ReadUInt64 ( ) : ulong
return ulong

Seek() public method

Seeks within the stream.
public Seek ( int offset, SeekOrigin origin ) : void
offset int Offset to seek to.
origin SeekOrigin Origin of seek operation.
return void