ByteArrayParser

internal struct ByteArrayParser : Parser

Parse byte arrays, which are [UInt8]

  • The source [UInt8] to parse

    Declaration

    Swift

    var source: [UInt8]
  • The type of encoding used

    Warning

    Only tested with .utf8 use other encodings at your own risk

    Declaration

    Swift

    var encoding: String.Encoding
  • Current reader index

    Declaration

    Swift

    var readerIndex: Int
  • Initalize with source

    Declaration

    Swift

    init(source: [UInt8])

    Parameters

    source

    The source to parse

  • Initalize with source and encoding

    Declaration

    Swift

    init(source: [UInt8], encoding: String.Encoding)

    Parameters

    source

    The source to parse

    encoding

    The encoding to use

  • Parse the source

    Declaration

    Swift

    mutating func parse() -> [Line]

    Return Value

    [Line]

  • Determines how to parse the next line

    Declaration

    Swift

    private mutating func parseNext() -> Line?

    Return Value

    Line?

  • Skip a comment line

    Declaration

    Swift

    private mutating func skipComment()
  • Parse the line

    Declaration

    Swift

    private mutating func parseLine() -> Line?

    Return Value

    Line?

  • Parse the value side of the key=value pair

    Declaration

    Swift

    private mutating func parseLineValue() -> String?

    Return Value

    String?

  • Skip spaces until another character is found

    Declaration

    Swift

    private mutating func skipSpaces()
  • Take a look at the next character to read without moving the readerIndex

    Declaration

    Swift

    private func peek() -> UInt8?

    Return Value

    UInt8?

  • Read the next character

    Declaration

    Swift

    @discardableResult
    private mutating func pop() -> UInt8?

    Return Value

    UInt8?

  • Count the distance to the next occurrence of byte

    Declaration

    Swift

    private func countDistance(to byte: UInt8) -> Int?

    Return Value

    Int?

  • Read the input length from source moving readerIndex

    Declaration

    Swift

    private mutating func reader(length: Int) -> ArraySlice<UInt8>?