Class DataReader
BinaryReader extension that adds methods for reading 32 and 64-bit integer values in a packed format.
Inheritance
Implements
Inherited Members
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 SourceDataReader(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 |
Methods
| Improve this Doc View SourceReadDouble()
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
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
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 |
---|---|
System.Int32 | A 4-byte signed integer read from the current stream. |
Overrides
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 |
---|---|
System.Int64 | An 8-byte signed integer read from the current stream. |
Overrides
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 |
---|---|
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. |
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. |
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 |
---|---|
System.Single | A Single value read from the stream. |
Overrides
ReadString()
Reads string from the stream.
Declaration
public override string ReadString()
Returns
Type | Description |
---|---|
System.String | A String value read from the stream. |
Overrides
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 |
---|---|
System.UInt16 | A 2-byte unsigned integer read from this stream. |
Overrides
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 |
---|---|
System.UInt32 | A 4-byte unsigned integer read from this stream. |
Overrides
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 |
---|---|
System.UInt64 | An 8-byte unsigned integer read from this stream. |
Overrides
Remarks
Overrides BinaryReader.ReadUInt64 by changing endian of the value read from the stream.