-
Notifications
You must be signed in to change notification settings - Fork 116
/
enums.dart
241 lines (193 loc) · 8.61 KB
/
enums.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// Note: the enums in this file are copied from native/bindings/objectbox_c.dart
// to avoid package:ffi import which would break compatibility with web.
// ignore_for_file: public_member_api_docs, constant_identifier_names
import '../annotations.dart';
/// Maps [OBXPropertyType] to its string representation (name).
String obxPropertyTypeToString(int type) {
switch (type) {
case OBXPropertyType.Bool:
return 'bool';
case OBXPropertyType.Byte:
return 'byte';
case OBXPropertyType.Short:
return 'short';
case OBXPropertyType.Char:
return 'char';
case OBXPropertyType.Int:
return 'int';
case OBXPropertyType.Long:
return 'long';
case OBXPropertyType.Float:
return 'float';
case OBXPropertyType.Double:
return 'double';
case OBXPropertyType.String:
return 'string';
case OBXPropertyType.Date:
return 'date';
case OBXPropertyType.Relation:
return 'relation';
case OBXPropertyType.DateNano:
return 'dateNano';
case OBXPropertyType.ByteVector:
return 'byteVector';
case OBXPropertyType.CharVector:
return 'charVector';
case OBXPropertyType.ShortVector:
return 'shortVector';
case OBXPropertyType.IntVector:
return 'intVector';
case OBXPropertyType.LongVector:
return 'longVector';
case OBXPropertyType.FloatVector:
return 'floatVector';
case OBXPropertyType.DoubleVector:
return 'doubleVector';
case OBXPropertyType.StringVector:
return 'stringVector';
}
throw ArgumentError.value(type, 'type', 'Invalid OBXPropertyType');
}
int propertyTypeToOBXPropertyType(PropertyType type) {
switch (type) {
case PropertyType.byte:
return OBXPropertyType.Byte;
case PropertyType.short:
return OBXPropertyType.Short;
case PropertyType.char:
return OBXPropertyType.Char;
case PropertyType.int:
return OBXPropertyType.Int;
case PropertyType.float:
return OBXPropertyType.Float;
case PropertyType.date:
return OBXPropertyType.Date;
case PropertyType.dateNano:
return OBXPropertyType.DateNano;
case PropertyType.byteVector:
return OBXPropertyType.ByteVector;
case PropertyType.charVector:
return OBXPropertyType.CharVector;
case PropertyType.shortVector:
return OBXPropertyType.ShortVector;
case PropertyType.intVector:
return OBXPropertyType.IntVector;
case PropertyType.floatVector:
return OBXPropertyType.FloatVector;
default:
throw ArgumentError.value(type, 'type', 'Invalid PropertyType');
}
}
/// Bit-flags defining the behavior of entities.
/// Note: Numbers indicate the bit position
abstract class OBXEntityFlags {
/// Enable "data synchronization" for this entity type: objects will be synced with other stores over the network.
/// It's possible to have local-only (non-synced) types and synced types in the same store (schema/data model).
static const int SYNC_ENABLED = 2;
/// Makes object IDs for a synced types (SYNC_ENABLED is set) global.
/// By default (not using this flag), the 64 bit object IDs have a local scope and are not unique globally.
/// This flag tells ObjectBox to treat object IDs globally and thus no ID mapping (local <-> global) is performed.
/// Often this is used with assignable IDs (ID_SELF_ASSIGNABLE property flag is set) and some special ID scheme.
/// Note: typically you won't do this with automatically assigned IDs, set by the local ObjectBox store.
/// Two devices would likely overwrite each other's object during sync as object IDs are prone to collide.
/// It might be OK if you can somehow ensure that only a single device will create new IDs.
static const int SHARED_GLOBAL_IDS = 4;
}
/// Bit-flags defining the behavior of properties.
/// Note: Numbers indicate the bit position
abstract class OBXPropertyFlags {
/// 64 bit long property (internally unsigned) representing the ID of the entity.
/// May be combined with: NON_PRIMITIVE_TYPE, ID_MONOTONIC_SEQUENCE, ID_SELF_ASSIGNABLE.
static const int ID = 1;
/// On languages like Java, a non-primitive type is used (aka wrapper types, allowing null)
static const int NON_PRIMITIVE_TYPE = 2;
/// Unused yet
static const int NOT_NULL = 4;
static const int INDEXED = 8;
/// Unused yet
static const int RESERVED = 16;
/// Unique index
static const int UNIQUE = 32;
/// Unused yet: Use a persisted sequence to enforce ID to rise monotonic (no ID reuse)
static const int ID_MONOTONIC_SEQUENCE = 64;
/// Allow IDs to be assigned by the developer
static const int ID_SELF_ASSIGNABLE = 128;
/// Unused yet
static const int INDEX_PARTIAL_SKIP_NULL = 256;
/// Used by References for 1) back-references and 2) to clear references to deleted objects (required for ID reuse)
static const int INDEX_PARTIAL_SKIP_ZERO = 512;
/// Virtual properties may not have a dedicated field in their entity class, e.g. target IDs of to-one relations
static const int VIRTUAL = 1024;
/// Index uses a 32 bit hash instead of the value
/// 32 bits is shorter on disk, runs well on 32 bit systems, and should be OK even with a few collisions
static const int INDEX_HASH = 2048;
/// Index uses a 64 bit hash instead of the value
/// recommended mostly for 64 bit machines with values longer >200 bytes; small values are faster with a 32 bit hash
static const int INDEX_HASH64 = 4096;
/// The actual type of the variable is unsigned (used in combination with numeric OBXPropertyType_*).
/// While our default are signed ints, queries & indexes need do know signing info.
/// Note: Don't combine with ID (IDs are always unsigned internally).
static const int UNSIGNED = 8192;
/// By defining an ID companion property, a special ID encoding scheme is activated involving this property.
///
/// For Time Series IDs, a companion property of type Date or DateNano represents the exact timestamp.
static const int ID_COMPANION = 16384;
/// Unique on-conflict strategy: the object being put replaces any existing conflicting object (deletes it).
static const int UNIQUE_ON_CONFLICT_REPLACE = 32768;
/// If a date property has this flag (max. one per entity type), the date value specifies the time by which
/// the object expires, at which point it MAY be removed (deleted), which can be triggered by an API call.
static const int EXPIRATION_TIME = 65536;
}
abstract class OBXPropertyType {
/// < Not a actual type; represents an uninitialized or invalid type
static const int Unknown = 0;
/// < A boolean (flag)
static const int Bool = 1;
/// < 8-bit integer
static const int Byte = 2;
/// < 16-bit integer
static const int Short = 3;
/// < 16-bit character
static const int Char = 4;
/// < 32-bit integer
static const int Int = 5;
/// < 64-bit integer
static const int Long = 6;
/// < 32-bit floating point number
static const int Float = 7;
/// < 64-bit floating point number
static const int Double = 8;
/// < UTF-8 encoded string (variable length)
static const int String = 9;
/// < 64-bit (integer) timestamp; milliseconds since 1970-01-01 (unix epoch)
static const int Date = 10;
/// < Relation to another entity
static const int Relation = 11;
/// < High precision 64-bit timestamp; nanoseconds since 1970-01-01 (unix epoch)
static const int DateNano = 12;
/// < Flexible" type, which may contain scalars (integers, floating points), strings or
/// < containers (lists and maps). Note: a flex map must use string keys.
static const int Flex = 13;
/// < Variable sized vector of Bool values (note: each value is one byte)
static const int BoolVector = 22;
/// < Variable sized vector of Byte values (8-bit integers)
static const int ByteVector = 23;
/// < Variable sized vector of Short values (16-bit integers)
static const int ShortVector = 24;
/// < Variable sized vector of Char values (16-bit characters)
static const int CharVector = 25;
/// < Variable sized vector of Int values (32-bit integers)
static const int IntVector = 26;
/// < Variable sized vector of Long values (64-bit integers)
static const int LongVector = 27;
/// < Variable sized vector of Float values (32-bit floating point numbers)
static const int FloatVector = 28;
/// < Variable sized vector of Double values (64-bit floating point numbers)
static const int DoubleVector = 29;
/// < Variable sized vector of String values (UTF-8 encoded strings).
static const int StringVector = 30;
/// < Variable sized vector of Date values (64-bit timestamp).
static const int DateVector = 31;
/// < Variable sized vector of Date values (high precision 64-bit timestamp).
static const int DateNanoVector = 32;
}