this repo has no description
at main 105 lines 2.5 kB view raw
1// 2// DecodingPrimitiveValue.swift 3// URLQueryItemCoder 4// 5// Created by Kyle Hughes on 1/19/23. 6// 7 8internal protocol DecodingPrimitiveValue { 9 func decode(_ type: Bool.Type) -> Bool? 10 func decode(_ type: Double.Type) -> Double? 11 func decode(_ type: Float.Type) -> Float? 12 func decode(_ type: Int.Type) -> Int? 13 func decode(_ type: Int8.Type) -> Int8? 14 func decode(_ type: Int16.Type) -> Int16? 15 func decode(_ type: Int32.Type) -> Int32? 16 func decode(_ type: Int64.Type) -> Int64? 17 func decode(_ type: String.Type) -> String? 18 func decode(_ type: UInt.Type) -> UInt? 19 func decode(_ type: UInt8.Type) -> UInt8? 20 func decode(_ type: UInt16.Type) -> UInt16? 21 func decode(_ type: UInt32.Type) -> UInt32? 22 func decode(_ type: UInt64.Type) -> UInt64? 23 func decodeNil() -> Bool 24} 25 26// MARK: - Conformance for String 27 28extension String: DecodingPrimitiveValue { 29 // MARK: Internal Instance Interface 30 31 @inlinable 32 internal func decode(_ type: Bool.Type) -> Bool? { 33 type.init(self) 34 } 35 36 @inlinable 37 internal func decode(_ type: Double.Type) -> Double? { 38 type.init(self) 39 } 40 41 @inlinable 42 internal func decode(_ type: Float.Type) -> Float? { 43 type.init(self) 44 } 45 46 @inlinable 47 internal func decode(_ type: Int.Type) -> Int? { 48 type.init(self) 49 } 50 51 @inlinable 52 internal func decode(_ type: Int8.Type) -> Int8? { 53 type.init(self) 54 } 55 56 @inlinable 57 internal func decode(_ type: Int16.Type) -> Int16? { 58 type.init(self) 59 } 60 61 @inlinable 62 internal func decode(_ type: Int32.Type) -> Int32? { 63 type.init(self) 64 } 65 66 @inlinable 67 internal func decode(_ type: Int64.Type) -> Int64? { 68 type.init(self) 69 } 70 71 @inlinable 72 internal func decode(_ type: String.Type) -> String? { 73 self 74 } 75 76 @inlinable 77 internal func decode(_ type: UInt.Type) -> UInt? { 78 type.init(self) 79 } 80 81 @inlinable 82 internal func decode(_ type: UInt8.Type) -> UInt8? { 83 type.init(self) 84 } 85 86 @inlinable 87 internal func decode(_ type: UInt16.Type) -> UInt16? { 88 type.init(self) 89 } 90 91 @inlinable 92 internal func decode(_ type: UInt32.Type) -> UInt32? { 93 type.init(self) 94 } 95 96 @inlinable 97 internal func decode(_ type: UInt64.Type) -> UInt64? { 98 type.init(self) 99 } 100 101 @inlinable 102 internal func decodeNil() -> Bool { 103 false 104 } 105}