-
Notifications
You must be signed in to change notification settings - Fork 104
/
SingleValueDecodingContainer.swift
57 lines (44 loc) · 1.53 KB
/
SingleValueDecodingContainer.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// SingleValueDecodingContainer.swift
// XMLCoder
//
// Created by Shawn Moore on 11/20/17.
// Copyright © 2017 Shawn Moore. All rights reserved.
//
import Foundation
extension XMLDecoderImplementation: SingleValueDecodingContainer {
// MARK: SingleValueDecodingContainer Methods
public func decodeNil() -> Bool {
return (try? topContainer().isNull) ?? true
}
public func decode(_: Bool.Type) throws -> Bool {
return try unbox(try topContainer())
}
public func decode(_: Decimal.Type) throws -> Decimal {
return try unbox(try topContainer())
}
public func decode<T: BinaryInteger & SignedInteger & Decodable>(_: T.Type) throws -> T {
return try unbox(try topContainer())
}
public func decode<T: BinaryInteger & UnsignedInteger & Decodable>(_: T.Type) throws -> T {
return try unbox(try topContainer())
}
public func decode(_: Float.Type) throws -> Float {
return try unbox(try topContainer())
}
public func decode(_: Double.Type) throws -> Double {
return try unbox(try topContainer())
}
public func decode(_: String.Type) throws -> String {
return try unbox(try topContainer())
}
public func decode(_: String.Type) throws -> Date {
return try unbox(try topContainer())
}
public func decode(_: String.Type) throws -> Data {
return try unbox(try topContainer())
}
public func decode<T: Decodable>(_: T.Type) throws -> T {
return try unbox(try topContainer())
}
}