motion-yapper 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (294) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -1
  4. data/lib/yapper.rb +3 -3
  5. data/lib/yapper/db.rb +61 -4
  6. data/lib/yapper/document/persistence.rb +4 -0
  7. data/lib/yapper/document/selection.rb +13 -0
  8. data/lib/yapper/version.rb +1 -1
  9. data/motion-yapper.gemspec +1 -1
  10. data/spec/integration/search_spec.rb +111 -0
  11. data/vendor/Podfile.lock +11 -7
  12. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -2
  13. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +10 -7
  14. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -2
  15. metadata +19 -297
  16. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  17. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  18. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  19. data/vendor/Pods/.build/libPods.a +0 -0
  20. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +0 -41
  21. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
  22. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
  23. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
  24. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +0 -369
  25. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +0 -99
  26. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +0 -634
  27. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +0 -30
  28. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +0 -181
  29. data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  30. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +0 -8
  31. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +0 -91
  32. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +0 -23
  33. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +0 -547
  34. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +0 -449
  35. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +0 -29
  36. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +0 -37
  37. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +0 -15
  38. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
  39. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +0 -444
  40. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
  41. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +0 -81
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -17
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -77
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +0 -158
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +0 -17
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +0 -446
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +0 -42
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +0 -35
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +0 -79
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +0 -125
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -83
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +0 -13
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +0 -121
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +0 -651
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +0 -127
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +0 -272
  74. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  75. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +0 -116
  76. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +0 -842
  77. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  78. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +0 -63
  79. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +0 -36
  80. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  81. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +0 -170
  82. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
  83. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  84. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +0 -498
  85. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +0 -99
  86. data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +0 -74
  87. data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +0 -17
  88. data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +0 -41
  89. data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +0 -15
  90. data/vendor/Pods/CocoaLumberjack/LICENSE.txt +0 -18
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +0 -41
  92. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +0 -100
  93. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +0 -102
  94. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +0 -727
  95. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +0 -369
  96. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +0 -1539
  97. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +0 -99
  98. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +0 -634
  99. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +0 -1208
  100. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +0 -181
  101. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +0 -1520
  102. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h +0 -63
  103. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.m +0 -191
  104. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.h +0 -128
  105. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +0 -253
  106. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +0 -30
  107. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +0 -127
  108. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +0 -7
  109. data/vendor/Pods/CocoaLumberjack/README.markdown +0 -74
  110. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +0 -41
  111. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +0 -102
  112. data/vendor/Pods/Headers/CocoaLumberjack/DDContextFilterLogFormatter.h +0 -63
  113. data/vendor/Pods/Headers/CocoaLumberjack/DDDispatchQueueLogFormatter.h +0 -128
  114. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +0 -369
  115. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +0 -99
  116. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +0 -634
  117. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +0 -30
  118. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +0 -181
  119. data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  120. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +0 -23
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +0 -547
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +0 -449
  123. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +0 -15
  124. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +0 -11
  125. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +0 -11
  126. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +0 -81
  127. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +0 -12
  128. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +0 -39
  129. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +0 -32
  130. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +0 -89
  131. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +0 -32
  132. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  133. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +0 -68
  134. data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +0 -42
  135. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +0 -35
  136. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +0 -29
  137. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +0 -163
  138. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +0 -99
  139. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +0 -59
  140. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +0 -384
  141. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +0 -149
  142. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +0 -33
  143. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +0 -33
  144. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +0 -58
  145. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +0 -651
  146. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +0 -127
  147. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +0 -272
  148. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +0 -116
  149. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +0 -842
  150. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +0 -63
  151. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +0 -330
  152. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +0 -498
  153. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +0 -99
  154. data/vendor/Pods/Headers/YapDatabase/YapSet.h +0 -41
  155. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +0 -7
  156. data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +0 -5
  157. data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +0 -5
  158. data/vendor/Pods/Headers/____Pods-environment.h +0 -38
  159. data/vendor/Pods/Manifest.lock +0 -22
  160. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +0 -18
  161. data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +0 -39
  162. data/vendor/Pods/NSData+MD5Digest/README.md +0 -11
  163. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +0 -5
  164. data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +0 -5
  165. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +0 -7
  166. data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
  167. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +0 -5
  168. data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +0 -5
  169. data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +0 -5
  170. data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
  171. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +0 -5
  172. data/vendor/Pods/Pods-YapDatabase-dummy.m +0 -5
  173. data/vendor/Pods/Pods-YapDatabase-prefix.pch +0 -5
  174. data/vendor/Pods/Pods-YapDatabase.xcconfig +0 -1
  175. data/vendor/Pods/Pods-acknowledgements.markdown +0 -59
  176. data/vendor/Pods/Pods-acknowledgements.plist +0 -97
  177. data/vendor/Pods/Pods-dummy.m +0 -5
  178. data/vendor/Pods/Pods-environment.h +0 -38
  179. data/vendor/Pods/Pods-resources.sh +0 -68
  180. data/vendor/Pods/Pods.xcconfig +0 -5
  181. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +0 -4807
  182. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +0 -59
  183. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +0 -59
  184. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +0 -59
  185. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +0 -59
  186. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -31
  187. data/vendor/Pods/YapDatabase/LICENSE.txt +0 -18
  188. data/vendor/Pods/YapDatabase/README.md +0 -32
  189. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -17
  190. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +0 -81
  191. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +0 -159
  192. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +0 -12
  193. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +0 -41
  194. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +0 -39
  195. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +0 -1235
  196. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +0 -32
  197. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +0 -77
  198. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +0 -89
  199. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +0 -146
  200. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +0 -32
  201. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +0 -298
  202. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +0 -79
  203. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +0 -95
  204. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +0 -68
  205. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +0 -1403
  206. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +0 -444
  207. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +0 -15
  208. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +0 -83
  209. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +0 -11
  210. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +0 -46
  211. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +0 -11
  212. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +0 -204
  213. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +0 -79
  214. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +0 -125
  215. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +0 -35
  216. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +0 -129
  217. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +0 -29
  218. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +0 -802
  219. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +0 -163
  220. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +0 -408
  221. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +0 -99
  222. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +0 -59
  223. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +0 -29
  224. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +0 -384
  225. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +0 -5254
  226. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +0 -83
  227. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +0 -18
  228. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +0 -149
  229. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +0 -161
  230. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +0 -33
  231. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +0 -331
  232. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +0 -33
  233. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +0 -245
  234. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +0 -58
  235. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +0 -1269
  236. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +0 -94
  237. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +0 -72
  238. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +0 -36
  239. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +0 -296
  240. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +0 -27
  241. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +0 -28
  242. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +0 -170
  243. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  244. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +0 -272
  245. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +0 -2500
  246. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +0 -842
  247. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +0 -1714
  248. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +0 -330
  249. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +0 -141
  250. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +0 -127
  251. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +0 -194
  252. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +0 -116
  253. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +0 -888
  254. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +0 -63
  255. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +0 -27
  256. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +0 -498
  257. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +0 -4986
  258. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +0 -99
  259. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +0 -8
  260. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +0 -19
  261. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +0 -91
  262. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +0 -465
  263. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +0 -48
  265. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +0 -37
  266. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +0 -83
  267. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +0 -158
  268. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +0 -73
  269. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +0 -56
  271. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +0 -446
  272. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +0 -26
  274. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +0 -121
  275. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +0 -74
  276. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +0 -603
  277. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +0 -17
  278. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +0 -35
  279. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +0 -15
  280. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +0 -31
  281. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +0 -23
  282. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +0 -199
  283. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +0 -42
  284. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +0 -96
  285. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +0 -41
  286. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +0 -82
  287. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +0 -547
  288. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +0 -2013
  289. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +0 -449
  290. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +0 -4046
  291. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +0 -651
  292. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +0 -5602
  293. data/vendor/Pods/build-iPhoneSimulator/Pods.bridgesupport +0 -3172
  294. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
@@ -1,127 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- #import "YapDatabaseExtension.h"
4
- #import "YapDatabaseViewTypes.h"
5
- #import "YapDatabaseViewOptions.h"
6
- #import "YapDatabaseViewConnection.h"
7
- #import "YapDatabaseViewTransaction.h"
8
- #import "YapDatabaseViewMappings.h"
9
- #import "YapDatabaseViewChange.h"
10
- #import "YapDatabaseViewRangeOptions.h"
11
-
12
- /**
13
- * Welcome to YapDatabase!
14
- *
15
- * https://github.com/yaptv/YapDatabase
16
- *
17
- * The project wiki has a wealth of documentation if you have any questions.
18
- * https://github.com/yaptv/YapDatabase/wiki
19
- *
20
- * YapDatabaseView is an extension designed to work with YapDatabase.
21
- * It gives you a persistent sorted "view" of a configurable subset of your data.
22
- *
23
- * For the full documentation on Views, please see the related wiki article:
24
- * https://github.com/yaptv/YapDatabase/wiki/Views
25
- *
26
- * Just in case you don't have Internet access,
27
- * see the quick overview in YapDatabaseView.h.
28
- **/
29
- @interface YapDatabaseView : YapDatabaseExtension
30
-
31
- /* Inherited from YapDatabaseExtension
32
-
33
- @property (nonatomic, strong, readonly) NSString *registeredName;
34
-
35
- */
36
-
37
- /**
38
- * See the wiki for an example of how to initialize a view:
39
- * https://github.com/yaptv/YapDatabase/wiki/Views#wiki-initializing_a_view
40
- *
41
- * @param groupingBlock
42
- *
43
- * The grouping block handles both filtering and grouping.
44
- *
45
- * @see YapDatabaseViewTypes.h for block type definition(s).
46
- *
47
- * @param groupingBlockType
48
- *
49
- * Specify the type of groupingBlock that is being passed.
50
- *
51
- * @see YapDatabaseViewTypes.h for block type definition(s).
52
- *
53
- * @param sortingBlock
54
- *
55
- * The sorting block handles sorting of objects within their group.
56
- *
57
- * @see YapDatabaseViewTypes.h for block type definition(s).
58
- *
59
- * @param sortingBlockType
60
- *
61
- * Specify the type of sortingBlock that is being passed.
62
- *
63
- * @see YapDatabaseViewTypes.h for block type definition(s).
64
- *
65
- * @param versionTag
66
- *
67
- * If, after creating a view, you need to change either the groupingBlock or sortingBlock,
68
- * then simply use the versionTag parameter. If you pass a versionTag that is different from the last
69
- * initialization of the view, then the view will automatically flush its tables, and re-populate itself.
70
- *
71
- * @param options
72
- *
73
- * The options allow you to specify things like creating an in-memory-only view (non persistent).
74
- **/
75
-
76
- - (id)initWithGroupingBlock:(YapDatabaseViewGroupingBlock)groupingBlock
77
- groupingBlockType:(YapDatabaseViewBlockType)groupingBlockType
78
- sortingBlock:(YapDatabaseViewSortingBlock)sortingBlock
79
- sortingBlockType:(YapDatabaseViewBlockType)sortingBlockType;
80
-
81
- - (id)initWithGroupingBlock:(YapDatabaseViewGroupingBlock)groupingBlock
82
- groupingBlockType:(YapDatabaseViewBlockType)groupingBlockType
83
- sortingBlock:(YapDatabaseViewSortingBlock)sortingBlock
84
- sortingBlockType:(YapDatabaseViewBlockType)sortingBlockType
85
- versionTag:(NSString *)versionTag;
86
-
87
- - (id)initWithGroupingBlock:(YapDatabaseViewGroupingBlock)groupingBlock
88
- groupingBlockType:(YapDatabaseViewBlockType)groupingBlockType
89
- sortingBlock:(YapDatabaseViewSortingBlock)sortingBlock
90
- sortingBlockType:(YapDatabaseViewBlockType)sortingBlockType
91
- versionTag:(NSString *)versionTag
92
- options:(YapDatabaseViewOptions *)options;
93
-
94
- @property (nonatomic, strong, readonly) YapDatabaseViewGroupingBlock groupingBlock;
95
- @property (nonatomic, strong, readonly) YapDatabaseViewSortingBlock sortingBlock;
96
-
97
- @property (nonatomic, assign, readonly) YapDatabaseViewBlockType groupingBlockType;
98
- @property (nonatomic, assign, readonly) YapDatabaseViewBlockType sortingBlockType;
99
-
100
- /**
101
- * The versionTag assists you in updating your blocks.
102
- *
103
- * If you need to change the groupingBlock or sortingBlock,
104
- * then simply pass a different versionTag during the init method, and the view will automatically update itself.
105
- *
106
- * If you want to keep things simple, you can use something like @"1",
107
- * representing version 1 of my groupingBlock & sortingBlock.
108
- *
109
- * For more advanced applications, you may also include within the versionTag string:
110
- * - localization information (if you're using localized sorting routines)
111
- * - configuration information (if your sorting routine is based on some in-app configuration)
112
- *
113
- * For example, if you're sorting strings using a localized string compare method, then embedding the localization
114
- * information into your versionTag means the view will automatically re-populate itself (re-sort)
115
- * if the user launches the app in a different language than last time.
116
- *
117
- * NSString *localeIdentifier = [[NSLocale currentLocale] localeIdentifier];
118
- * NSString *versionTag = [NSString stringWithFormat:@"1-%@", localeIdentifier];
119
- **/
120
- @property (nonatomic, copy, readonly) NSString *versionTag;
121
-
122
- /**
123
- * The options allow you to specify things like creating an in-memory-only view (non persistent).
124
- **/
125
- @property (nonatomic, copy, readonly) YapDatabaseViewOptions *options;
126
-
127
- @end
@@ -1,194 +0,0 @@
1
- #import "YapDatabaseView.h"
2
- #import "YapDatabaseViewPrivate.h"
3
-
4
- #import "YapDatabasePrivate.h"
5
- #import "YapDatabaseExtensionPrivate.h"
6
-
7
- #import "YapDatabaseLogging.h"
8
-
9
- #if ! __has_feature(objc_arc)
10
- #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
11
- #endif
12
-
13
- /**
14
- * Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
15
- * See YapDatabaseLogging.h for more information.
16
- **/
17
- #if DEBUG
18
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
19
- #else
20
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
21
- #endif
22
-
23
- @implementation YapDatabaseView
24
-
25
- + (void)dropTablesForRegisteredName:(NSString *)registeredName
26
- withTransaction:(YapDatabaseReadWriteTransaction *)transaction
27
- {
28
- NSString *mapTableName = [self mapTableNameForRegisteredName:registeredName];
29
- NSString *pageTableName = [self pageTableNameForRegisteredName:registeredName];
30
- NSString *pageMetadataTableName = [self pageMetadataTableNameForRegisteredName:registeredName];
31
-
32
- // Handle persistent view
33
-
34
- sqlite3 *db = transaction->connection->db;
35
-
36
- NSString *dropKeyTable = [NSString stringWithFormat:@"DROP TABLE IF EXISTS \"%@\";", mapTableName];
37
- NSString *dropPageTable = [NSString stringWithFormat:@"DROP TABLE IF EXISTS \"%@\";", pageTableName];
38
-
39
- int status;
40
-
41
- status = sqlite3_exec(db, [dropKeyTable UTF8String], NULL, NULL, NULL);
42
- if (status != SQLITE_OK)
43
- {
44
- YDBLogError(@"%@ - Failed dropping map table (%@): %d %s",
45
- THIS_METHOD, mapTableName, status, sqlite3_errmsg(db));
46
- }
47
-
48
- status = sqlite3_exec(db, [dropPageTable UTF8String], NULL, NULL, NULL);
49
- if (status != SQLITE_OK)
50
- {
51
- YDBLogError(@"%@ - Failed dropping page table (%@): %d %s",
52
- THIS_METHOD, pageTableName, status, sqlite3_errmsg(db));
53
- }
54
-
55
- // Handle memory view
56
-
57
- [transaction->connection unregisterTableWithName:mapTableName];
58
- [transaction->connection unregisterTableWithName:pageTableName];
59
- [transaction->connection unregisterTableWithName:pageMetadataTableName];
60
- }
61
-
62
- + (NSArray *)previousClassNames
63
- {
64
- return @[ @"YapCollectionsDatabaseView" ];
65
- }
66
-
67
- + (NSString *)mapTableNameForRegisteredName:(NSString *)registeredName
68
- {
69
- return [NSString stringWithFormat:@"view_%@_map", registeredName];
70
- }
71
-
72
- + (NSString *)pageTableNameForRegisteredName:(NSString *)registeredName
73
- {
74
- return [NSString stringWithFormat:@"view_%@_page", registeredName];
75
- }
76
-
77
- + (NSString *)pageMetadataTableNameForRegisteredName:(NSString *)registeredName
78
- {
79
- return [NSString stringWithFormat:@"view_%@_pageMetadata", registeredName];
80
- }
81
-
82
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83
- #pragma mark Instance
84
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
85
-
86
- @synthesize groupingBlock = groupingBlock;
87
- @synthesize sortingBlock = sortingBlock;
88
-
89
- @synthesize groupingBlockType = groupingBlockType;
90
- @synthesize sortingBlockType = sortingBlockType;
91
-
92
- @synthesize versionTag = versionTag;
93
- @dynamic options;
94
-
95
- - (id)initWithGroupingBlock:(YapDatabaseViewGroupingBlock)inGroupingBlock
96
- groupingBlockType:(YapDatabaseViewBlockType)inGroupingBlockType
97
- sortingBlock:(YapDatabaseViewSortingBlock)inSortingBlock
98
- sortingBlockType:(YapDatabaseViewBlockType)inSortingBlockType
99
- {
100
- return [self initWithGroupingBlock:inGroupingBlock
101
- groupingBlockType:inGroupingBlockType
102
- sortingBlock:inSortingBlock
103
- sortingBlockType:inSortingBlockType
104
- versionTag:@""
105
- options:nil];
106
- }
107
-
108
- - (id)initWithGroupingBlock:(YapDatabaseViewGroupingBlock)inGroupingBlock
109
- groupingBlockType:(YapDatabaseViewBlockType)inGroupingBlockType
110
- sortingBlock:(YapDatabaseViewSortingBlock)inSortingBlock
111
- sortingBlockType:(YapDatabaseViewBlockType)inSortingBlockType
112
- versionTag:(NSString *)inVersionTag
113
- {
114
- return [self initWithGroupingBlock:inGroupingBlock
115
- groupingBlockType:inGroupingBlockType
116
- sortingBlock:inSortingBlock
117
- sortingBlockType:inSortingBlockType
118
- versionTag:inVersionTag
119
- options:nil];
120
- }
121
-
122
- - (id)initWithGroupingBlock:(YapDatabaseViewGroupingBlock)inGroupingBlock
123
- groupingBlockType:(YapDatabaseViewBlockType)inGroupingBlockType
124
- sortingBlock:(YapDatabaseViewSortingBlock)inSortingBlock
125
- sortingBlockType:(YapDatabaseViewBlockType)inSortingBlockType
126
- versionTag:(NSString *)inVersionTag
127
- options:(YapDatabaseViewOptions *)inOptions
128
- {
129
- if ((self = [super init]))
130
- {
131
- NSAssert(inGroupingBlock != NULL, @"Invalid grouping block");
132
- NSAssert(inSortingBlock != NULL, @"Invalid sorting block");
133
-
134
- NSAssert(inGroupingBlockType == YapDatabaseViewBlockTypeWithKey ||
135
- inGroupingBlockType == YapDatabaseViewBlockTypeWithObject ||
136
- inGroupingBlockType == YapDatabaseViewBlockTypeWithMetadata ||
137
- inGroupingBlockType == YapDatabaseViewBlockTypeWithRow,
138
- @"Invalid grouping block type");
139
-
140
- NSAssert(inSortingBlockType == YapDatabaseViewBlockTypeWithKey ||
141
- inSortingBlockType == YapDatabaseViewBlockTypeWithObject ||
142
- inSortingBlockType == YapDatabaseViewBlockTypeWithMetadata ||
143
- inSortingBlockType == YapDatabaseViewBlockTypeWithRow,
144
- @"Invalid sorting block type");
145
-
146
- groupingBlock = inGroupingBlock;
147
- groupingBlockType = inGroupingBlockType;
148
-
149
- sortingBlock = inSortingBlock;
150
- sortingBlockType = inSortingBlockType;
151
-
152
- versionTag = inVersionTag ? [inVersionTag copy] : @"";
153
-
154
- options = inOptions ? [inOptions copy] : [[YapDatabaseViewOptions alloc] init];
155
- }
156
- return self;
157
- }
158
-
159
- - (YapDatabaseViewOptions *)options
160
- {
161
- return [options copy];
162
- }
163
-
164
- /**
165
- * Subclasses must implement this method.
166
- * This method is called during the view registration process to enusre the extension supports
167
- * the database configuration.
168
- **/
169
- - (BOOL)supportsDatabase:(YapDatabase *)database withRegisteredExtensions:(NSDictionary *)registeredExtensions
170
- {
171
- return YES;
172
- }
173
-
174
- - (YapDatabaseExtensionConnection *)newConnection:(YapDatabaseConnection *)databaseConnection
175
- {
176
- return [[YapDatabaseViewConnection alloc] initWithView:self databaseConnection:databaseConnection];
177
- }
178
-
179
- - (NSString *)mapTableName
180
- {
181
- return [[self class] mapTableNameForRegisteredName:self.registeredName];
182
- }
183
-
184
- - (NSString *)pageTableName
185
- {
186
- return [[self class] pageTableNameForRegisteredName:self.registeredName];
187
- }
188
-
189
- - (NSString *)pageMetadataTableName
190
- {
191
- return [[self class] pageMetadataTableNameForRegisteredName:self.registeredName];
192
- }
193
-
194
- @end
@@ -1,116 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- #import "YapDatabaseExtensionConnection.h"
4
- #import "YapDatabaseViewChange.h"
5
- #import "YapDatabaseViewMappings.h"
6
-
7
- @class YapDatabaseView;
8
-
9
- /**
10
- * Welcome to YapDatabase!
11
- *
12
- * https://github.com/yaptv/YapDatabase
13
- *
14
- * The project wiki has a wealth of documentation if you have any questions.
15
- * https://github.com/yaptv/YapDatabase/wiki
16
- *
17
- * YapDatabaseView is an extension designed to work with YapDatabase.
18
- * It gives you a persistent sorted "view" of a configurable subset of your data.
19
- *
20
- * For the full documentation on Views, please see the related wiki article:
21
- * https://github.com/yaptv/YapDatabase/wiki/Views
22
- *
23
- *
24
- * As a extension, YapDatabaseViewConnection is automatically created by YapDatabaseConnnection.
25
- * You can access this object via:
26
- *
27
- * [databaseConnection extension:@"myRegisteredViewName"]
28
- *
29
- * @see YapDatabaseView
30
- * @see YapDatabaseViewTransaction
31
- **/
32
- @interface YapDatabaseViewConnection : YapDatabaseExtensionConnection
33
-
34
- /**
35
- * Returns the parent view instance.
36
- **/
37
- @property (nonatomic, strong, readonly) YapDatabaseView *view;
38
-
39
- /**
40
- * Want to easily animate a tableView or collectionView when the view changes?
41
- * Want an exact list of changes that happend to the view?
42
- *
43
- * You're in luck!
44
- *
45
- * Here's an overview of how it works:
46
- *
47
- * - (void)yapDatabaseModified:(NSNotification *)notification
48
- * {
49
- * // Jump to the most recent commit.
50
- * // End & Re-Begin the long-lived transaction atomically.
51
- * // Also grab all the notifications for all the commits that I jump.
52
- * NSArray *notifications = [roDatabaseConnection beginLongLivedReadTransaction];
53
- *
54
- * // What changed in my tableView?
55
- *
56
- * NSDictionary *mappings = @{ @"bestSellers" : @(0) };
57
- * NSArray *changes = [[databaseConnection extension:@"sales"] operationsForNotifications:notifications
58
- * withGroupToSectionMappings:mappings];
59
- * if ([changes count] == 0)
60
- * {
61
- * // There aren't any changes that affect our tableView!
62
- * return;
63
- * }
64
- *
65
- * // Familiar with NSFetchedResultsController?
66
- * // Then this should look pretty familiar
67
- *
68
- * [self.tableView beginUpdates];
69
- *
70
- * for (YapDatabaseViewChange *change in changes)
71
- * {
72
- * switch (change.type)
73
- * {
74
- * case YapDatabaseViewChangeDelete :
75
- * {
76
- * [self.tableView deleteRowsAtIndexPaths:@[ change.indexPath ]
77
- * withRowAnimation:UITableViewRowAnimationAutomatic];
78
- * break;
79
- * }
80
- * case YapDatabaseViewChangeInsert :
81
- * {
82
- * [self.tableView insertRowsAtIndexPaths:@[ change.newIndexPath ]
83
- * withRowAnimation:UITableViewRowAnimationAutomatic];
84
- * break;
85
- * }
86
- * case YapDatabaseViewChangeMove :
87
- * {
88
- * [self.tableView deleteRowsAtIndexPaths:@[ change.indexPath ]
89
- * withRowAnimation:UITableViewRowAnimationAutomatic];
90
- * [self.tableView insertRowsAtIndexPaths:@[ change.newIndexPath ]
91
- * withRowAnimation:UITableViewRowAnimationAutomatic];
92
- * break;
93
- * }
94
- * case YapDatabaseViewChangeUpdate :
95
- * {
96
- * [self.tableView reloadRowsAtIndexPaths:@[ change.indexPath ]
97
- * withRowAnimation:UITableViewRowAnimationAutomatic];
98
- * break;
99
- * }
100
- * }
101
- * }
102
- *
103
- * [self.tableView endUpdates];
104
- * }
105
- **/
106
- - (void)getSectionChanges:(NSArray **)sectionChangesPtr
107
- rowChanges:(NSArray **)rowChangesPtr
108
- forNotifications:(NSArray *)notifications
109
- withMappings:(YapDatabaseViewMappings *)mappings;
110
-
111
- /**
112
- * A simple YES/NO query to see if the view changed at all, inclusive of all groups.
113
- **/
114
- - (BOOL)hasChangesForNotifications:(NSArray *)notifications;
115
-
116
- @end
@@ -1,888 +0,0 @@
1
- #import "YapDatabaseViewConnection.h"
2
- #import "YapDatabaseViewPrivate.h"
3
- #import "YapDatabaseExtensionPrivate.h"
4
- #import "YapDatabasePrivate.h"
5
- #import "YapDatabaseViewPage.h"
6
- #import "YapDatabaseViewChange.h"
7
- #import "YapDatabaseViewChangePrivate.h"
8
- #import "YapCollectionKey.h"
9
- #import "YapCache.h"
10
- #import "YapDatabaseString.h"
11
- #import "YapDatabaseLogging.h"
12
-
13
- #if ! __has_feature(objc_arc)
14
- #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
15
- #endif
16
-
17
- /**
18
- * Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
19
- * See YapDatabaseLogging.h for more information.
20
- **/
21
- #if DEBUG
22
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
23
- #else
24
- static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
25
- #endif
26
-
27
- static NSString *const key_dirtyMaps = @"dirtyMaps";
28
- static NSString *const key_dirtyPages = @"dirtyPages";
29
- static NSString *const key_reset = @"reset";
30
- static NSString *const key_group_pagesMetadata_dict = @"group_pagesMetadata_dict";
31
- static NSString *const key_pageKey_group_dict = @"pageKey_group_dict";
32
- static NSString *const key_changes = @"changes";
33
-
34
- @implementation YapDatabaseViewConnection
35
- {
36
- id sharedKeySetForInternalChangeset;
37
- id sharedKeySetForExternalChangeset;
38
-
39
- sqlite3_stmt *mapTable_getPageKeyForRowidStatement;
40
- sqlite3_stmt *mapTable_setPageKeyForRowidStatement;
41
- sqlite3_stmt *mapTable_removeForRowidStatement;
42
- sqlite3_stmt *mapTable_removeAllStatement;
43
-
44
- sqlite3_stmt *pageTable_getDataForPageKeyStatement;
45
- sqlite3_stmt *pageTable_insertForPageKeyStatement;
46
- sqlite3_stmt *pageTable_updateAllForPageKeyStatement;
47
- sqlite3_stmt *pageTable_updatePageForPageKeyStatement;
48
- sqlite3_stmt *pageTable_updateLinkForPageKeyStatement;
49
- sqlite3_stmt *pageTable_removeForPageKeyStatement;
50
- sqlite3_stmt *pageTable_removeAllStatement;
51
- }
52
-
53
- @synthesize view = view;
54
-
55
- - (id)initWithView:(YapDatabaseView *)inView databaseConnection:(YapDatabaseConnection *)inDbC
56
- {
57
- if ((self = [super init]))
58
- {
59
- view = inView;
60
- databaseConnection = inDbC;
61
-
62
- mapCache = [[YapCache alloc] initWithKeyClass:[NSNumber class]];
63
- pageCache = [[YapCache alloc] initWithKeyClass:[NSString class]];
64
-
65
- sharedKeySetForInternalChangeset = [NSDictionary sharedKeySetForKeys:[self internalChangesetKeys]];
66
- sharedKeySetForExternalChangeset = [NSDictionary sharedKeySetForKeys:[self externalChangesetKeys]];
67
- }
68
- return self;
69
- }
70
-
71
- - (void)dealloc
72
- {
73
- [self _flushStatements];
74
- }
75
-
76
- - (void)_flushStatements
77
- {
78
- sqlite_finalize_null(&mapTable_getPageKeyForRowidStatement);
79
- sqlite_finalize_null(&mapTable_setPageKeyForRowidStatement);
80
- sqlite_finalize_null(&mapTable_removeForRowidStatement);
81
- sqlite_finalize_null(&mapTable_removeAllStatement);
82
-
83
- sqlite_finalize_null(&pageTable_getDataForPageKeyStatement);
84
- sqlite_finalize_null(&pageTable_insertForPageKeyStatement);
85
- sqlite_finalize_null(&pageTable_updateAllForPageKeyStatement);
86
- sqlite_finalize_null(&pageTable_updatePageForPageKeyStatement);
87
- sqlite_finalize_null(&pageTable_updateLinkForPageKeyStatement);
88
- sqlite_finalize_null(&pageTable_removeForPageKeyStatement);
89
- sqlite_finalize_null(&pageTable_removeAllStatement);
90
- }
91
-
92
- /**
93
- * Required override method from YapDatabaseExtensionConnection
94
- **/
95
- - (void)_flushMemoryWithFlags:(YapDatabaseConnectionFlushMemoryFlags)flags
96
- {
97
- if (flags & YapDatabaseConnectionFlushMemoryFlags_Caches)
98
- {
99
- [mapCache removeAllObjects];
100
- [pageCache removeAllObjects];
101
- }
102
-
103
- if (flags & YapDatabaseConnectionFlushMemoryFlags_Statements)
104
- {
105
- [self _flushStatements];
106
- }
107
- }
108
-
109
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
110
- #pragma mark Accessors
111
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
112
-
113
- /**
114
- * Required override method from YapDatabaseExtensionConnection.
115
- **/
116
- - (YapDatabaseExtension *)extension
117
- {
118
- return view;
119
- }
120
-
121
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
122
- #pragma mark Transactions
123
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
124
-
125
- /**
126
- * Required override method from YapDatabaseExtensionConnection.
127
- **/
128
- - (id)newReadTransaction:(YapDatabaseReadTransaction *)databaseTransaction
129
- {
130
- YapDatabaseViewTransaction *transaction =
131
- [[YapDatabaseViewTransaction alloc] initWithViewConnection:self
132
- databaseTransaction:databaseTransaction];
133
-
134
- return transaction;
135
- }
136
-
137
- /**
138
- * Required override method from YapDatabaseExtensionConnection.
139
- **/
140
- - (id)newReadWriteTransaction:(YapDatabaseReadWriteTransaction *)databaseTransaction
141
- {
142
- YapDatabaseViewTransaction *transaction =
143
- [[YapDatabaseViewTransaction alloc] initWithViewConnection:self
144
- databaseTransaction:databaseTransaction];
145
-
146
- [self prepareForReadWriteTransaction];
147
- return transaction;
148
- }
149
-
150
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
151
- #pragma mark Utilities
152
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
153
-
154
- - (NSMutableDictionary *)group_pagesMetadata_dict_deepCopy:(NSDictionary *)in_group_pagesMetadata_dict
155
- {
156
- NSMutableDictionary *deepCopy = [NSMutableDictionary dictionaryWithCapacity:[in_group_pagesMetadata_dict count]];
157
-
158
- [in_group_pagesMetadata_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
159
-
160
- __unsafe_unretained NSString *group = (NSString *)key;
161
- __unsafe_unretained NSMutableArray *pagesMetadata = (NSMutableArray *)obj;
162
-
163
- // We need a mutable copy of the pages array,
164
- // and we need a copy of each YapDatabaseViewPageMetadata object within the pages array.
165
-
166
- NSMutableArray *pagesMetadataDeepCopy = [[NSMutableArray alloc] initWithArray:pagesMetadata copyItems:YES];
167
-
168
- [deepCopy setObject:pagesMetadataDeepCopy forKey:group];
169
- }];
170
-
171
- return deepCopy;
172
- }
173
-
174
- - (void)sanitizeDirtyPages
175
- {
176
- NSNull *nsnull = [NSNull null];
177
-
178
- for (NSString *pageKey in [dirtyPages allKeys])
179
- {
180
- YapDatabaseViewPage *page = [dirtyPages objectForKey:pageKey];
181
-
182
- if ((id)page != nsnull)
183
- {
184
- [dirtyPages setObject:[page copy] forKey:pageKey];
185
- }
186
- }
187
- }
188
-
189
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
190
- #pragma mark Changeset Architecture
191
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
192
-
193
- /**
194
- * Initializes any ivars that a read-write transaction may need.
195
- **/
196
- - (void)prepareForReadWriteTransaction
197
- {
198
- if (dirtyMaps == nil)
199
- dirtyMaps = [[NSMutableDictionary alloc] init];
200
- if (dirtyPages == nil)
201
- dirtyPages = [[NSMutableDictionary alloc] init];
202
- if (dirtyLinks == nil)
203
- dirtyLinks = [[NSMutableDictionary alloc] init];
204
- if (changes == nil)
205
- changes = [[NSMutableArray alloc] init];
206
- if (mutatedGroups == nil)
207
- mutatedGroups = [[NSMutableSet alloc] init];
208
- }
209
-
210
- /**
211
- * Invoked by our YapDatabaseViewTransaction at the completion of the rollbackTransaction method.
212
- **/
213
- - (void)postRollbackCleanup
214
- {
215
- YDBLogAutoTrace();
216
-
217
- group_pagesMetadata_dict = nil;
218
- pageKey_group_dict = nil;
219
-
220
- [mapCache removeAllObjects];
221
- [pageCache removeAllObjects];
222
-
223
- [dirtyMaps removeAllObjects];
224
- [dirtyPages removeAllObjects];
225
- [dirtyLinks removeAllObjects];
226
- reset = NO;
227
-
228
- [changes removeAllObjects];
229
- }
230
-
231
- /**
232
- * Invoked by our YapDatabaseViewTransaction at the completion of the commitTransaction method.
233
- **/
234
- - (void)postCommitCleanup
235
- {
236
- // This code is best understood alongside the getExternalChangeset:internalChangeset: method (below).
237
-
238
- // Both dirtyKeys & dirtyPages are sent in the internalChangeset.
239
- // So we need completely new versions of them.
240
-
241
- if ([dirtyMaps count] > 0)
242
- dirtyMaps = nil;
243
-
244
- if ([dirtyPages count] > 0)
245
- dirtyPages = nil;
246
-
247
- // dirtyLinks isn't part of the changeset.
248
- // So it's safe to simply reset.
249
-
250
- [dirtyLinks removeAllObjects];
251
-
252
- // The changes log is copied into the external changeset.
253
- // So it's safe to simply reset.
254
-
255
- [changes removeAllObjects];
256
- [mutatedGroups removeAllObjects];
257
-
258
- reset = NO;
259
- }
260
-
261
- - (NSArray *)internalChangesetKeys
262
- {
263
- return @[ key_dirtyMaps,
264
- key_dirtyPages,
265
- key_reset,
266
- key_group_pagesMetadata_dict,
267
- key_pageKey_group_dict ];
268
- }
269
-
270
- - (NSArray *)externalChangesetKeys
271
- {
272
- return @[ key_changes ];
273
- }
274
-
275
- - (void)getInternalChangeset:(NSMutableDictionary **)internalChangesetPtr
276
- externalChangeset:(NSMutableDictionary **)externalChangesetPtr
277
- hasDiskChanges:(BOOL *)hasDiskChangesPtr
278
- {
279
- YDBLogAutoTrace();
280
-
281
- NSMutableDictionary *internalChangeset = nil;
282
- NSMutableDictionary *externalChangeset = nil;
283
- BOOL hasDiskChanges = NO;
284
-
285
- if ([dirtyMaps count] > 0 ||
286
- [dirtyPages count] > 0 ||
287
- [dirtyLinks count] > 0 || reset)
288
- {
289
- hasDiskChanges = view->options.isPersistent;
290
- internalChangeset = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySetForInternalChangeset];
291
-
292
- if ([dirtyMaps count] > 0)
293
- {
294
- [internalChangeset setObject:dirtyMaps forKey:key_dirtyMaps];
295
- }
296
- if ([dirtyPages count] > 0)
297
- {
298
- [self sanitizeDirtyPages];
299
- [internalChangeset setObject:dirtyPages forKey:key_dirtyPages];
300
- }
301
-
302
- if (reset)
303
- {
304
- [internalChangeset setObject:@(reset) forKey:key_reset];
305
- }
306
-
307
- NSMutableDictionary *group_pagesMetadata_dict_copy;
308
- NSMutableDictionary *pageKey_group_dict_copy;
309
-
310
- group_pagesMetadata_dict_copy = [self group_pagesMetadata_dict_deepCopy:group_pagesMetadata_dict];
311
- pageKey_group_dict_copy = [pageKey_group_dict mutableCopy];
312
-
313
- [internalChangeset setObject:group_pagesMetadata_dict_copy forKey:key_group_pagesMetadata_dict];
314
- [internalChangeset setObject:pageKey_group_dict_copy forKey:key_pageKey_group_dict];
315
- }
316
-
317
- if ([changes count] > 0)
318
- {
319
- externalChangeset = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySetForExternalChangeset];
320
-
321
- [externalChangeset setObject:[changes copy] forKey:key_changes];
322
- }
323
-
324
- *internalChangesetPtr = internalChangeset;
325
- *externalChangesetPtr = externalChangeset;
326
- *hasDiskChangesPtr = hasDiskChanges;
327
- }
328
-
329
- - (void)processChangeset:(NSDictionary *)changeset
330
- {
331
- YDBLogAutoTrace();
332
-
333
- NSMutableDictionary *changeset_group_pagesMetadata_dict = [changeset objectForKey:key_group_pagesMetadata_dict];
334
- NSMutableDictionary *changeset_pageKey_group_dict = [changeset objectForKey:key_pageKey_group_dict];
335
-
336
- NSDictionary *changeset_dirtyMaps = [changeset objectForKey:key_dirtyMaps];
337
- NSDictionary *changeset_dirtyPages = [changeset objectForKey:key_dirtyPages];
338
-
339
- BOOL changeset_reset = [[changeset objectForKey:key_reset] boolValue];
340
-
341
- // Perform proper deep copies
342
- //
343
- // Note: we make copies from changeset_dirtyPages on demand below via:
344
- // - [pageCache setObject:[page copy] forKey:pageKey];
345
-
346
- changeset_group_pagesMetadata_dict = [self group_pagesMetadata_dict_deepCopy:changeset_group_pagesMetadata_dict];
347
- changeset_pageKey_group_dict = [changeset_pageKey_group_dict mutableCopy];
348
-
349
- // Store new top level objects
350
-
351
- group_pagesMetadata_dict = changeset_group_pagesMetadata_dict;
352
- pageKey_group_dict = changeset_pageKey_group_dict;
353
-
354
- // Update mapCache
355
-
356
- if (changeset_reset && ([changeset_dirtyMaps count] == 0))
357
- {
358
- [mapCache removeAllObjects];
359
- }
360
- else if ([changeset_dirtyMaps count] > 0)
361
- {
362
- NSUInteger removeCapacity = [mapCache count];
363
- NSUInteger updateCapacity = MIN([mapCache count], [changeset_dirtyMaps count]);
364
-
365
- NSMutableArray *keysToRemove = [NSMutableArray arrayWithCapacity:removeCapacity];
366
- NSMutableArray *keysToUpdate = [NSMutableArray arrayWithCapacity:updateCapacity];
367
-
368
- [mapCache enumerateKeysWithBlock:^(id key, BOOL *stop) {
369
-
370
- // Order matters.
371
- // Consider the following database change:
372
- //
373
- // [transaction removeAllObjects];
374
- // [transaction setObject:obj forKey:key];
375
-
376
- if ([changeset_dirtyMaps objectForKey:key])
377
- [keysToUpdate addObject:key];
378
- else if (changeset_reset)
379
- [keysToRemove addObject:key];
380
- }];
381
-
382
- [mapCache removeObjectsForKeys:keysToRemove];
383
-
384
- NSNull *nsnull = [NSNull null];
385
-
386
- for (NSString *key in keysToUpdate)
387
- {
388
- NSString *pageKey = [changeset_dirtyMaps objectForKey:key];
389
-
390
- if ((id)pageKey == nsnull)
391
- [mapCache removeObjectForKey:key];
392
- else
393
- [mapCache setObject:pageKey forKey:key];
394
- }
395
- }
396
-
397
- // Update pageCache
398
-
399
- if (changeset_reset && ([changeset_dirtyPages count] == 0))
400
- {
401
- [pageCache removeAllObjects];
402
- }
403
- else if ([changeset_dirtyPages count])
404
- {
405
- NSUInteger removeCapacity = [pageCache count];
406
- NSUInteger updateCapacity = MIN([pageCache count], [changeset_dirtyPages count]);
407
-
408
- NSMutableArray *keysToRemove = [NSMutableArray arrayWithCapacity:removeCapacity];
409
- NSMutableArray *keysToUpdate = [NSMutableArray arrayWithCapacity:updateCapacity];
410
-
411
- [pageCache enumerateKeysWithBlock:^(id key, BOOL *stop) {
412
-
413
- // Order matters.
414
- // Consider the following database change:
415
- //
416
- // [transaction removeAllObjects];
417
- // [transaction setObject:obj forKey:key];
418
-
419
- if ([changeset_dirtyPages objectForKey:key])
420
- [keysToUpdate addObject:key];
421
- else if (changeset_reset)
422
- [keysToRemove addObject:key];
423
- }];
424
-
425
- [pageCache removeObjectsForKeys:keysToRemove];
426
-
427
- NSNull *nsnull = [NSNull null];
428
-
429
- for (NSString *pageKey in keysToUpdate)
430
- {
431
- YapDatabaseViewPage *page = [changeset_dirtyPages objectForKey:pageKey];
432
-
433
- // Each viewConnection needs its own independent mutable copy of the page.
434
- // Mutable pages cannot be shared between multiple view connections.
435
-
436
- if ((id)page == nsnull)
437
- [pageCache removeObjectForKey:pageKey];
438
- else
439
- [pageCache setObject:[page copy] forKey:pageKey];
440
- }
441
- }
442
- }
443
-
444
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
445
- #pragma mark Changeset Inspection
446
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
447
-
448
- /**
449
- * Gets an exact list of changes that happend to the view, translating groups to sections as requested.
450
- * See the header file for more information.
451
- **/
452
- - (void)getSectionChanges:(NSArray **)sectionChangesPtr
453
- rowChanges:(NSArray **)rowChangesPtr
454
- forNotifications:(NSArray *)notifications
455
- withMappings:(YapDatabaseViewMappings *)mappings
456
- {
457
- if (mappings == nil)
458
- {
459
- YDBLogWarn(@"%@ - mappings parameter is nil", THIS_METHOD);
460
-
461
- if (sectionChangesPtr) *sectionChangesPtr = nil;
462
- if (rowChangesPtr) *rowChangesPtr = nil;
463
-
464
- return;
465
- }
466
- if (mappings.snapshotOfLastUpdate == UINT64_MAX)
467
- {
468
- NSString *reason = [NSString stringWithFormat:
469
- @"ViewConnection[%p, RegisteredName=%@] was asked for changes, but given bad mappings.",
470
- self, view.registeredName];
471
-
472
- NSDictionary *userInfo = @{ NSLocalizedRecoverySuggestionErrorKey:
473
- @"The given mappings have not been properly initialized."
474
- @" You need to invoke [mappings updateWithTransaction:transaction] once in order to initialize"
475
- @" the mappings object. You should do this after invoking"
476
- @" [databaseConnection beginLongLivedReadTransaction]. For example code, please see"
477
- @" YapDatabaseViewMappings.h, or see the wiki: https://github.com/yaptv/YapDatabase/wiki/Views"};
478
-
479
- @throw [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
480
- }
481
-
482
- NSString *registeredName = self.view.registeredName;
483
- NSMutableArray *all_changes = [NSMutableArray array];
484
-
485
- for (NSNotification *notification in notifications)
486
- {
487
- NSDictionary *changeset =
488
- [[notification.userInfo objectForKey:YapDatabaseExtensionsKey] objectForKey:registeredName];
489
-
490
- NSArray *changeset_changes = [changeset objectForKey:key_changes];
491
-
492
- [all_changes addObjectsFromArray:changeset_changes];
493
- }
494
-
495
- YapDatabaseViewMappings *originalMappings = [mappings copy];
496
- __block BOOL isLongLivedReadTransaction = NO;
497
-
498
- [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
499
-
500
- isLongLivedReadTransaction = transaction.connection.isInLongLivedReadTransaction;
501
- [mappings updateWithTransaction:transaction];
502
- }];
503
-
504
- if ([notifications count] > 0)
505
- {
506
- NSDictionary *firstChangeset = [[notifications objectAtIndex:0] userInfo];
507
- NSDictionary *lastChangeset = [[notifications lastObject] userInfo];
508
-
509
- uint64_t firstSnapshot = [[firstChangeset objectForKey:YapDatabaseSnapshotKey] unsignedLongLongValue];
510
- uint64_t lastSnapshot = [[lastChangeset objectForKey:YapDatabaseSnapshotKey] unsignedLongLongValue];
511
-
512
- if ((originalMappings.snapshotOfLastUpdate != (firstSnapshot - 1)) ||
513
- (mappings.snapshotOfLastUpdate != lastSnapshot))
514
- {
515
- NSString *reason = [NSString stringWithFormat:
516
- @"ViewConnection[%p, RegisteredName=%@] was asked for changes,"
517
- @" but given mismatched mappings & notifications.", self, view.registeredName];
518
-
519
- NSString *failureReason = [NSString stringWithFormat:
520
- @"preMappings.snapshotOfLastUpdate: expected(%llu) != found(%llu), "
521
- @"postMappings.snapshotOfLastUpdate: expected(%llu) != found(%llu), "
522
- @"isLongLivedReadTransaction = %@",
523
- originalMappings.snapshotOfLastUpdate, (firstSnapshot - 1),
524
- mappings.snapshotOfLastUpdate, lastSnapshot,
525
- (isLongLivedReadTransaction ? @"YES" : @"NO")];
526
-
527
- NSString *suggestion = [NSString stringWithFormat:
528
- @"When you initialize the database, the snapshot (uint64) is set to zero."
529
- @" Every read-write transaction (that makes modifications) increments the snapshot."
530
- @" Now, when you ask the viewConnection for a changeset, "
531
- @" you need to pass matching mappings & notifications. That is, the mappings need to represent the"
532
- @" database at snapshot X, and the notifications need to represent the database at snapshots"
533
- @" @[ X+1, X+2, ...]. This does not appear to be the case. This most often happens when the"
534
- @" databaseConnection isn't using a longLivedReadTransaction. And this happens by accident"
535
- @" most often when you use a databaseConnection, which is in a longLivedReadTransaction, to perform"
536
- @" a read-write transaction. Doing so implicitly forces the connection out of the"
537
- @" longLivedReadTransaction, and moves it to the most recent snapshot. If this is the case,"
538
- @" be sure to use a separate connection for your read-write transaction."];
539
-
540
- NSDictionary *userInfo = @{
541
- NSLocalizedFailureReasonErrorKey: failureReason,
542
- NSLocalizedRecoverySuggestionErrorKey: suggestion };
543
-
544
- // If we don't throw the exception here,
545
- // then you'll just get an exception later from the tableView or collectionView.
546
- // It will look something like this:
547
- //
548
- // > Invalid update: invalid number of rows in section X. The number of rows contained in an
549
- // > existing section after the update (Y) must be equal to the number of rows contained in that section
550
- // > before the update (Z), plus or minus the number of rows inserted or deleted from that
551
- // > section (# inserted, # deleted).
552
- //
553
- // In order to guarantee you DON'T get an exception (either from YapDatabase or from Apple),
554
- // then you need to follow the instructions for setting up your connection, mappings, & notifications.
555
- //
556
- // For complete code samples, check out the wiki:
557
- // https://github.com/yaptv/YapDatabase/wiki/Views
558
- //
559
- // You may be tempted to simply comment out the exception below.
560
- // If you do, you're not fixing the root cause of your problem.
561
- // Furthermore, you're simply trading this exception, which comes with documented steps on how
562
- // to fix the problem, for an exception from Apple which will be even harder to diagnose.
563
-
564
- @throw [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
565
- }
566
-
567
- if (!isLongLivedReadTransaction)
568
- {
569
- YDBLogWarn(@"%@ - The databaseConnection is NOT in a longLivedReadTransaction."
570
- @" It needs to be in order to guarantee"
571
- @" (A) you can provide a stable data-source for your UI thread and"
572
- @" (B) you can get changesets which match the movement from one"
573
- @" stable data-source state to another. If you think your databaseConnection IS"
574
- @" in a longLivedReadTransaction, then perhaps you aborted it by accident."
575
- @" This generally happens when you use a databaseConnection,"
576
- @" which is in a longLivedReadTransaction, to perform a read-write transaction."
577
- @" Doing so implicitly forces the connection out of the longLivedReadTransaction,"
578
- @" and moves it to the most recent snapshot. If this is the case,"
579
- @" be sure to use a separate connection for your read-write transaction.", THIS_METHOD);
580
- }
581
- }
582
-
583
- [YapDatabaseViewChange getSectionChanges:sectionChangesPtr
584
- rowChanges:rowChangesPtr
585
- withOriginalMappings:originalMappings
586
- finalMappings:mappings
587
- fromChanges:all_changes];
588
- }
589
-
590
- /**
591
- * A simple YES/NO query to see if the view changed at all, inclusive of all groups.
592
- **/
593
- - (BOOL)hasChangesForNotifications:(NSArray *)notifications
594
- {
595
- NSString *registeredName = self.view.registeredName;
596
-
597
- for (NSNotification *notification in notifications)
598
- {
599
- NSDictionary *changeset =
600
- [[notification.userInfo objectForKey:YapDatabaseExtensionsKey] objectForKey:registeredName];
601
-
602
- NSArray *changeset_changes = [changeset objectForKey:key_changes];
603
-
604
- if ([changeset_changes count] > 0)
605
- {
606
- return YES;
607
- }
608
- }
609
-
610
- return NO;
611
- }
612
-
613
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
614
- #pragma mark Statements - KeyTable
615
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
616
-
617
- - (sqlite3_stmt *)mapTable_getPageKeyForRowidStatement
618
- {
619
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
620
-
621
- if (mapTable_getPageKeyForRowidStatement == NULL)
622
- {
623
- NSString *string = [NSString stringWithFormat:
624
- @"SELECT \"pageKey\" FROM \"%@\" WHERE \"rowid\" = ?;", [view mapTableName]];
625
-
626
- sqlite3 *db = databaseConnection->db;
627
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
628
-
629
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_getPageKeyForRowidStatement, NULL);
630
- if (status != SQLITE_OK)
631
- {
632
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
633
- }
634
-
635
- FreeYapDatabaseString(&stmt);
636
- }
637
-
638
- return mapTable_getPageKeyForRowidStatement;
639
- }
640
-
641
- - (sqlite3_stmt *)mapTable_setPageKeyForRowidStatement
642
- {
643
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
644
-
645
- if (mapTable_setPageKeyForRowidStatement == NULL)
646
- {
647
- NSString *string = [NSString stringWithFormat:
648
- @"INSERT OR REPLACE INTO \"%@\" (\"rowid\", \"pageKey\") VALUES (?, ?);", [view mapTableName]];
649
-
650
- sqlite3 *db = databaseConnection->db;
651
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
652
-
653
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_setPageKeyForRowidStatement, NULL);
654
- if (status != SQLITE_OK)
655
- {
656
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
657
- }
658
-
659
- FreeYapDatabaseString(&stmt);
660
- }
661
-
662
- return mapTable_setPageKeyForRowidStatement;
663
- }
664
-
665
- - (sqlite3_stmt *)mapTable_removeForRowidStatement
666
- {
667
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
668
-
669
- if (mapTable_removeForRowidStatement == NULL)
670
- {
671
- NSString *string = [NSString stringWithFormat:
672
- @"DELETE FROM \"%@\" WHERE \"rowid\" = ?;", [view mapTableName]];
673
-
674
- sqlite3 *db = databaseConnection->db;
675
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
676
-
677
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_removeForRowidStatement, NULL);
678
- if (status != SQLITE_OK)
679
- {
680
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
681
- }
682
-
683
- FreeYapDatabaseString(&stmt);
684
- }
685
-
686
- return mapTable_removeForRowidStatement;
687
- }
688
-
689
- - (sqlite3_stmt *)mapTable_removeAllStatement
690
- {
691
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
692
-
693
- if (mapTable_removeAllStatement == NULL)
694
- {
695
- NSString *string = [NSString stringWithFormat:
696
- @"DELETE FROM \"%@\";", [view mapTableName]];
697
-
698
- sqlite3 *db = databaseConnection->db;
699
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
700
-
701
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &mapTable_removeAllStatement, NULL);
702
- if (status != SQLITE_OK)
703
- {
704
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
705
- }
706
-
707
- FreeYapDatabaseString(&stmt);
708
- }
709
-
710
- return mapTable_removeAllStatement;
711
- }
712
-
713
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
714
- #pragma mark Statements - PageTable
715
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
716
-
717
- - (sqlite3_stmt *)pageTable_getDataForPageKeyStatement
718
- {
719
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
720
-
721
- if (pageTable_getDataForPageKeyStatement == NULL)
722
- {
723
- NSString *string = [NSString stringWithFormat:
724
- @"SELECT \"data\" FROM \"%@\" WHERE \"pageKey\" = ?;", [view pageTableName]];
725
-
726
- sqlite3 *db = databaseConnection->db;
727
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
728
-
729
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_getDataForPageKeyStatement, NULL);
730
- if (status != SQLITE_OK)
731
- {
732
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
733
- }
734
-
735
- FreeYapDatabaseString(&stmt);
736
- }
737
-
738
- return pageTable_getDataForPageKeyStatement;
739
- }
740
-
741
- - (sqlite3_stmt *)pageTable_insertForPageKeyStatement
742
- {
743
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
744
-
745
- if (pageTable_insertForPageKeyStatement == NULL)
746
- {
747
- NSString *string = [NSString stringWithFormat:
748
- @"INSERT INTO \"%@\""
749
- @" (\"pageKey\", \"group\", \"prevPageKey\", \"count\", \"data\") VALUES (?, ?, ?, ?, ?);",
750
- [view pageTableName]];
751
-
752
- sqlite3 *db = databaseConnection->db;
753
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
754
-
755
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_insertForPageKeyStatement, NULL);
756
- if (status != SQLITE_OK)
757
- {
758
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
759
- }
760
-
761
- FreeYapDatabaseString(&stmt);
762
- }
763
-
764
- return pageTable_insertForPageKeyStatement;
765
- }
766
-
767
- - (sqlite3_stmt *)pageTable_updateAllForPageKeyStatement
768
- {
769
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
770
-
771
- if (pageTable_updateAllForPageKeyStatement == NULL)
772
- {
773
- NSString *string = [NSString stringWithFormat:
774
- @"UPDATE \"%@\" SET \"prevPageKey\" = ?, \"count\" = ?, \"data\" = ? WHERE \"pageKey\" = ?;",
775
- [view pageTableName]];
776
-
777
- sqlite3 *db = databaseConnection->db;
778
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
779
-
780
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_updateAllForPageKeyStatement, NULL);
781
- if (status != SQLITE_OK)
782
- {
783
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
784
- }
785
-
786
- FreeYapDatabaseString(&stmt);
787
- }
788
-
789
- return pageTable_updateAllForPageKeyStatement;
790
- }
791
-
792
- - (sqlite3_stmt *)pageTable_updatePageForPageKeyStatement
793
- {
794
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
795
-
796
- if (pageTable_updatePageForPageKeyStatement == NULL)
797
- {
798
- NSString *string = [NSString stringWithFormat:
799
- @"UPDATE \"%@\" SET \"count\" = ?, \"data\" = ? WHERE \"pageKey\" = ?;", [view pageTableName]];
800
-
801
- sqlite3 *db = databaseConnection->db;
802
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
803
-
804
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_updatePageForPageKeyStatement, NULL);
805
- if (status != SQLITE_OK)
806
- {
807
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
808
- }
809
-
810
- FreeYapDatabaseString(&stmt);
811
- }
812
-
813
- return pageTable_updatePageForPageKeyStatement;
814
- }
815
-
816
- - (sqlite3_stmt *)pageTable_updateLinkForPageKeyStatement
817
- {
818
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
819
-
820
- if (pageTable_updateLinkForPageKeyStatement == NULL)
821
- {
822
- NSString *string = [NSString stringWithFormat:
823
- @"UPDATE \"%@\" SET \"prevPageKey\" = ? WHERE \"pageKey\" = ?;", [view pageTableName]];
824
-
825
- sqlite3 *db = databaseConnection->db;
826
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
827
-
828
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_updateLinkForPageKeyStatement, NULL);
829
- if (status != SQLITE_OK)
830
- {
831
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
832
- }
833
-
834
- FreeYapDatabaseString(&stmt);
835
- }
836
-
837
- return pageTable_updateLinkForPageKeyStatement;
838
- }
839
-
840
- - (sqlite3_stmt *)pageTable_removeForPageKeyStatement
841
- {
842
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
843
-
844
- if (pageTable_removeForPageKeyStatement == NULL)
845
- {
846
- NSString *string = [NSString stringWithFormat:
847
- @"DELETE FROM \"%@\" WHERE \"pageKey\" = ?;", [view pageTableName]];
848
-
849
- sqlite3 *db = databaseConnection->db;
850
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
851
-
852
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_removeForPageKeyStatement, NULL);
853
- if (status != SQLITE_OK)
854
- {
855
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
856
- }
857
-
858
- FreeYapDatabaseString(&stmt);
859
- }
860
-
861
- return pageTable_removeForPageKeyStatement;
862
- }
863
-
864
- - (sqlite3_stmt *)pageTable_removeAllStatement
865
- {
866
- NSAssert(view->options.isPersistent, @"In-memory view accessing sqlite");
867
-
868
- if (pageTable_removeAllStatement == NULL)
869
- {
870
- NSString *string = [NSString stringWithFormat:
871
- @"DELETE FROM \"%@\";", [view pageTableName]];
872
-
873
- sqlite3 *db = databaseConnection->db;
874
- YapDatabaseString stmt; MakeYapDatabaseString(&stmt, string);
875
-
876
- int status = sqlite3_prepare_v2(db, stmt.str, stmt.length+1, &pageTable_removeAllStatement, NULL);
877
- if (status != SQLITE_OK)
878
- {
879
- YDBLogError(@"%@: Error creating prepared statement: %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
880
- }
881
-
882
- FreeYapDatabaseString(&stmt);
883
- }
884
-
885
- return pageTable_removeAllStatement;
886
- }
887
-
888
- @end