AnyBSON
@frozen
public enum AnyBSON : BSON
extension AnyBSON: ExpressibleByStringLiteral
extension AnyBSON: ExpressibleByBooleanLiteral
extension AnyBSON: ExpressibleByFloatLiteral
extension AnyBSON: ExpressibleByIntegerLiteral
extension AnyBSON: ExpressibleByDictionaryLiteral
extension AnyBSON: ExpressibleByArrayLiteral
extension AnyBSON: Equatable
extension AnyBSON: Hashable
Enum representing a BSON value.
See also
bsonspec.org-
A BSON double.
Declaration
Swift
case double(Double)
-
A BSON string.
Declaration
Swift
case string(String)
-
A BSON document.
Declaration
Swift
indirect case document(Document)
-
A BSON array.
Declaration
Swift
indirect case array([AnyBSON?])
-
A BSON binary.
Declaration
Swift
case binary(Data)
-
A BSON ObjectId.
Declaration
Swift
case objectId(ObjectId)
-
A BSON boolean.
Declaration
Swift
case bool(Bool)
-
A BSON UTC datetime.
Declaration
Swift
case datetime(Date)
-
A BSON regular expression.
Declaration
Swift
case regex(NSRegularExpression)
-
A BSON int32.
Declaration
Swift
case int32(Int32)
-
A BSON timestamp.
Declaration
Swift
case timestamp(Date)
-
A BSON int64.
Declaration
Swift
case int64(Int64)
-
A BSON Decimal128.
Declaration
Swift
case decimal128(Decimal128)
-
A UUID.
Declaration
Swift
case uuid(UUID)
-
A BSON minKey.
Declaration
Swift
case minKey
-
A BSON maxKey.
Declaration
Swift
case maxKey
-
A BSON null type.
Declaration
Swift
case null
-
Initialize a
BSON
from an integer. On 64-bit systems, this will result in an.int64
. On 32-bit systems, this will result in an.int32
.Declaration
Swift
public init(_ int: Int)
-
If this
BSON
is an.int32
, return it as anInt32
. Otherwise, return nil.Declaration
Swift
public var int32Value: Int32? { get }
-
If this
BSON
is a.regex
, return it as aRegularExpression
. Otherwise, return nil.Declaration
Swift
public var regexValue: NSRegularExpression? { get }
-
If this
BSON
is an.int64
, return it as anInt64
. Otherwise, return nil.Declaration
Swift
public var int64Value: Int64? { get }
-
Declaration
Swift
public var objectIdValue: ObjectId? { get }
-
If this
BSON
is a.date
, return it as aDate
. Otherwise, return nil.Declaration
Swift
public var dateValue: Date? { get }
-
If this
BSON
is an.array
, return it as an[BSON]
. Otherwise, return nil.Declaration
Swift
public var arrayValue: [AnyBSON?]? { get }
-
If this
BSON
is a.string
, return it as aString
. Otherwise, return nil.Declaration
Swift
public var stringValue: String? { get }
-
Declaration
Swift
public var documentValue: Document? { get }
-
If this
BSON
is a.bool
, return it as anBool
. Otherwise, return nil.Declaration
Swift
public var boolValue: Bool? { get }
-
If this
BSON
is a.binary
, return it as aBinary
. Otherwise, return nil.Declaration
Swift
public var binaryValue: Data? { get }
-
If this
BSON
is a.double
, return it as aDouble
. Otherwise, return nil.Declaration
Swift
public var doubleValue: Double? { get }
-
If this
BSON
is a.decimal128
, return it as aDecimal128
. Otherwise, return nil.Declaration
Swift
public var decimal128Value: Decimal128? { get }
-
If this
BSON
is a.timestamp
, return it as aTimestamp
. Otherwise, return nil.Declaration
Swift
public var timestampValue: Date? { get }
-
If this
BSON
is a.uuid
, return it as aUUID
. Otherwise, return nil.Declaration
Swift
public var uuidValue: UUID? { get }
-
Declaration
Swift
public var isNull: Bool { get }
-
Return this BSON as an
Int
if possible. This will coerce non-integer numeric cases (e.g..double
) into anInt
if such coercion would be lossless.Declaration
Swift
public func asInt() -> Int?
-
Return this BSON as an
Int32
if possible. This will coerce numeric cases (e.g..double
) into anInt32
if such coercion would be lossless.Declaration
Swift
public func asInt32() -> Int32?
-
Return this BSON as an
Int64
if possible. This will coerce numeric cases (e.g..double
) into anInt64
if such coercion would be lossless.Declaration
Swift
public func asInt64() -> Int64?
-
Return this BSON as a
Double
if possible. This will coerce numeric cases (e.g..decimal128
) into aDouble
if such coercion would be lossless.Declaration
Swift
public func asDouble() -> Double?
-
Return this BSON as a
Decimal128
if possible. This will coerce numeric cases (e.g..double
) into aDecimal128
if such coercion would be lossless.Declaration
Swift
public func asDecimal128() -> Decimal128?
-
Return this BSON as a
T
if possible, otherwise nil.Declaration
Swift
public func value<T>() -> T? where T : BSON
-
Declaration
Swift
public init(stringLiteral value: String)
-
Declaration
Swift
public init(booleanLiteral value: Bool)
-
Declaration
Swift
public init(floatLiteral value: Double)
-
Initialize a
BSON
from an integer. On 64-bit systems, this will result in an.int64
. On 32-bit systems, this will result in an.int32
.Declaration
Swift
public init(integerLiteral value: Int)
-
Declaration
Swift
public init(dictionaryLiteral elements: (String, AnyBSON?)...)
-
Declaration
Swift
public init(arrayLiteral elements: AnyBSON?...)