From b28f855bd4c51f947bc0f0ece890f3ed02e554e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 24 Sep 2015 08:29:39 +0200 Subject: [PATCH] MetalType documentation --- GRDB/Core/Protocols/MetalType.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/GRDB/Core/Protocols/MetalType.swift b/GRDB/Core/Protocols/MetalType.swift index 98cb67763..5e82ac863 100644 --- a/GRDB/Core/Protocols/MetalType.swift +++ b/GRDB/Core/Protocols/MetalType.swift @@ -1,14 +1,27 @@ /** -TODO +When a type adopts both DatabaseValueConvertible and MetalType, it is granted +with faster access to the SQLite database values. */ public protocol MetalType { /** Returns an instance initialized from a raw SQLite statement pointer. + As an example, here is the how Int64 adopts MetalType: + + extension Int64: MetalType { + public init(sqliteStatement: SQLiteStatement, index: Int32) { + self = sqlite3_column_int64(sqliteStatement, index) + } + } + + Implement this method in an optimistic mind: don't check for NULL, don't + check for type mismatch. + + See https://www.sqlite.org/c3ref/column_blob.html for more information. + - parameter sqliteStatement: A pointer to a SQLite statement. - parameter index: The column index. */ init(sqliteStatement: SQLiteStatement, index: Int32) - }