Refactor entire codebase and rewrite documentation
This commit is contained in:
@@ -1,28 +1,27 @@
|
||||
import Foundation
|
||||
|
||||
extension Bool: SQLiteRawRepresentable {
|
||||
/// Provides the `SQLiteRawValue` representation for boolean types.
|
||||
extension Bool: SQLiteRepresentable {
|
||||
/// Converts a Boolean value to its SQLite representation.
|
||||
///
|
||||
/// This implementation converts the boolean value to an `SQLiteRawValue` of type `.int`.
|
||||
/// - `true` is represented as `1`.
|
||||
/// - `false` is represented as `0`.
|
||||
/// Boolean values are stored in SQLite as integers (`INTEGER` type). The value `true` is
|
||||
/// represented as `1`, and `false` as `0`.
|
||||
///
|
||||
/// - Returns: An `SQLiteRawValue` of type `.int`, containing `1` for `true` and `0` for `false`.
|
||||
public var sqliteRawValue: SQLiteRawValue {
|
||||
/// - Returns: An ``SQLiteValue`` of type `.int`, containing `1` for `true`
|
||||
/// and `0` for `false`.
|
||||
public var sqliteValue: SQLiteValue {
|
||||
.int(self ? 1 : 0)
|
||||
}
|
||||
|
||||
/// Initializes an instance of the conforming type from an `SQLiteRawValue`.
|
||||
/// Creates a Boolean value from an SQLite representation.
|
||||
///
|
||||
/// This initializer handles `SQLiteRawValue` of type `.int`, converting it to a boolean value.
|
||||
/// - `1` is converted to `true`.
|
||||
/// - `0` is converted to `false`.
|
||||
/// This initializer supports the ``SQLiteValue/int(_:)`` case and converts the integer value to
|
||||
/// a Boolean. `1` is interpreted as `true`, `0` as `false`. If the integer is not `0` or `1`,
|
||||
/// the initializer returns `nil`.
|
||||
///
|
||||
/// If the integer value is not `0` or `1`, the initializer returns `nil`.
|
||||
///
|
||||
/// - Parameter sqliteRawValue: The raw SQLite value used to initialize the instance.
|
||||
public init?(_ sqliteRawValue: SQLiteRawValue) {
|
||||
switch sqliteRawValue {
|
||||
/// - Parameter value: The SQLite value to convert from.
|
||||
/// - Returns: A Boolean value if the conversion succeeds, or `nil` otherwise.
|
||||
public init?(_ value: SQLiteValue) {
|
||||
switch value {
|
||||
case .int(let value) where value == 0 || value == 1:
|
||||
self = value == 1
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user