LittleEndianByteReader
public final class LittleEndianByteReader : ByteReader
A type that contains functions for reading Data
byte-by-byte in the Little 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 bycount
positions.Precondition
Parametercount
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 aUInt64
number, advancing byfromBytes
positions.Note
If it is known that thefromBytes
is exactly 8 then consider using theuint64()
function (without an argument), since it may provide better performance.Precondition
ParameterfromBytes
must be in the0...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 aUInt32
number, advancing byfromBytes
positions.Note
If it is known that thefromBytes
is exactly 4 then consider using theuint32()
function (without an argument), since it may provide better performance.Precondition
ParameterfromBytes
must be in the0...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 aUInt16
number, advancing byfromBytes
positions.Note
If it is known that thefromBytes
is exactly 2 then consider using theuint16()
function (without an argument), since it may provide better performance.Precondition
ParameterfromBytes
must be in the0...2
range.Precondition
There must be enough bytes left.Declaration
Swift
public func uint16(fromBytes count: Int) -> UInt16