@@ -166,7 +166,7 @@ public final class Statement {
166166
167167 reset ( clearBindings: false )
168168 _ = try step ( )
169- return try row. getValue ( 0 )
169+ return try row. getValue ( 0 )
170170 }
171171
172172 /// - Parameter bindings: A list of parameters to bind to the statement.
@@ -259,83 +259,83 @@ extension Statement: CustomStringConvertible {
259259}
260260
261261public protocol CursorProtocol {
262- func getValue( _ idx: Int ) throws -> Binding ?
263- func getValue( _ idx: Int ) throws -> Double
264- func getValue( _ idx: Int ) throws -> Int64
265- func getValue( _ idx: Int ) throws -> String
266- func getValue( _ idx: Int ) throws -> Blob
262+ func getValue( _ idx: Int ) throws -> Binding ?
263+ func getValue( _ idx: Int ) throws -> Double
264+ func getValue( _ idx: Int ) throws -> Int64
265+ func getValue( _ idx: Int ) throws -> String
266+ func getValue( _ idx: Int ) throws -> Blob
267267}
268268
269269extension CursorProtocol {
270- public func getValue< T: Binding > ( _ idx: Int ) -> T ? {
271- switch T . self {
272- case is Double . Type :
273- return try ? getValue ( idx) as Double as? T
274- case is Int64 . Type :
275- return try ? getValue ( idx) as Int64 as? T
276- case is String . Type :
277- return try ? getValue ( idx) as String as? T
278- case is Blob . Type :
279- return try ? getValue ( idx) as Blob as? T
280- default :
281- return nil
282- }
283- }
284-
285- public func getValue( _ idx: Int ) throws -> Bool {
286- try Bool . fromDatatypeValue ( getValue ( idx) )
287- }
288-
289- public func getValue( _ idx: Int ) throws -> Int {
290- try Int . fromDatatypeValue ( getValue ( idx) )
291- }
270+ public func getValue< T: Binding > ( _ idx: Int ) -> T ? {
271+ switch T . self {
272+ case is Double . Type :
273+ return try ? getValue ( idx) as Double as? T
274+ case is Int64 . Type :
275+ return try ? getValue ( idx) as Int64 as? T
276+ case is String . Type :
277+ return try ? getValue ( idx) as String as? T
278+ case is Blob . Type :
279+ return try ? getValue ( idx) as Blob as? T
280+ default :
281+ return nil
282+ }
283+ }
284+
285+ public func getValue( _ idx: Int ) throws -> Bool {
286+ try Bool . fromDatatypeValue ( getValue ( idx) )
287+ }
288+
289+ public func getValue( _ idx: Int ) throws -> Int {
290+ try Int . fromDatatypeValue ( getValue ( idx) )
291+ }
292292}
293293
294294struct CursorWithBindingArray : CursorProtocol {
295- let elements : [ Binding ? ]
296- init ( elements: [ Binding ? ] ) {
297- self . elements = elements
298- }
299-
300- func getValue( _ idx: Int ) throws -> Binding ? {
301- elements [ idx]
302- }
303- func getValue( _ idx: Int ) throws -> Double {
304- guard let value = elements [ idx] as? Double else {
305- throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
306- }
307- return value
308- }
309- func getValue( _ idx: Int ) throws -> Int64 {
310- guard let value = elements [ idx] as? Int64 else {
311- throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
312- }
313- return value
314- }
315- func getValue( _ idx: Int ) throws -> String {
316- guard let value = elements [ idx] as? String else {
317- throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
318- }
319- return value
320- }
321- func getValue( _ idx: Int ) throws -> Blob {
322- guard let value = elements [ idx] as? Blob else {
323- throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
324- }
325- return value
326- }
295+ let elements : [ Binding ? ]
296+ init ( elements: [ Binding ? ] ) {
297+ self . elements = elements
298+ }
299+
300+ func getValue( _ idx: Int ) throws -> Binding ? {
301+ elements [ idx]
302+ }
303+ func getValue( _ idx: Int ) throws -> Double {
304+ guard let value = elements [ idx] as? Double else {
305+ throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
306+ }
307+ return value
308+ }
309+ func getValue( _ idx: Int ) throws -> Int64 {
310+ guard let value = elements [ idx] as? Int64 else {
311+ throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
312+ }
313+ return value
314+ }
315+ func getValue( _ idx: Int ) throws -> String {
316+ guard let value = elements [ idx] as? String else {
317+ throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
318+ }
319+ return value
320+ }
321+ func getValue( _ idx: Int ) throws -> Blob {
322+ guard let value = elements [ idx] as? Blob else {
323+ throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
324+ }
325+ return value
326+ }
327327}
328328
329329public struct Cursor : CursorProtocol {
330330 fileprivate let statement : Statement
331- fileprivate var handle : OpaquePointer {
332- statement. handle!
333- }
331+ fileprivate var handle : OpaquePointer {
332+ statement. handle!
333+ }
334334
335335 fileprivate let columnCount : Int
336336
337337 fileprivate init ( _ statement: Statement ) {
338- self . statement = statement
338+ self . statement = statement
339339 columnCount = statement. columnCount
340340 }
341341
@@ -348,9 +348,9 @@ public struct Cursor: CursorProtocol {
348348 }
349349
350350 public func getValue( _ idx: Int ) throws -> String {
351- guard let text = sqlite3_column_text ( handle, Int32 ( idx) ) else {
352- throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
353- }
351+ guard let text = sqlite3_column_text ( handle, Int32 ( idx) ) else {
352+ throw QueryError . unexpectedNullValue ( name: " column at index \( idx) " )
353+ }
354354 return String ( cString: UnsafePointer ( text) )
355355 }
356356
0 commit comments