Skip to content

Commit a51488d

Browse files
committed
add enum classes and C header
1 parent bbd8291 commit a51488d

File tree

7 files changed

+1996
-0
lines changed

7 files changed

+1996
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
identifier_name:
2+
excluded: # Object IDs are splendid!
3+
- id
4+
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
/// Not really an enum, but binary flags to use across languages
23+
public enum DebugFlags: UInt32 {
24+
public typealias T = UInt32
25+
public static var byteSize: Int { return MemoryLayout<UInt32>.size }
26+
public var value: UInt32 { return self.rawValue }
27+
case logTransactionsRead = 1
28+
case logTransactionsWrite = 2
29+
case logQueries = 4
30+
case logQueryParameters = 8
31+
case logAsyncQueue = 16
32+
case logCacheHits = 32
33+
case logCacheAll = 64
34+
35+
36+
public static var max: DebugFlags { return .logCacheAll }
37+
public static var min: DebugFlags { return .logTransactionsRead }
38+
}
39+
40+
/// Defines a padding mode for putting data bytes.
41+
/// Depending on how that data is created, this mode may optimize data handling by avoiding copying memory.
42+
/// Internal background: data buffers used by put operations are required to have a size divisible by 4 for an
43+
/// efficient data layout.
44+
public enum PutPaddingMode: UInt16 {
45+
public typealias T = UInt16
46+
public static var byteSize: Int { return MemoryLayout<UInt16>.size }
47+
public var value: UInt16 { return self.rawValue }
48+
/// Not a real type, just best practice (e.g. forward compatibility)
49+
case unknown = 0
50+
/// Adds a padding when needed (requiring to copy memory): this is the safe option and also the default.
51+
/// The extra memory copy may impact performance, however this is usually not noticeable.
52+
case paddingautomatic = 1
53+
/// Indicates that data buffers are safe to be extended for padding (adding up to 3 bytes to size is OK).
54+
/// Typically, it depends on the used FlatBuffers builder; e.g. the official C++ seems to ensure it, but
55+
/// flatcc (3rd party implementation for plain C) does not.
56+
case paddingallowedbybuffer = 2
57+
/// The caller ensures that all data bytes are already padded.
58+
/// ObjectBox will verify this and throws an exception if this is violated.
59+
case paddingbycaller = 3
60+
61+
62+
public static var max: PutPaddingMode { return .paddingbycaller }
63+
public static var min: PutPaddingMode { return .unknown }
64+
}
65+
66+
/// Defines if and how the database is checked for structural consistency when opening it.
67+
public enum ValidateOnOpenMode: UInt16 {
68+
public typealias T = UInt16
69+
public static var byteSize: Int { return MemoryLayout<UInt16>.size }
70+
public var value: UInt16 { return self.rawValue }
71+
/// Not a real type, just best practice (e.g. forward compatibility)
72+
case unknown = 0
73+
/// No additional checks are performed. This is fine if your file system is reliable (which it typically should be).
74+
case none_ = 1
75+
/// Performs a limited number of checks on the most important database structures (e.g. "branch pages").
76+
case regular = 2
77+
/// Performs a limited number of checks on database structures including "data leaves".
78+
case withleaves = 3
79+
/// Performs a unlimited number of checks on the most important database structures (e.g. "branch pages").
80+
case allbranches = 4
81+
/// Performs a unlimited number of checks on database structures including "data leaves".
82+
case full = 5
83+
84+
85+
public static var max: ValidateOnOpenMode { return .full }
86+
public static var min: ValidateOnOpenMode { return .unknown }
87+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
/// Not really an enum, but binary flags to use across languages
23+
public enum EntityFlags: UInt32 {
24+
public typealias T = UInt32
25+
public static var byteSize: Int { return MemoryLayout<UInt32>.size }
26+
public var value: UInt32 { return self.rawValue }
27+
/// Use the default (no arguments) constructor to create entities
28+
case useNoArgConstructor = 1
29+
/// Enable "data synchronization" for this entity type: objects will be synced with other stores over the network.
30+
/// It's possible to have local-only (non-synced) types and synced types in the same store (schema/data model).
31+
case syncEnabled = 2
32+
33+
34+
public static var max: EntityFlags { return .syncEnabled }
35+
public static var min: EntityFlags { return .useNoArgConstructor }
36+
}
37+
38+
extension Array where Element == EntityFlags {
39+
var rawValue: UInt32 {
40+
var combined: UInt32 = 0
41+
for value in self {
42+
combined |= value.rawValue
43+
}
44+
return combined
45+
}
46+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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

Comments
 (0)