|
| 1 | +/* |
| 2 | + * Copyright 2020 ObjectBox Ltd. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +// automatically generated by the FlatBuffers compiler, do not modify |
| 18 | +// swiftlint:disable all |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +/// Basic type of a property |
| 23 | +public enum PropertyType: UInt16 { |
| 24 | + public typealias T = UInt16 |
| 25 | + public static var byteSize: Int { return MemoryLayout<UInt16>.size } |
| 26 | + public var value: UInt16 { return self.rawValue } |
| 27 | + /// Not a real type, just best practice (e.g. forward compatibility) |
| 28 | + case unknown = 0 |
| 29 | + case bool = 1 |
| 30 | + case byte = 2 |
| 31 | + case short = 3 |
| 32 | + case char = 4 |
| 33 | + case int = 5 |
| 34 | + case long = 6 |
| 35 | + case float = 7 |
| 36 | + case double = 8 |
| 37 | + case string = 9 |
| 38 | + /// Date/time stored as a 64 bit long representing milliseconds since 1970-01-01 (unix epoch) |
| 39 | + case date = 10 |
| 40 | + /// Relation to another entity |
| 41 | + case relation = 11 |
| 42 | + /// High precision date/time stored as a 64 bit long representing nanoseconds since 1970-01-01 (unix epoch) |
| 43 | + case datenano = 12 |
| 44 | + case reserved2 = 13 |
| 45 | + case reserved3 = 14 |
| 46 | + case reserved4 = 15 |
| 47 | + case reserved5 = 16 |
| 48 | + case reserved6 = 17 |
| 49 | + case reserved7 = 18 |
| 50 | + case reserved8 = 19 |
| 51 | + case reserved9 = 20 |
| 52 | + case reserved10 = 21 |
| 53 | + case boolVector = 22 |
| 54 | + case byteVector = 23 |
| 55 | + case shortVector = 24 |
| 56 | + case charVector = 25 |
| 57 | + case intVector = 26 |
| 58 | + case longVector = 27 |
| 59 | + case floatVector = 28 |
| 60 | + case doubleVector = 29 |
| 61 | + case stringVector = 30 |
| 62 | + case dateVector = 31 |
| 63 | + case dateNanoVector = 32 |
| 64 | + |
| 65 | + |
| 66 | + public static var max: PropertyType { return .dateNanoVector } |
| 67 | + public static var min: PropertyType { return .unknown } |
| 68 | +} |
| 69 | + |
| 70 | +/// Bit-flags defining the behavior of properties. |
| 71 | +/// Note: Numbers indicate the bit position |
| 72 | +public enum PropertyFlags: UInt32 { |
| 73 | + public typealias T = UInt32 |
| 74 | + public static var byteSize: Int { return MemoryLayout<UInt32>.size } |
| 75 | + public var value: UInt32 { return self.rawValue } |
| 76 | + /// 64 bit long property (internally unsigned) representing the ID of the entity. |
| 77 | + /// May be combined with: NON_PRIMITIVE_TYPE, ID_MONOTONIC_SEQUENCE, ID_SELF_ASSIGNABLE. |
| 78 | + case id = 1 |
| 79 | + /// On languages like Java, a non-primitive type is used (aka wrapper types, allowing null) |
| 80 | + case nonPrimitiveType = 2 |
| 81 | + /// Unused yet |
| 82 | + case notNull = 4 |
| 83 | + case indexed = 8 |
| 84 | + /// Unused yet |
| 85 | + case reserved = 16 |
| 86 | + /// Unique index |
| 87 | + case unique = 32 |
| 88 | + /// Unused yet: Use a persisted sequence to enforce ID to rise monotonic (no ID reuse) |
| 89 | + case idMonotonicSequence = 64 |
| 90 | + /// Allow IDs to be assigned by the developer |
| 91 | + case idSelfAssignable = 128 |
| 92 | + /// Unused yet |
| 93 | + case indexPartialSkipNull = 256 |
| 94 | + /// Unused yet in user land. |
| 95 | + /// Used internally by relations for 1) backlinks and 2) to clear references to deleted objects (required for ID reuse). |
| 96 | + case indexPartialSkipZero = 512 |
| 97 | + /// Virtual properties may not have a dedicated field in their entity class, e.g. target IDs of to-one relations |
| 98 | + case virtual = 1024 |
| 99 | + /// Index uses a 32 bit hash instead of the value. 32 bit is the default hash size because: |
| 100 | + /// they take less disk space, run well on 32 bit systems, and also run quite well on 64 bit systems |
| 101 | + /// (especially for small to medium sized values). |
| 102 | + /// and should be OK even with a few collisions. |
| 103 | + case indexHash = 2048 |
| 104 | + /// Index uses a 64 bit hash instead of the value. |
| 105 | + /// Recommended mostly for 64 bit machines with values longer than 200 bytes; |
| 106 | + /// small values are faster with a 32 bit hash even on 64 bit machines. |
| 107 | + case indexHash64 = 4096 |
| 108 | + /// Unused yet: While our default are signed ints, queries and indexes need do know signing info. |
| 109 | + /// Note: Don't combine with ID (IDs are always unsigned internally). |
| 110 | + case unsigned = 8192 |
| 111 | + /// By defining an ID companion property, a special ID encoding scheme is activated involving this property. |
| 112 | + /// |
| 113 | + /// For Time Series IDs, a companion property of type Date or DateNano represents the exact timestamp. |
| 114 | + /// (In the future, ID companion string properties may be added as another supported type). |
| 115 | + case idCompanion = 16384 |
| 116 | + |
| 117 | + |
| 118 | + public static var max: PropertyFlags { return .idCompanion } |
| 119 | + public static var min: PropertyFlags { return .id } |
| 120 | +} |
| 121 | + |
| 122 | + |
| 123 | +extension Array where Element == PropertyFlags { |
| 124 | + var rawValue: UInt32 { |
| 125 | + var combined: UInt32 = 0 |
| 126 | + for value in self { |
| 127 | + combined |= value.rawValue |
| 128 | + } |
| 129 | + return combined |
| 130 | + } |
| 131 | +} |
0 commit comments