UnkeyedDecodingContainer

protocol UnkeyedDecodingContainer

A type that provides a view into a decoder's storage and is used to hold the encoded properties of a decodable type sequentially, without keys.

Decoders should provide types conforming to UnkeyedDecodingContainer for their format.

Instance Variables

var codingPath Required

The path of coding keys taken to get to this point in decoding.

Declaration

var codingPath: [CodingKey]
var count Required

The number of elements contained within this container.

If the number of elements is unknown, the value is nil.

Declaration

var count: Int?
var currentIndex Required

The current decoding index of the container (i.e. the index of the next element to be decoded.) Incremented after every successful decode call.

Declaration

var currentIndex: Int
var isAtEnd Required

A Boolean value indicating whether there are no more elements left to be decoded in the container.

Declaration

var isAtEnd: Bool

Instance Methods

func decode(_ type: Bool.Type) throws -> Bool Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Bool.Type) throws -> Bool
func decode(_ type: String.Type) throws -> String Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: String.Type) throws -> String
func decode(_ type: Double.Type) throws -> Double Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Double.Type) throws -> Double
func decode(_ type: Float.Type) throws -> Float Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Float.Type) throws -> Float
func decode(_ type: Int.Type) throws -> Int Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Int.Type) throws -> Int
func decode(_ type: Int8.Type) throws -> Int8 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Int8.Type) throws -> Int8
func decode(_ type: Int16.Type) throws -> Int16 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Int16.Type) throws -> Int16
func decode(_ type: Int32.Type) throws -> Int32 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Int32.Type) throws -> Int32
func decode(_ type: Int64.Type) throws -> Int64 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: Int64.Type) throws -> Int64
func decode(_ type: UInt.Type) throws -> UInt Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: UInt.Type) throws -> UInt
func decode(_ type: UInt8.Type) throws -> UInt8 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: UInt8.Type) throws -> UInt8
func decode(_ type: UInt16.Type) throws -> UInt16 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: UInt16.Type) throws -> UInt16
func decode(_ type: UInt32.Type) throws -> UInt32 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: UInt32.Type) throws -> UInt32
func decode(_ type: UInt64.Type) throws -> UInt64 Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode(_ type: UInt64.Type) throws -> UInt64
func decode(_ type: T.Type) throws -> T Required

Decodes a value of the given type.

  • parameter type: The type of value to decode.

Declaration

mutating func decode<T>(_ type: T.Type) throws -> T where T: Decodable
func decodeIfPresent(_ type: Bool.Type) throws -> Bool? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Bool.Type) throws -> Bool?
func decodeIfPresent(_ type: String.Type) throws -> String? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: String.Type) throws -> String?
func decodeIfPresent(_ type: Double.Type) throws -> Double? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Double.Type) throws -> Double?
func decodeIfPresent(_ type: Float.Type) throws -> Float? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Float.Type) throws -> Float?
func decodeIfPresent(_ type: Int.Type) throws -> Int? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Int.Type) throws -> Int?
func decodeIfPresent(_ type: Int8.Type) throws -> Int8? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Int8.Type) throws -> Int8?
func decodeIfPresent(_ type: Int16.Type) throws -> Int16? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Int16.Type) throws -> Int16?
func decodeIfPresent(_ type: Int32.Type) throws -> Int32? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Int32.Type) throws -> Int32?
func decodeIfPresent(_ type: Int64.Type) throws -> Int64? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: Int64.Type) throws -> Int64?
func decodeIfPresent(_ type: UInt.Type) throws -> UInt? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: UInt.Type) throws -> UInt?
func decodeIfPresent(_ type: UInt8.Type) throws -> UInt8? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: UInt8.Type) throws -> UInt8?
func decodeIfPresent(_ type: UInt16.Type) throws -> UInt16? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: UInt16.Type) throws -> UInt16?
func decodeIfPresent(_ type: UInt32.Type) throws -> UInt32? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: UInt32.Type) throws -> UInt32?
func decodeIfPresent(_ type: UInt64.Type) throws -> UInt64? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent(_ type: UInt64.Type) throws -> UInt64?
func decodeIfPresent(_ type: T.Type) throws -> T? Required

Decodes a value of the given type, if present.

This method returns nil if the container has no elements left to decode, or if the value is null. The difference between these states can be distinguished by checking isAtEnd.

  • parameter type: The type of value to decode.

Declaration

mutating func decodeIfPresent<T>(_ type: T.Type) throws -> T? where T: Decodable
func decodeNil() throws -> Bool Required

Decodes a null value.

If the value is not null, does not increment currentIndex.

Declaration

mutating func decodeNil() throws -> Bool
func nestedContainer(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer<NestedKey> Required

Decodes a nested container keyed by the given type.

  • parameter type: The key type to use for the container.

Declaration

mutating func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer<NestedKey> where NestedKey: CodingKey
func nestedUnkeyedContainer() throws -> UnkeyedDecodingContainer Required

Decodes an unkeyed nested container.

Declaration

mutating func nestedUnkeyedContainer() throws -> UnkeyedDecodingContainer
func superDecoder() throws -> Decoder Required

Decodes a nested container and returns a Decoder instance for decoding super from that container.

Declaration

mutating func superDecoder() throws -> Decoder