BigEndianByteReader

public final class BigEndianByteReader : ByteReader

A type that contains functions for reading Data byte-by-byte in the Big Endian order.

  • Size of the data (in bytes).

    Declaration

    Swift

    public let size: Int
  • Data which is being read.

    Declaration

    Swift

    public let data: Data
  • Offset to a byte in the data which will be read next.

    Declaration

    Swift

    public var offset: Int
  • Creates an instance for reading bytes from the data.

    Declaration

    Swift

    public init(data: Data)
  • Reads a byte and returns it, advancing by one position.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func byte() -> UInt8
  • Reads count bytes and returns them as a [UInt8] array, advancing by count positions.

    Precondition

    Parameter count must be non-negative.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func bytes(count: Int) -> [UInt8]
  • Reads 8 bytes and returns them as a UInt64 number, advancing by 8 positions.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func uint64() -> UInt64
  • Reads fromBytes bytes and returns them as a UInt64 number, advancing by fromBytes positions.

    Note

    If it is known that the fromBytes is exactly 8 then consider using the uint64() function (without an argument), since it may provide better performance.

    Precondition

    Parameter fromBytes must be in the 0...8 range.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func uint64(fromBytes count: Int) -> UInt64
  • Reads 4 bytes and returns them as a UInt32 number, advancing by 4 positions.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func uint32() -> UInt32
  • Reads fromBytes bytes and returns them as a UInt32 number, advancing by fromBytes positions.

    Note

    If it is known that the fromBytes is exactly 4 then consider using the uint32() function (without an argument), since it may provide better performance.

    Precondition

    Parameter fromBytes must be in the 0...4 range.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func uint32(fromBytes count: Int) -> UInt32
  • Reads 2 bytes and returns them as a UInt16 number, advancing by 2 positions.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func uint16() -> UInt16
  • Reads fromBytes bytes and returns them as a UInt16 number, advancing by fromBytes positions.

    Note

    If it is known that the fromBytes is exactly 2 then consider using the uint16() function (without an argument), since it may provide better performance.

    Precondition

    Parameter fromBytes must be in the 0...2 range.

    Precondition

    There must be enough bytes left.

    Declaration

    Swift

    public func uint16(fromBytes count: Int) -> UInt16