ByteReader
public protocol ByteReader : AnyObject
A type that contains functions for reading Data
byte-by-byte.
-
Size of the
data
(in bytes).Declaration
Swift
var size: Int { get }
-
Data which is being read.
Declaration
Swift
var data: Data { get }
-
Offset to a byte in the
data
which will be read next.Declaration
Swift
var offset: Int { get set }
-
Creates an instance for reading bytes from the
data
.Declaration
Swift
init(data: Data)
-
Reads a byte and returns it, advancing by one position.
Declaration
Swift
func byte() -> UInt8
-
Reads
count
bytes and returns them as a[UInt8]
array, advancing bycount
positions.Declaration
Swift
func bytes(count: Int) -> [UInt8]
-
int(fromBytes:
Default implementation) Reads
fromBytes
bytes and returns them as aInt
number, advancing byfromBytes
positions.Default Implementation
Reads
fromBytes
bytes by either usinguint64(fromBytes:)
oruint32(fromBytes:)
depending on the platform’s integer bit width, converts the result toInt
, and returns it, advancing byfromBytes
positions.Declaration
Swift
func int(fromBytes count: Int) -> Int
-
Reads
fromBytes
bytes and returns them as aUInt64
number, advancing byfromBytes
positions.Declaration
Swift
func uint64(fromBytes count: Int) -> UInt64
-
Reads
fromBytes
bytes and returns them as aUInt32
number, advancing byfromBytes
positions.Declaration
Swift
func uint32(fromBytes count: Int) -> UInt32
-
Reads
fromBytes
bytes and returns them as aUInt16
number, advancing byfromBytes
positions.Declaration
Swift
func uint16(fromBytes count: Int) -> UInt16
-
init(_:
Extension method) Declaration
Swift
public init(_ bitReader: BitReader)
-
bytesLeft
Extension methodAmount of bytes left to read.
Declaration
Swift
public var bytesLeft: Int { get }
-
bytesRead
Extension methodAmount of bytes that were already read.
Declaration
Swift
public var bytesRead: Int { get }
-
isFinished
Extension method