mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Main framework compiles on Linux
This commit is contained in:
1 parent
4f5fdf45e8
commit
55472c2d7f
9 files changed
+26
-3
No files matched your search
@@ -304,7 +304,7 @@ extension Database {
|
||||
let db = Unmanaged<Database>.fromOpaque(dbPointer!).takeUnretainedValue()
|
||||
db.configuration.trace!(sql)
|
||||
}, dbPointer)
|
||||
#else
|
||||
#elseif !os(Linux)
|
||||
if #available(iOS 10.0, OSX 10.12, watchOS 3.0, *) {
|
||||
sqlite3_trace_v2(sqliteConnection, UInt32(SQLITE_TRACE_STMT), { (mask, dbPointer, stmt, unexpandedSQL) -> Int32 in
|
||||
guard let stmt = stmt else { return SQLITE_OK }
|
||||
@@ -322,6 +322,12 @@ extension Database {
|
||||
db.configuration.trace!(sql)
|
||||
}, dbPointer)
|
||||
}
|
||||
#else
|
||||
sqlite3_trace(sqliteConnection, { (dbPointer, sql) in
|
||||
guard let sql = sql.map({ String(cString: $0) }) else { return }
|
||||
let db = Unmanaged<Database>.fromOpaque(dbPointer!).takeUnretainedValue()
|
||||
db.configuration.trace!(sql)
|
||||
}, dbPointer)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#if os(Linux)
|
||||
import Glibc
|
||||
#endif
|
||||
#if SWIFT_PACKAGE
|
||||
import CSQLite
|
||||
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if !os(Linux)
|
||||
import CoreGraphics
|
||||
|
||||
/// CGFloat adopts DatabaseValueConvertible
|
||||
@@ -16,3 +17,4 @@ extension CGFloat : DatabaseValueConvertible {
|
||||
return CGFloat(double)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@ import Foundation
|
||||
import SQLite3
|
||||
#endif
|
||||
|
||||
#if !os(Linux)
|
||||
/// NSDate is stored in the database using the format
|
||||
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
|
||||
extension NSDate : DatabaseValueConvertible {
|
||||
@@ -31,6 +32,7 @@ extension NSDate : DatabaseValueConvertible {
|
||||
return cast(date)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Date is stored in the database using the format
|
||||
/// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if !os(Linux)
|
||||
import Foundation
|
||||
|
||||
/// NSData is convertible to and from DatabaseValue.
|
||||
@@ -17,3 +18,4 @@ extension NSData : DatabaseValueConvertible {
|
||||
return cast(data)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#if !os(Linux)
|
||||
import Foundation
|
||||
|
||||
private let integerRoundingBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
|
||||
@@ -65,3 +66,4 @@ extension NSNumber : DatabaseValueConvertible {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
#if !os(Linux)
|
||||
import Foundation
|
||||
|
||||
/// NSString adopts DatabaseValueConvertible
|
||||
@@ -16,3 +17,4 @@ extension NSString : DatabaseValueConvertible {
|
||||
return self.init(string: string)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
#if !os(Linux)
|
||||
/// NSURL stores its absoluteString in the database.
|
||||
extension NSURL : DatabaseValueConvertible {
|
||||
|
||||
@@ -17,6 +18,7 @@ extension NSURL : DatabaseValueConvertible {
|
||||
return cast(URL(string: string))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// URL stores its absoluteString in the database.
|
||||
extension URL : DatabaseValueConvertible { }
|
||||
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
#if !os(Linux)
|
||||
/// NSUUID adopts DatabaseValueConvertible
|
||||
extension NSUUID : DatabaseValueConvertible {
|
||||
|
||||
@@ -8,18 +9,19 @@ extension NSUUID : DatabaseValueConvertible {
|
||||
var uuidBytes = ContiguousArray(repeating: UInt8(0), count: 16)
|
||||
return uuidBytes.withUnsafeMutableBufferPointer { buffer in
|
||||
getBytes(buffer.baseAddress!)
|
||||
return NSData(bytes: buffer.baseAddress, length: 16).databaseValue
|
||||
return Data(bytes: buffer.baseAddress, length: 16).databaseValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an NSUUID initialized from *dbValue*, if possible.
|
||||
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
|
||||
guard let data = NSData.fromDatabaseValue(dbValue), data.length == 16 else {
|
||||
guard let data = Data.fromDatabaseValue(dbValue), data.length == 16 else {
|
||||
return nil
|
||||
}
|
||||
return self.init(uuidBytes: data.bytes.assumingMemoryBound(to: UInt8.self))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// UUID adopts DatabaseValueConvertible
|
||||
extension UUID : DatabaseValueConvertible { }
|
||||
Reference in new issue
Block a user