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
System.Object
System.IO.BinaryReader
DataReader
Implements
System.IDisposable
Inherited Members
System.IO.BinaryReader.Dispose()
System.IO.BinaryReader.Dispose(System.Boolean)
System.IO.BinaryReader.FillBuffer(System.Int32)
System.IO.BinaryReader.PeekChar()
System.IO.BinaryReader.Read()
System.IO.BinaryReader.Read(System.Byte[], System.Int32, System.Int32)
System.IO.BinaryReader.Read(System.Char[], System.Int32, System.Int32)
System.IO.BinaryReader.Read7BitEncodedInt()
System.IO.BinaryReader.ReadBoolean()
System.IO.BinaryReader.ReadByte()
System.IO.BinaryReader.ReadBytes(System.Int32)
System.IO.BinaryReader.ReadChar()
System.IO.BinaryReader.ReadChars(System.Int32)
System.IO.BinaryReader.ReadDecimal()
System.IO.BinaryReader.ReadSByte()
System.IO.BinaryReader.BaseStream
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Tangosol.IO
Assembly: Coherence.Core.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

| Improve this Doc View Source

DataReader(Stream)

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

Declaration
public DataReader(Stream input)
Parameters
Type Name Description
System.IO.Stream input

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

Methods

| Improve this Doc View Source

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
System.Double

A Double value read from the stream.

Overrides
System.IO.BinaryReader.ReadDouble()
| Improve this Doc View Source

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
System.Int16

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

Overrides
System.IO.BinaryReader.ReadInt16()
Remarks

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

| Improve this Doc View Source

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
System.Int32

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

Overrides
System.IO.BinaryReader.ReadInt32()
Remarks

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

| Improve this Doc View Source

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
System.Int64

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

Overrides
System.IO.BinaryReader.ReadInt64()
Remarks

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

| Improve this Doc View Source

ReadPackedInt32()

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

Declaration
public virtual int ReadPackedInt32()
Returns
Type Description
System.Int32

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
System.IO.IOException

If an I/O error occurs.

| Improve this Doc View Source

ReadPackedInt64()

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

Declaration
public virtual long ReadPackedInt64()
Returns
Type Description
System.Int64

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
System.IO.IOException

If an I/O error occurs.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
System.Single

A Single value read from the stream.

Overrides
System.IO.BinaryReader.ReadSingle()
| Improve this Doc View Source

ReadString()

Reads string from the stream.

Declaration
public override string ReadString()
Returns
Type Description
System.String

A String value read from the stream.

Overrides
System.IO.BinaryReader.ReadString()
Remarks

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

| Improve this Doc View Source

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
System.UInt16

A 2-byte unsigned integer read from this stream.

Overrides
System.IO.BinaryReader.ReadUInt16()
Remarks

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

| Improve this Doc View Source

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
System.UInt32

A 4-byte unsigned integer read from this stream.

Overrides
System.IO.BinaryReader.ReadUInt32()
Remarks

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

| Improve this Doc View Source

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
System.UInt64

An 8-byte unsigned integer read from this stream.

Overrides
System.IO.BinaryReader.ReadUInt64()
Remarks

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

Implements

System.IDisposable

See Also

DataWriter
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.