Show / Hide Table of Contents

Class DataReader

BinaryReader extension that adds methods for reading 32 and 64-bit integer values in a packed format.

Inheritance
object
BinaryReader
DataReader
Implements
IDisposable
Inherited Members
BinaryReader.Close()
BinaryReader.Dispose()
BinaryReader.Dispose(bool)
BinaryReader.FillBuffer(int)
BinaryReader.PeekChar()
BinaryReader.Read()
BinaryReader.Read(byte[], int, int)
BinaryReader.Read(char[], int, int)
BinaryReader.Read(Span<byte>)
BinaryReader.Read(Span<char>)
BinaryReader.Read7BitEncodedInt()
BinaryReader.Read7BitEncodedInt64()
BinaryReader.ReadBoolean()
BinaryReader.ReadByte()
BinaryReader.ReadBytes(int)
BinaryReader.ReadChar()
BinaryReader.ReadChars(int)
BinaryReader.ReadDecimal()
BinaryReader.ReadHalf()
BinaryReader.ReadSByte()
BinaryReader.BaseStream
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.IO
Assembly: Coherence.dll
Syntax
public class DataReader : BinaryReader, IDisposable
Remarks

The "packed" format includes a sign bit (0x40) and a continuation bit (0x80) in the first byte, followed by the least 6 significant bits of the int value. Subsequent bytes (each appearing only if the previous byte had its continuation bit set) include a continuation bit (0x80) and the next least 7 significant bits of the int value.

In this way, a 32-bit value is encoded into 1-5 bytes, and 64-bit value is encoded into 1-10 bytes, depending on the magnitude of the value being encoded.

Constructors

DataReader(Stream)

Construct a new DataReader that will read from a passed Stream object.

Declaration
public DataReader(Stream input)
Parameters
Type Name Description
Stream input

The Stream object to write from; must not be null.

Methods

ReadDouble()

Reads bits which are stored in an Int64 instance and converts them into the Double object.

Declaration
public override double ReadDouble()
Returns
Type Description
double

A Double value read from the stream.

Overrides
BinaryReader.ReadDouble()

ReadInt16()

Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes.

Declaration
public override short ReadInt16()
Returns
Type Description
short

A 2-byte signed integer read from the current stream.

Overrides
BinaryReader.ReadInt16()
Remarks

Overrides BinaryReader.ReadInt16 by changing endian of the value read from the stream.

ReadInt32()

Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes.

Declaration
public override int ReadInt32()
Returns
Type Description
int

A 4-byte signed integer read from the current stream.

Overrides
BinaryReader.ReadInt32()
Remarks

Overrides BinaryReader.ReadInt32 by changing endian of the value read from the stream.

ReadInt64()

Reads an 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes.

Declaration
public override long ReadInt64()
Returns
Type Description
long

An 8-byte signed integer read from the current stream.

Overrides
BinaryReader.ReadInt64()
Remarks

Overrides BinaryReader.ReadInt64 by changing endian of the value read from the stream.

ReadPackedInt32()

Reads an Int32 value using a variable-length storage format.

Declaration
public virtual int ReadPackedInt32()
Returns
Type Description
int

An Int32 value.

Remarks

The "packed" format includes a sign bit (0x40) and a continuation bit (0x80) in the first byte, followed by the least 6 significant bits of the int value. Subsequent bytes (each appearing only if the previous byte had its continuation bit set) include a continuation bit (0x80) and the next least 7 significant bits of the int value. In this way, a 32-bit value is encoded into 1-5 bytes, depending on the magnitude of the value being encoded.

Exceptions
Type Condition
IOException

If an I/O error occurs.

ReadPackedInt64()

Reads an Int64 value using a variable-length storage format.

Declaration
public virtual long ReadPackedInt64()
Returns
Type Description
long

An Int64 value.

Remarks

The "packed" format includes a sign bit (0x40) and a continuation bit (0x80) in the first byte, followed by the least 6 significant bits of the int value. Subsequent bytes (each appearing only if the previous byte had its continuation bit set) include a continuation bit (0x80) and the next least 7 significant bits of the int value. In this way, a 64-bit value is encoded into 1-10 bytes, depending on the magnitude of the value being encoded.

Exceptions
Type Condition
IOException

If an I/O error occurs.

ReadPackedRawInt128(DataReader)

Reads a RawInt128 value from DataReader.

Declaration
public virtual RawInt128 ReadPackedRawInt128(DataReader reader)
Parameters
Type Name Description
DataReader reader

The DataReader to read from.

Returns
Type Description
RawInt128

RawInt128 value.

ReadSingle()

Reads bits which are stored in an Int32 instance and converts them into the Single object.

Declaration
public override float ReadSingle()
Returns
Type Description
float

A Single value read from the stream.

Overrides
BinaryReader.ReadSingle()

ReadString()

Reads string from the stream.

Declaration
public override string ReadString()
Returns
Type Description
string

A String value read from the stream.

Overrides
BinaryReader.ReadString()
Remarks

String is prefixed with the string length encoded as "packed" Int32.

ReadUInt16()

Reads a 2-byte unsigned integer from the current stream using little endian encoding and advances the position of the stream by two bytes.

Declaration
public override ushort ReadUInt16()
Returns
Type Description
ushort

A 2-byte unsigned integer read from this stream.

Overrides
BinaryReader.ReadUInt16()
Remarks

Overrides BinaryReader.ReadUInt16 by changing endian of the value read from the stream.

ReadUInt32()

Reads a 4-byte unsigned integer from the current stream and advances the position of the stream by four bytes.

Declaration
public override uint ReadUInt32()
Returns
Type Description
uint

A 4-byte unsigned integer read from this stream.

Overrides
BinaryReader.ReadUInt32()
Remarks

Overrides BinaryReader.ReadUInt32 by changing endian of the value read from the stream.

ReadUInt64()

Reads an 8-byte unsigned integer from the current stream and advances the position of the stream by eight bytes.

Declaration
public override ulong ReadUInt64()
Returns
Type Description
ulong

An 8-byte unsigned integer read from this stream.

Overrides
BinaryReader.ReadUInt64()
Remarks

Overrides BinaryReader.ReadUInt64 by changing endian of the value read from the stream.

Implements

IDisposable

See Also

DataWriter
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.