objectbox.g.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. // GENERATED CODE - DO NOT MODIFY BY HAND
  2. // ignore_for_file: camel_case_types
  3. import 'dart:typed_data';
  4. import 'package:objectbox/flatbuffers/flat_buffers.dart' as fb;
  5. import 'package:objectbox/internal.dart'; // generated code can access "internal" functionality
  6. import 'package:objectbox/objectbox.dart';
  7. import 'package:objectbox_flutter_libs/objectbox_flutter_libs.dart';
  8. import 'entities/content.dart';
  9. import 'entities/friend.dart';
  10. import 'entities/message.dart';
  11. import 'entities/profile.dart';
  12. import 'entities/user.dart';
  13. export 'package:objectbox/objectbox.dart'; // so that callers only have to import this file
  14. final _entities = <ModelEntity>[
  15. ModelEntity(
  16. id: const IdUid(2, 1438354990151910015),
  17. name: 'Profile',
  18. lastPropertyId: const IdUid(7, 4763561980566319174),
  19. flags: 0,
  20. properties: <ModelProperty>[
  21. ModelProperty(
  22. id: const IdUid(1, 3873481118333862410),
  23. name: 'id',
  24. type: 6,
  25. flags: 1),
  26. ModelProperty(
  27. id: const IdUid(2, 9078004558710481468),
  28. name: 'theme',
  29. type: 6,
  30. flags: 0),
  31. ModelProperty(
  32. id: const IdUid(3, 7647214962273172849),
  33. name: 'username',
  34. type: 9,
  35. flags: 0),
  36. ModelProperty(
  37. id: const IdUid(4, 5923665807684456265),
  38. name: 'isLogin',
  39. type: 1,
  40. flags: 0),
  41. ModelProperty(
  42. id: const IdUid(7, 4763561980566319174),
  43. name: 'isLogout',
  44. type: 1,
  45. flags: 0)
  46. ],
  47. relations: <ModelRelation>[],
  48. backlinks: <ModelBacklink>[]),
  49. ModelEntity(
  50. id: const IdUid(3, 2132486004932842474),
  51. name: 'Content',
  52. lastPropertyId: const IdUid(1, 8861377786907255369),
  53. flags: 0,
  54. properties: <ModelProperty>[
  55. ModelProperty(
  56. id: const IdUid(1, 8861377786907255369),
  57. name: 'id',
  58. type: 6,
  59. flags: 1)
  60. ],
  61. relations: <ModelRelation>[],
  62. backlinks: <ModelBacklink>[]),
  63. ModelEntity(
  64. id: const IdUid(4, 5044745765388820377),
  65. name: 'Friend',
  66. lastPropertyId: const IdUid(3, 214180290351070734),
  67. flags: 0,
  68. properties: <ModelProperty>[
  69. ModelProperty(
  70. id: const IdUid(1, 5034484793468406763),
  71. name: 'id',
  72. type: 6,
  73. flags: 1),
  74. ModelProperty(
  75. id: const IdUid(2, 754684519442805673),
  76. name: 'user1Id',
  77. type: 11,
  78. flags: 520,
  79. indexId: const IdUid(2, 3790366672903506902),
  80. relationTarget: 'User'),
  81. ModelProperty(
  82. id: const IdUid(3, 214180290351070734),
  83. name: 'user2Id',
  84. type: 11,
  85. flags: 520,
  86. indexId: const IdUid(3, 1460593015267560936),
  87. relationTarget: 'User')
  88. ],
  89. relations: <ModelRelation>[
  90. ModelRelation(
  91. id: const IdUid(1, 5078486750954543598),
  92. name: 'messages',
  93. targetId: const IdUid(5, 8880211362757189177))
  94. ],
  95. backlinks: <ModelBacklink>[]),
  96. ModelEntity(
  97. id: const IdUid(5, 8880211362757189177),
  98. name: 'Message',
  99. lastPropertyId: const IdUid(3, 7721473969164711791),
  100. flags: 0,
  101. properties: <ModelProperty>[
  102. ModelProperty(
  103. id: const IdUid(1, 8816894358087325317),
  104. name: 'id',
  105. type: 6,
  106. flags: 1),
  107. ModelProperty(
  108. id: const IdUid(2, 7982216815340584307),
  109. name: 'fromId',
  110. type: 11,
  111. flags: 520,
  112. indexId: const IdUid(4, 6495021264194887400),
  113. relationTarget: 'User'),
  114. ModelProperty(
  115. id: const IdUid(3, 7721473969164711791),
  116. name: 'toId',
  117. type: 11,
  118. flags: 520,
  119. indexId: const IdUid(5, 5329740598468773345),
  120. relationTarget: 'User')
  121. ],
  122. relations: <ModelRelation>[],
  123. backlinks: <ModelBacklink>[]),
  124. ModelEntity(
  125. id: const IdUid(6, 6066676571331973763),
  126. name: 'User',
  127. lastPropertyId: const IdUid(2, 2230815448876041069),
  128. flags: 0,
  129. properties: <ModelProperty>[
  130. ModelProperty(
  131. id: const IdUid(1, 5757871925438229578),
  132. name: 'id',
  133. type: 6,
  134. flags: 1),
  135. ModelProperty(
  136. id: const IdUid(2, 2230815448876041069),
  137. name: 'username',
  138. type: 9,
  139. flags: 2080,
  140. indexId: const IdUid(6, 2181766053148811865))
  141. ],
  142. relations: <ModelRelation>[
  143. ModelRelation(
  144. id: const IdUid(2, 3118435353931894829),
  145. name: 'friends',
  146. targetId: const IdUid(4, 5044745765388820377))
  147. ],
  148. backlinks: <ModelBacklink>[])
  149. ];
  150. /// Open an ObjectBox store with the model declared in this file.
  151. Future<Store> openStore(
  152. {String? directory,
  153. int? maxDBSizeInKB,
  154. int? fileMode,
  155. int? maxReaders,
  156. bool queriesCaseSensitiveDefault = true,
  157. String? macosApplicationGroup}) async =>
  158. Store(getObjectBoxModel(),
  159. directory: directory ?? (await defaultStoreDirectory()).path,
  160. maxDBSizeInKB: maxDBSizeInKB,
  161. fileMode: fileMode,
  162. maxReaders: maxReaders,
  163. queriesCaseSensitiveDefault: queriesCaseSensitiveDefault,
  164. macosApplicationGroup: macosApplicationGroup);
  165. /// ObjectBox model definition, pass it to [Store] - Store(getObjectBoxModel())
  166. ModelDefinition getObjectBoxModel() {
  167. final model = ModelInfo(
  168. entities: _entities,
  169. lastEntityId: const IdUid(6, 6066676571331973763),
  170. lastIndexId: const IdUid(6, 2181766053148811865),
  171. lastRelationId: const IdUid(2, 3118435353931894829),
  172. lastSequenceId: const IdUid(0, 0),
  173. retiredEntityUids: const [3444477729893015694],
  174. retiredIndexUids: const [],
  175. retiredPropertyUids: const [
  176. 5463014948149082651,
  177. 2305308568754167021,
  178. 649621747167423523,
  179. 4818206049188692305
  180. ],
  181. retiredRelationUids: const [],
  182. modelVersion: 5,
  183. modelVersionParserMinimum: 5,
  184. version: 1);
  185. final bindings = <Type, EntityDefinition>{
  186. Profile: EntityDefinition<Profile>(
  187. model: _entities[0],
  188. toOneRelations: (Profile object) => [],
  189. toManyRelations: (Profile object) => {},
  190. getId: (Profile object) => object.id,
  191. setId: (Profile object, int id) {
  192. object.id = id;
  193. },
  194. objectToFB: (Profile object, fb.Builder fbb) {
  195. final usernameOffset = object.username == null
  196. ? null
  197. : fbb.writeString(object.username!);
  198. fbb.startTable(8);
  199. fbb.addInt64(0, object.id);
  200. fbb.addInt64(1, object.theme);
  201. fbb.addOffset(2, usernameOffset);
  202. fbb.addBool(3, object.isLogin);
  203. fbb.addBool(6, object.isLogout);
  204. fbb.finish(fbb.endTable());
  205. return object.id;
  206. },
  207. objectFromFB: (Store store, ByteData fbData) {
  208. final buffer = fb.BufferContext(fbData);
  209. final rootOffset = buffer.derefObject(0);
  210. final object = Profile()
  211. ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0)
  212. ..theme = const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0)
  213. ..username =
  214. const fb.StringReader().vTableGetNullable(buffer, rootOffset, 8)
  215. ..isLogin =
  216. const fb.BoolReader().vTableGet(buffer, rootOffset, 10, false)
  217. ..isLogout =
  218. const fb.BoolReader().vTableGet(buffer, rootOffset, 16, false);
  219. return object;
  220. }),
  221. Content: EntityDefinition<Content>(
  222. model: _entities[1],
  223. toOneRelations: (Content object) => [],
  224. toManyRelations: (Content object) => {},
  225. getId: (Content object) => object.id,
  226. setId: (Content object, int id) {
  227. object.id = id;
  228. },
  229. objectToFB: (Content object, fb.Builder fbb) {
  230. fbb.startTable(2);
  231. fbb.addInt64(0, object.id);
  232. fbb.finish(fbb.endTable());
  233. return object.id;
  234. },
  235. objectFromFB: (Store store, ByteData fbData) {
  236. final buffer = fb.BufferContext(fbData);
  237. final rootOffset = buffer.derefObject(0);
  238. final object = Content()
  239. ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
  240. return object;
  241. }),
  242. Friend: EntityDefinition<Friend>(
  243. model: _entities[2],
  244. toOneRelations: (Friend object) => [object.user1, object.user2],
  245. toManyRelations: (Friend object) =>
  246. {RelInfo<Friend>.toMany(1, object.id): object.messages},
  247. getId: (Friend object) => object.id,
  248. setId: (Friend object, int id) {
  249. object.id = id;
  250. },
  251. objectToFB: (Friend object, fb.Builder fbb) {
  252. fbb.startTable(4);
  253. fbb.addInt64(0, object.id);
  254. fbb.addInt64(1, object.user1.targetId);
  255. fbb.addInt64(2, object.user2.targetId);
  256. fbb.finish(fbb.endTable());
  257. return object.id;
  258. },
  259. objectFromFB: (Store store, ByteData fbData) {
  260. final buffer = fb.BufferContext(fbData);
  261. final rootOffset = buffer.derefObject(0);
  262. final object = Friend()
  263. ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
  264. object.user1.targetId =
  265. const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0);
  266. object.user1.attach(store);
  267. object.user2.targetId =
  268. const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0);
  269. object.user2.attach(store);
  270. InternalToManyAccess.setRelInfo(object.messages, store,
  271. RelInfo<Friend>.toMany(1, object.id), store.box<Friend>());
  272. return object;
  273. }),
  274. Message: EntityDefinition<Message>(
  275. model: _entities[3],
  276. toOneRelations: (Message object) => [object.from, object.to],
  277. toManyRelations: (Message object) => {},
  278. getId: (Message object) => object.id,
  279. setId: (Message object, int id) {
  280. object.id = id;
  281. },
  282. objectToFB: (Message object, fb.Builder fbb) {
  283. fbb.startTable(4);
  284. fbb.addInt64(0, object.id);
  285. fbb.addInt64(1, object.from.targetId);
  286. fbb.addInt64(2, object.to.targetId);
  287. fbb.finish(fbb.endTable());
  288. return object.id;
  289. },
  290. objectFromFB: (Store store, ByteData fbData) {
  291. final buffer = fb.BufferContext(fbData);
  292. final rootOffset = buffer.derefObject(0);
  293. final object = Message()
  294. ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
  295. object.from.targetId =
  296. const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0);
  297. object.from.attach(store);
  298. object.to.targetId =
  299. const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0);
  300. object.to.attach(store);
  301. return object;
  302. }),
  303. User: EntityDefinition<User>(
  304. model: _entities[4],
  305. toOneRelations: (User object) => [],
  306. toManyRelations: (User object) =>
  307. {RelInfo<User>.toMany(2, object.id): object.friends},
  308. getId: (User object) => object.id,
  309. setId: (User object, int id) {
  310. object.id = id;
  311. },
  312. objectToFB: (User object, fb.Builder fbb) {
  313. final usernameOffset = fbb.writeString(object.username);
  314. fbb.startTable(3);
  315. fbb.addInt64(0, object.id);
  316. fbb.addOffset(1, usernameOffset);
  317. fbb.finish(fbb.endTable());
  318. return object.id;
  319. },
  320. objectFromFB: (Store store, ByteData fbData) {
  321. final buffer = fb.BufferContext(fbData);
  322. final rootOffset = buffer.derefObject(0);
  323. final object = User(
  324. id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
  325. username:
  326. const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''));
  327. InternalToManyAccess.setRelInfo(object.friends, store,
  328. RelInfo<User>.toMany(2, object.id), store.box<User>());
  329. return object;
  330. })
  331. };
  332. return ModelDefinition(model, bindings);
  333. }
  334. /// [Profile] entity fields to define ObjectBox queries.
  335. class Profile_ {
  336. /// see [Profile.id]
  337. static final id = QueryIntegerProperty<Profile>(_entities[0].properties[0]);
  338. /// see [Profile.theme]
  339. static final theme =
  340. QueryIntegerProperty<Profile>(_entities[0].properties[1]);
  341. /// see [Profile.username]
  342. static final username =
  343. QueryStringProperty<Profile>(_entities[0].properties[2]);
  344. /// see [Profile.isLogin]
  345. static final isLogin =
  346. QueryBooleanProperty<Profile>(_entities[0].properties[3]);
  347. /// see [Profile.isLogout]
  348. static final isLogout =
  349. QueryBooleanProperty<Profile>(_entities[0].properties[4]);
  350. }
  351. /// [Content] entity fields to define ObjectBox queries.
  352. class Content_ {
  353. /// see [Content.id]
  354. static final id = QueryIntegerProperty<Content>(_entities[1].properties[0]);
  355. }
  356. /// [Friend] entity fields to define ObjectBox queries.
  357. class Friend_ {
  358. /// see [Friend.id]
  359. static final id = QueryIntegerProperty<Friend>(_entities[2].properties[0]);
  360. /// see [Friend.user1]
  361. static final user1 =
  362. QueryRelationToOne<Friend, User>(_entities[2].properties[1]);
  363. /// see [Friend.user2]
  364. static final user2 =
  365. QueryRelationToOne<Friend, User>(_entities[2].properties[2]);
  366. /// see [Friend.messages]
  367. static final messages =
  368. QueryRelationToMany<Friend, Message>(_entities[2].relations[0]);
  369. }
  370. /// [Message] entity fields to define ObjectBox queries.
  371. class Message_ {
  372. /// see [Message.id]
  373. static final id = QueryIntegerProperty<Message>(_entities[3].properties[0]);
  374. /// see [Message.from]
  375. static final from =
  376. QueryRelationToOne<Message, User>(_entities[3].properties[1]);
  377. /// see [Message.to]
  378. static final to =
  379. QueryRelationToOne<Message, User>(_entities[3].properties[2]);
  380. }
  381. /// [User] entity fields to define ObjectBox queries.
  382. class User_ {
  383. /// see [User.id]
  384. static final id = QueryIntegerProperty<User>(_entities[4].properties[0]);
  385. /// see [User.username]
  386. static final username = QueryStringProperty<User>(_entities[4].properties[1]);
  387. /// see [User.friends]
  388. static final friends =
  389. QueryRelationToMany<User, Friend>(_entities[4].relations[0]);
  390. }