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
Afficher le fichier Open project: jadref/buffer_bci Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

Closes the reader, including the underlying stream..
public Close ( ) : void
Résultat void

Dispose() public méthode

Disposes of the underlying stream.
public Dispose ( ) : void
Résultat void

EndianBinaryReader() public méthode

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
Résultat System

EndianBinaryReader() public méthode

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
Résultat System

Read() public méthode

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
Résultat int

Read() public méthode

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
Résultat int

Read() public méthode

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
Résultat int

Read7BitEncodedInt() public méthode

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
Résultat int

ReadBigEndian7BitEncodedInt() public méthode

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
Résultat int

ReadBoolean() public méthode

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

ReadByte() public méthode

Reads a single byte from the stream.
public ReadByte ( ) : byte
Résultat byte

ReadBytes() public méthode

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
Résultat byte[]

ReadBytesOrThrow() public méthode

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
Résultat byte[]

ReadDecimal() public méthode

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

ReadDouble() public méthode

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

ReadInt16() public méthode

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

ReadInt32() public méthode

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

ReadInt64() public méthode

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

ReadSByte() public méthode

Reads a single signed byte from the stream.
public ReadSByte ( ) : sbyte
Résultat sbyte

ReadSingle() public méthode

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

ReadString() public méthode

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
Résultat string

ReadUInt16() public méthode

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

ReadUInt32() public méthode

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

ReadUInt64() public méthode

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

Seek() public méthode

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