From 5334dcd7695bfe4b729936ed17a7c0d6dd375fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 11 Jul 2015 10:50:56 +0200 Subject: [PATCH] Documentation WIP --- GRDB/Configuration.swift | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/GRDB/Configuration.swift b/GRDB/Configuration.swift index b709b0478..ef42b7314 100644 --- a/GRDB/Configuration.swift +++ b/GRDB/Configuration.swift @@ -27,6 +27,8 @@ Configuration are arguments to the DatabaseQueue initializers. */ public struct Configuration { + // MARK: - Utilities + /// A tracing function that logs SQL statements public static func logSQL(sql: String, bindings: Bindings?) { NSLog("GRDB: %@", sql) @@ -35,7 +37,14 @@ public struct Configuration { } } - /// A tracing function. + // MARK: - Configuration options + + /** + A tracing function. + + - parameter sql: An SQL query + - parameter bindings: Eventual bindings that hold SQL parameters. + */ public typealias TraceFunction = (sql: String, bindings: Bindings?) -> Void /// If true, the database has support for foreign keys. @@ -44,12 +53,23 @@ public struct Configuration { /// If true, the database is opened readonly. public var readonly: Bool - /// A tracing function that you can use for any purpose. + /** + An optional tracing function. + + You can use Configuration.logSQL as a tracing function: it logs all SQL + statements with NSLog(). + */ public var trace: TraceFunction? + + // MARK: - Initialization + /** Setup a configuration. + You can use Configuration.logSQL as a tracing function: it logs all SQL + statements with NSLog(). + - parameter foreignKeysEnabled: If true (the default), the database has support for foreign keys. - parameter readonly: If false (the default), the database will be @@ -65,6 +85,9 @@ public struct Configuration { self.trace = trace } + + // MARK: - Not public + var sqliteOpenFlags: Int32 { // See https://www.sqlite.org/c3ref/open.html return readonly ? SQLITE_OPEN_READONLY : (SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)