From 1e25debefc6c5dc380ad03e70c4128da54addb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 19 Aug 2018 07:31:09 +0200 Subject: [PATCH] Done --- GRDB/Record/FetchableRecord+Decodable.swift | 14 -------------- GRDB/Record/PersistableRecord+Encodable.swift | 12 ++++++------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/GRDB/Record/FetchableRecord+Decodable.swift b/GRDB/Record/FetchableRecord+Decodable.swift index 3ba5fdb6a..9cb05eef4 100644 --- a/GRDB/Record/FetchableRecord+Decodable.swift +++ b/GRDB/Record/FetchableRecord+Decodable.swift @@ -88,14 +88,6 @@ private struct RowDecoder: Decoder { return nil } - /// Decodes a value of the given type for the given key. - /// - /// - parameter type: The type of value to decode. - /// - parameter key: The key that the decoded value is associated with. - /// - 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.keyNotFound` if `self` does not have an entry for the given key. - /// - throws: `DecodingError.valueNotFound` if `self` has a null entry for the given key. func decode(_ type: T.Type, forKey key: Key) throws -> T where T : Decodable { let row = decoder.row let keyName = key.stringValue @@ -151,12 +143,6 @@ private struct RowDecoder: Decoder { return try decode(type, fromRow: row, codingPath: codingPath + [key]) } - /// Returns the data stored for the given key as represented in a container keyed by the given key type. - /// - /// - parameter type: The key type to use for the container. - /// - parameter key: The key that the nested container is associated with. - /// - returns: A keyed decoding container view into `self`. - /// - throws: `DecodingError.typeMismatch` if the encountered stored value is not a keyed container. func nestedContainer(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer where NestedKey : CodingKey { fatalError("not implemented") } diff --git a/GRDB/Record/PersistableRecord+Encodable.swift b/GRDB/Record/PersistableRecord+Encodable.swift index 0eb3fe01b..046e0272b 100644 --- a/GRDB/Record/PersistableRecord+Encodable.swift +++ b/GRDB/Record/PersistableRecord+Encodable.swift @@ -13,6 +13,12 @@ private class RecordEncoder: Encoder { _persistenceContainer = PersistenceContainer() } + /// Helper method + @inline(__always) + fileprivate func encode(_ value: DatabaseValueConvertible?, forKey key: CodingKey) { + _persistenceContainer[key.stringValue] = value + } + func container(keyedBy type: Key.Type) -> KeyedEncodingContainer { let container = KeyedContainer(recordEncoder: self) return KeyedEncodingContainer(container) @@ -37,12 +43,6 @@ private class RecordEncoder: Encoder { fatalError("single value encoding is not supported") } - /// Helper method - @inline(__always) - fileprivate func encode(_ value: DatabaseValueConvertible?, forKey key: CodingKey) { - _persistenceContainer[key.stringValue] = value - } - private struct KeyedContainer : KeyedEncodingContainerProtocol { var recordEncoder: RecordEncoder var userInfo: [CodingUserInfoKey: Any] { return Record.databaseEncodingUserInfo }