Functions

The following functions are available globally.

  • Get a keyed decoding container using a coding key

    Throws

    DecodingError.typeMismatch if the encountered stored value is not a keyed container.

    Declaration

    Swift

    public func ~~> <K: CodingKey>(decoder: Decoder,
                                   keyType: K.Type) throws -> KeyedDecodingContainer<K>

    Parameters

    decoder

    The decoder

    keyType

    The key type

    Return Value

    A keyed container

  • Decode a value or object

    Throws

    DecodingError.typeMismatch if the encountered encoded value is not convertible to the requested type.

    Declaration

    Swift

    public func *> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> O where O : Decodable, K : CodingKey

    Return Value

    The value or object

  • Decode a optional value or object

    Throws

    DecodingError.typeMismatch if the encountered encoded value is not convertible to the requested type.

    Declaration

    Swift

    public func ?*> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> O? where O : Decodable, K : CodingKey

    Return Value

    The value or object

  • Decode an array

    Throws

    DecodingError.typeMismatch if the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.

    Throws

    DecodingError.valueNotFound if the encountered encoded value is null, or of there are no more values to decode.

    Declaration

    Swift

    public func **> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> [O] where O : Decodable, K : CodingKey

    Parameters

    container

    The container

    key

    The coding key

    Return Value

    An array of objects

  • Decode an array

    Throws

    DecodingError.typeMismatch if the encountered stored value is not an unkeyed container or a contained object doesn’t match the object type.

    Throws

    DecodingError.valueNotFound if the encountered encoded value is null, or of there are no more values to decode.

    Declaration

    Swift

    public func ?**> <O, K>(container: KeyedDecodingContainer<K>, key: K) throws -> [O]? where O : Decodable, K : CodingKey

    Parameters

    container

    The container

    key

    The coding key

    Return Value

    An array of objects

  • Get a keyed encoding container using a coding key

    Declaration

    Swift

    public func ~~> <K>(encoder: Encoder, keyType: K.Type) -> KeyedEncodingContainer<K> where K : CodingKey

    Parameters

    encoder

    The encoder

    keyType

    The key type

    Return Value

    A keyed container

  • Combine a coding key and a coding value

    Declaration

    Swift

    public func <~~ <O, K>(key: K, value: O?) -> (key: K, value: O?) where O : Encodable, K : CodingKey

    Parameters

    key

    The coding key

    object

    The coding value

    Return Value

    The coding pair

  • Encode a value

    Throws

    EncodingError.invalidValue if the given value is invalid in the current context for this format.

    Declaration

    Swift

    public func <* <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>,
                                                pair: (key: K, value: O?)) throws

    Parameters

    container

    The encoding container

    pair

    The key value pair that need to be encoded

  • Encode an optional value

    Throws

    EncodingError.invalidValue if the given value is invalid in the current context for this format.

    Declaration

    Swift

    public func <*? <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>,
                                                 pair: (key: K, value: O?)) throws

    Parameters

    container

    The encoding container

    pair

    The key value pair that need to be encoded

  • Encode an array

    Throws

    EncodingError.invalidValue if the given value is invalid in the current context for this format.

    Declaration

    Swift

    public func <** <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>,
                                                 pair: (key: K, value: [O]?)) throws

    Parameters

    container

    The encoding container

    pair

    The key value pair that need to be encoded

  • Encode an optional array

    Throws

    EncodingError.invalidValue if the given value is invalid in the current context for this format.

    Declaration

    Swift

    public func <**? <O: Encodable, K: CodingKey>(container: KeyedEncodingContainer<K>,
                                                  pair: (key: K, value: [O]?)) throws

    Parameters

    container

    The encoding container

    pair

    The key value pair that need to be encoded

  • Compare a string to a regex.

    Declaration

    Swift

    public func ~= (regex: String, string: String) -> Bool

    Parameters

    string

    The string to be compared.

    pattern

    The regex to be used

    Return Value

    Whether the regex can be found in the string or not.