mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Done
This commit is contained in:
1 parent
97d77e871b
commit
1e25debefc
2 files changed
+6
-20
No files matched your search
@@ -88,14 +88,6 @@ private struct RowDecoder<Record: FetchableRecord>: 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<T>(_ 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<Record: FetchableRecord>: 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<NestedKey>(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer<NestedKey> where NestedKey : CodingKey {
|
||||
fatalError("not implemented")
|
||||
}
|
||||
|
||||
@@ -13,6 +13,12 @@ private class RecordEncoder<Record: MutablePersistableRecord>: Encoder {
|
||||
_persistenceContainer = PersistenceContainer()
|
||||
}
|
||||
|
||||
/// Helper method
|
||||
@inline(__always)
|
||||
fileprivate func encode(_ value: DatabaseValueConvertible?, forKey key: CodingKey) {
|
||||
_persistenceContainer[key.stringValue] = value
|
||||
}
|
||||
|
||||
func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> {
|
||||
let container = KeyedContainer<Key>(recordEncoder: self)
|
||||
return KeyedEncodingContainer(container)
|
||||
@@ -37,12 +43,6 @@ private class RecordEncoder<Record: MutablePersistableRecord>: 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<Key: CodingKey> : KeyedEncodingContainerProtocol {
|
||||
var recordEncoder: RecordEncoder
|
||||
var userInfo: [CodingUserInfoKey: Any] { return Record.databaseEncodingUserInfo }
|
||||
|
||||
Reference in new issue
Block a user