protocol
UnkeyedDecodingContainer
Import |
|
---|
Instance Variables
The path of coding keys taken to get to this point in decoding.
Declaration
var
codingPath
: [
CodingKey
] {
get
}
The number of elements contained within this container.
If the number of elements is unknown, the value is nil
.
Declaration
var
count
:
Int
? {
get
}
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
{
get
}
A Boolean value indicating whether there are no more elements left to be decoded in the container.
Declaration
var
isAtEnd
:
Bool
{
get
}
Instance Methods
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Bool
.
Type
)
throws
-
>
Bool
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Double
.
Type
)
throws
-
>
Double
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Float
.
Type
)
throws
-
>
Float
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Int
.
Type
)
throws
-
>
Int
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Int8
.
Type
)
throws
-
>
Int8
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Int16
.
Type
)
throws
-
>
Int16
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Int32
.
Type
)
throws
-
>
Int32
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
Int64
.
Type
)
throws
-
>
Int64
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
String
.
Type
)
throws
-
>
String
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt
.
Type
)
throws
-
>
UInt
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt8
.
Type
)
throws
-
>
UInt8
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt16
.
Type
)
throws
-
>
UInt16
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt32
.
Type
)
throws
-
>
UInt32
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
(
_
type
:
UInt64
.
Type
)
throws
-
>
UInt64
Decodes a value of the given type.
type
: The type of value to decode.
returns: A value of the requested type, if present for the given key
and convertible to the requested type.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
decode
<
T
>
(
_
type
:
T
.
Type
)
throws
-
>
T
where
T
:
Decodable
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Bool
.
Type
)
throws
-
>
Bool
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Double
.
Type
)
throws
-
>
Double
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Float
.
Type
)
throws
-
>
Float
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int
.
Type
)
throws
-
>
Int
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int8
.
Type
)
throws
-
>
Int8
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int16
.
Type
)
throws
-
>
Int16
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int32
.
Type
)
throws
-
>
Int32
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int64
.
Type
)
throws
-
>
Int64
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
String
.
Type
)
throws
-
>
String
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt
.
Type
)
throws
-
>
UInt
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt8
.
Type
)
throws
-
>
UInt8
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt16
.
Type
)
throws
-
>
UInt16
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt32
.
Type
)
throws
-
>
UInt32
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt64
.
Type
)
throws
-
>
UInt64
?
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
.
type
: The type of value to decode.
returns: A decoded value of the requested type, or nil
if the value
is a null value, or if there are no more elements to decode.
throws: DecodingError.typeMismatch
if the encountered encoded value
is not convertible to the requested type.
Declaration
mutating
func
decodeIfPresent
<
T
>
(
_
type
:
T
.
Type
)
throws
-
>
T
?
where
T
:
Decodable
Decodes a null value.
If the value is not null, does not increment currentIndex.
returns: Whether the encountered value was null.
throws: DecodingError.valueNotFound
if there are no more values to
decode.
Declaration
mutating
func
decodeNil
()
throws
-
>
Bool
Decodes a nested container keyed by the given type.
type
: The key type to use for the container.
returns: A keyed decoding container view into self
.
throws: DecodingError.typeMismatch
if the encountered stored value is
not a keyed container.
Declaration
mutating
func
nestedContainer
<
NestedKey
>
(
keyedBy
type
:
NestedKey
.
Type
)
throws
-
>
KeyedDecodingContainer
<
NestedKey
>
where
NestedKey
:
CodingKey
Decodes an unkeyed nested container.
returns: An unkeyed decoding container view into self
.
throws: DecodingError.typeMismatch
if the encountered stored value is
not an unkeyed container.
Declaration
mutating
func
nestedUnkeyedContainer
()
throws
-
>
UnkeyedDecodingContainer
Decodes a nested container and returns a Decoder
instance for decoding
super
from that container.
returns: A new Decoder
to pass to super.init(from:)
.
throws: DecodingError.valueNotFound
if the encountered encoded value
is null, or of there are no more values to decode.
Declaration
mutating
func
superDecoder
()
throws
-
>
Decoder
Default Implementations
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Bool
.
Type
)
throws
-
>
Bool
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Double
.
Type
)
throws
-
>
Double
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Float
.
Type
)
throws
-
>
Float
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int
.
Type
)
throws
-
>
Int
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int8
.
Type
)
throws
-
>
Int8
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int16
.
Type
)
throws
-
>
Int16
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int32
.
Type
)
throws
-
>
Int32
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
Int64
.
Type
)
throws
-
>
Int64
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
String
.
Type
)
throws
-
>
String
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt
.
Type
)
throws
-
>
UInt
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt8
.
Type
)
throws
-
>
UInt8
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt16
.
Type
)
throws
-
>
UInt16
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt32
.
Type
)
throws
-
>
UInt32
?
Declaration
mutating
func
decodeIfPresent
(
_
type
:
UInt64
.
Type
)
throws
-
>
UInt64
?
Declaration
mutating
func
decodeIfPresent
<
T
>
(
_
type
:
T
.
Type
)
throws
-
>
T
?
where
T
:
Decodable
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.