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,1714 +0,0 @@
1
- #import "YapDatabaseViewMappingsPrivate.h"
2
- #import "YapDatabaseViewRangeOptionsPrivate.h"
3
- #import "YapDatabaseViewTransaction.h"
4
-
5
- #import "YapDatabasePrivate.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
-
24
- @implementation YapDatabaseViewMappings
25
- {
26
- // Immutable init parameters
27
- NSString *registeredViewName;
28
-
29
- NSArray *allGroups;
30
-
31
- BOOL viewGroupsAreDynamic;
32
- YapDatabaseViewMappingGroupFilter groupFilterBlock;
33
- YapDatabaseViewMappingGroupSort groupSort;
34
-
35
- // Mappings and cached counts
36
- NSMutableArray *visibleGroups;
37
- NSMutableDictionary *counts;
38
- BOOL isUsingConsolidatedGroup;
39
- BOOL autoConsolidationDisabled;
40
- BOOL isDynamicSectionForAllGroups;
41
-
42
- // Configuration
43
- NSMutableSet *dynamicSections;
44
- NSMutableSet *reverse;
45
- NSMutableDictionary *rangeOptions;
46
- NSMutableDictionary *dependencies;
47
- NSUInteger autoConsolidateGroupsThreshold;
48
- NSString *consolidatedGroupName;
49
-
50
- // Snapshot (used for error detection)
51
- uint64_t snapshotOfLastUpdate;
52
- }
53
-
54
- @synthesize allGroups = allGroups;
55
- @synthesize view = registeredViewName;
56
-
57
- @synthesize snapshotOfLastUpdate = snapshotOfLastUpdate;
58
-
59
- + (instancetype)mappingsWithGroups:(NSArray *)inGroups view:(NSString *)inRegisteredViewName
60
- {
61
- return [[YapDatabaseViewMappings alloc] initWithGroups:inGroups view:inRegisteredViewName];
62
- }
63
-
64
- - (id)initWithGroups:(NSArray *)inGroups
65
- view:(NSString *)inRegisteredViewName
66
- {
67
- if ((self = [super init]))
68
- {
69
- allGroups = [[NSArray alloc] initWithArray:inGroups copyItems:YES];
70
- NSUInteger allGroupsCount = [allGroups count];
71
- viewGroupsAreDynamic = NO;
72
-
73
- visibleGroups = [[NSMutableArray alloc] initWithCapacity:allGroupsCount];
74
- dynamicSections = [[NSMutableSet alloc] initWithCapacity:allGroupsCount];
75
- reverse = [[NSMutableSet alloc] initWithCapacity:allGroupsCount];
76
-
77
- id sharedKeySet = [NSDictionary sharedKeySetForKeys:allGroups];
78
- counts = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
79
- rangeOptions = [NSMutableDictionary dictionaryWithCapacity:allGroupsCount];
80
- dependencies = [NSMutableDictionary dictionaryWithCapacity:allGroupsCount];
81
-
82
- [self _initWithView:inRegisteredViewName];
83
-
84
- }
85
- return self;
86
- }
87
-
88
- - (id)initWithGroupFilterBlock:(YapDatabaseViewMappingGroupFilter)inFilter sortBlock:(YapDatabaseViewMappingGroupSort)inSort view:(NSString *)inRegisteredViewName{
89
- if (self = [super init]){
90
- groupFilterBlock = inFilter;
91
- groupSort = inSort;
92
- viewGroupsAreDynamic = YES;
93
-
94
- //we don't know what our capacity is going to be yet.
95
- visibleGroups = [NSMutableArray new];
96
- dynamicSections = [NSMutableSet new];
97
- reverse = [NSMutableSet new];
98
- rangeOptions = [NSMutableDictionary new];
99
- dependencies = [NSMutableDictionary new];
100
-
101
- [self _initWithView:inRegisteredViewName];
102
- }
103
- return self;
104
- }
105
-
106
- - (void)_initWithView:(NSString *)inRegisteredViewName{
107
- registeredViewName = [inRegisteredViewName copy];
108
- snapshotOfLastUpdate = UINT64_MAX;
109
- }
110
-
111
- - (id)copyWithZone:(NSZone *)zone
112
- {
113
- YapDatabaseViewMappings *copy = [[YapDatabaseViewMappings alloc] init];
114
- copy->allGroups = allGroups;
115
- copy->registeredViewName = registeredViewName;
116
-
117
- copy->viewGroupsAreDynamic = viewGroupsAreDynamic;
118
- copy->groupFilterBlock = groupFilterBlock;
119
- copy->groupSort = groupSort;
120
-
121
- copy->visibleGroups = [visibleGroups mutableCopy];
122
- copy->counts = [counts mutableCopy];
123
- copy->isUsingConsolidatedGroup = isUsingConsolidatedGroup;
124
- copy->autoConsolidationDisabled = autoConsolidationDisabled;
125
-
126
- copy->isDynamicSectionForAllGroups = isDynamicSectionForAllGroups;
127
- copy->dynamicSections = [dynamicSections mutableCopy];
128
- copy->reverse = [reverse mutableCopy];
129
- copy->rangeOptions = [rangeOptions mutableCopy];
130
- copy->dependencies = [dependencies mutableCopy];
131
- copy->autoConsolidateGroupsThreshold = autoConsolidateGroupsThreshold;
132
- copy->consolidatedGroupName = consolidatedGroupName;
133
-
134
- copy->snapshotOfLastUpdate = snapshotOfLastUpdate;
135
-
136
- return copy;
137
- }
138
-
139
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
140
- #pragma mark Configuration
141
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
142
-
143
- - (void)setIsDynamicSectionForAllGroups:(BOOL)isDynamic
144
- {
145
- isDynamicSectionForAllGroups = isDynamic;
146
- }
147
-
148
- - (BOOL)isDynamicSectionForAllGroups
149
- {
150
- return isDynamicSectionForAllGroups;
151
- }
152
-
153
- - (BOOL)isGroupNameValid:(NSString *)group{
154
- return viewGroupsAreDynamic || [allGroups containsObject:group];
155
- }
156
-
157
- - (void)setIsDynamicSection:(BOOL)isDynamic forGroup:(NSString *)group
158
- {
159
- if (![self isGroupNameValid:group]) {
160
- YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
161
- return;
162
- }
163
-
164
- if (isDynamic)
165
- [dynamicSections addObject:group];
166
- else
167
- [dynamicSections removeObject:group];
168
- }
169
-
170
- - (BOOL)isDynamicSectionForGroup:(NSString *)group
171
- {
172
- return [dynamicSections containsObject:group];
173
- }
174
-
175
- - (void)setRangeOptions:(YapDatabaseViewRangeOptions *)rangeOpts forGroup:(NSString *)group
176
- {
177
- if (rangeOpts == nil) {
178
- [self removeRangeOptionsForGroup:group];
179
- return;
180
- }
181
-
182
- if (![self isGroupNameValid:group]){
183
- YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
184
- return;
185
- }
186
-
187
- // Store private immutable copy
188
- if ([reverse containsObject:group])
189
- rangeOpts = [rangeOpts copyAndReverse];
190
- else
191
- rangeOpts = [rangeOpts copy];
192
-
193
- if (snapshotOfLastUpdate == UINT64_MAX)
194
- {
195
- // We don't have the counts yet, so we can't set rangeOpts.length yet.
196
-
197
- [rangeOptions setObject:rangeOpts forKey:group];
198
- }
199
- else
200
- {
201
- // Normal setter logic
202
-
203
- [self updateRangeOptions:rangeOpts forGroup:group];
204
- [self updateVisibility];
205
- }
206
- }
207
-
208
- - (YapDatabaseViewRangeOptions *)rangeOptionsForGroup:(NSString *)group
209
- {
210
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
211
-
212
- // Return copy. Our internal version must remain immutable.
213
-
214
- if ([reverse containsObject:group])
215
- return [rangeOpts copyAndReverse];
216
- else
217
- return [rangeOpts copy];
218
- }
219
-
220
- - (void)removeRangeOptionsForGroup:(NSString *)group
221
- {
222
- [rangeOptions removeObjectForKey:group];
223
- }
224
-
225
- - (void)setCellDrawingDependencyForNeighboringCellWithOffset:(NSInteger)offset forGroup:(NSString *)group
226
- {
227
- [self setCellDrawingDependencyOffsets:[NSSet setWithObject:@(offset)] forGroup:group];
228
- }
229
-
230
- - (void)setCellDrawingDependencyOffsets:(NSSet *)offsets forGroup:(NSString *)group
231
- {
232
-
233
- if (![self isGroupNameValid:group]){
234
- YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
235
- return;
236
- }
237
-
238
- NSMutableSet *validOffsets = [NSMutableSet setWithCapacity:[offsets count]];
239
- BOOL needsReverse = [reverse containsObject:group];
240
-
241
- for (id obj in offsets)
242
- {
243
- if ([obj isKindOfClass:[NSNumber class]])
244
- {
245
- NSInteger offset = [obj integerValue];
246
- if (offset != 0)
247
- {
248
- if (needsReverse)
249
- [validOffsets addObject:@(offset * -1)];
250
- else
251
- [validOffsets addObject:obj];
252
- }
253
- }
254
- else
255
- {
256
- YDBLogWarn(@"%@ - Non-NSNumber passed in offsets: %@", THIS_METHOD, obj);
257
- }
258
- }
259
-
260
- [dependencies setObject:[validOffsets copy] forKey:group];
261
- }
262
-
263
- - (NSSet *)cellDrawingDependencyOffsetsForGroup:(NSString *)group
264
- {
265
- NSSet *offsets = [dependencies objectForKey:group];
266
-
267
- if ([reverse containsObject:group])
268
- {
269
- NSMutableSet *reverseOffsets = [NSMutableSet setWithCapacity:[offsets count]];
270
- for (NSNumber *obj in offsets)
271
- {
272
- NSUInteger offset = [obj integerValue];
273
- [reverseOffsets addObject:@(offset * -1)];
274
- }
275
-
276
- return [reverseOffsets copy];
277
- }
278
- else
279
- {
280
- return offsets;
281
- }
282
- }
283
-
284
- - (void)setIsReversed:(BOOL)isReversed forGroup:(NSString *)group
285
- {
286
- if (![self isGroupNameValid:group]){
287
- YDBLogWarn(@"%@ - mappings doesn't contain group(%@), only: %@", THIS_METHOD, group, allGroups);
288
- return;
289
- }
290
-
291
- if (isReversed)
292
- [reverse addObject:group];
293
- else
294
- [reverse removeObject:group];
295
- }
296
-
297
- - (BOOL)isReversedForGroup:(NSString *)group
298
- {
299
- return [reverse containsObject:group];
300
- }
301
-
302
- - (void)setAutoConsolidateGroupsThreshold:(NSUInteger)threshold withName:(NSString *)inConsolidatedGroupName
303
- {
304
- autoConsolidateGroupsThreshold = threshold;
305
- consolidatedGroupName = [inConsolidatedGroupName copy];
306
- [self validateAutoConsolidation];
307
- }
308
-
309
- - (NSUInteger)autoConsolidateGroupsThreshold
310
- {
311
- return autoConsolidateGroupsThreshold;
312
- }
313
-
314
- - (NSString *)consolidatedGroupName
315
- {
316
- return consolidatedGroupName;
317
- }
318
-
319
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
320
- #pragma mark Initialization & Updates
321
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
322
-
323
- - (void)updateWithTransaction:(YapDatabaseReadTransaction *)transaction
324
- {
325
- if (![transaction->connection isInLongLivedReadTransaction])
326
- {
327
- NSString *reason = @"YapDatabaseViewMappings requires the connection to be in a longLivedReadTransaction.";
328
-
329
- NSString *failureReason =
330
- @"The architecture surrounding mappings is designed to move from one longLivedReadTransaction to another."
331
- @" This allows you to freeze the data-source (databaseConnection) of your UI on a particular commit."
332
- @" And then atomically move the data-source from an older commit to a newer commit in response to"
333
- @" YapDatabaseModifiedNotifications. This ensures that the data-source for your UI remains in a steady"
334
- @" state at all times, and that updates are properly handled using the appropriate update mechanisms"
335
- @" (and properly animated if desired)."
336
- @" For example code, please see the wiki: https://github.com/yaptv/YapDatabase/wiki/Views";
337
-
338
- NSString *suggestion =
339
- @"You must invoke [databaseConnection beginLongLivedReadTransaction] before you initialize the mappings";
340
-
341
- NSDictionary *userInfo = @{
342
- NSLocalizedFailureReasonErrorKey: failureReason,
343
- NSLocalizedRecoverySuggestionErrorKey: suggestion };
344
-
345
- // Here's what you SHOULD be doing: (correct)
346
- //
347
- // [databaseConnection beginLongLivedReadConnection];
348
- // [databaseConnection readWithBlock:^(YapDatabaseConnectionReadTransaction *transaction){
349
- // [mappings updateWithTransaction:transaction];
350
- // }];
351
- //
352
- // Here's what you ARE doing: (wrong)
353
- //
354
- // [databaseConnection readWithBlock:^(YapDatabaseConnectionReadTransaction *transaction){
355
- // [mappings updateWithTransaction:transaction];
356
- // }];
357
- // [databaseConnection beginLongLivedReadConnection];
358
- //
359
- //
360
- // Warning: Do NOT, under any circumstance, comment out this exception.
361
-
362
- @throw [NSException exceptionWithName:@"YapDatabaseException" reason:reason userInfo:userInfo];
363
- }
364
-
365
- YapDatabaseViewTransaction *viewTransaction = [transaction ext:registeredViewName];
366
- if (viewGroupsAreDynamic)
367
- {
368
- NSArray *newGroups = [self filterAndSortGroups:[viewTransaction allGroups] withTransaction:transaction];
369
- if ([self shouldUpdateAllGroupsWithNewGroups:newGroups]) {
370
- [self updateMappingsWithNewGroups:newGroups];
371
- }
372
- }
373
-
374
- for (NSString *group in allGroups)
375
- {
376
- NSUInteger count = [viewTransaction numberOfKeysInGroup:group];
377
-
378
- [counts setObject:@(count) forKey:group];
379
- }
380
-
381
- BOOL firstUpdate = (snapshotOfLastUpdate == UINT64_MAX);
382
- snapshotOfLastUpdate = [transaction->connection snapshot];
383
-
384
- if (firstUpdate)
385
- [self initializeRangeOptsLength];
386
-
387
- [self updateVisibility];
388
- }
389
-
390
- - (void)updateMappingsWithNewGroups:(NSArray *)newAllGroups
391
- {
392
- allGroups = [newAllGroups copy];
393
- [self validateAutoConsolidation];
394
- id sharedKeySet = [NSDictionary sharedKeySetForKeys:allGroups];
395
- counts = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
396
- }
397
-
398
- - (void)validateAutoConsolidation{
399
- if ([allGroups containsObject:consolidatedGroupName]){
400
- YDBLogWarn(@"%@ - consolidatedGroupName cannot match existing groupName", THIS_METHOD);
401
- consolidatedGroupName = nil;
402
- autoConsolidateGroupsThreshold = 0;
403
- }
404
-
405
- if (consolidatedGroupName == nil || autoConsolidateGroupsThreshold == 0){
406
- consolidatedGroupName = nil;
407
- autoConsolidateGroupsThreshold = 0;
408
- }
409
- }
410
-
411
- - (NSArray *)filterAndSortGroups:(NSArray *)groups withTransaction:(YapDatabaseReadTransaction *)transaction
412
- {
413
- NSMutableArray *newAllGroups = [NSMutableArray arrayWithCapacity:[groups count]];
414
- for (NSString *group in groups)
415
- {
416
- if (groupFilterBlock(group, transaction)) {
417
- [newAllGroups addObject:group];
418
- }
419
- }
420
-
421
- [newAllGroups sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
422
-
423
- return groupSort(obj1, obj2, transaction);
424
- }];
425
-
426
- return [newAllGroups copy];
427
- }
428
-
429
- - (BOOL)shouldUpdateAllGroupsWithNewGroups:(NSArray *)newGroups{
430
- return ![allGroups isEqualToArray:newGroups];
431
- }
432
-
433
-
434
- /**
435
- * This method is internal.
436
- * It is only for use by the unit tests in TestViewChangeLogic.
437
- **/
438
- - (void)updateWithCounts:(NSDictionary *)newCounts
439
- {
440
- if (viewGroupsAreDynamic)
441
- {
442
- // The groups passed in the dictionary represent the new allGroups.
443
- // This simulates as if we ran the groupFilterBlock & groupSortBlock.
444
-
445
- NSArray *newGroups = [newCounts allKeys];
446
- if ([self shouldUpdateAllGroupsWithNewGroups:newGroups]) {
447
- [self updateMappingsWithNewGroups:newGroups];
448
- }
449
- }
450
- for (NSString *group in allGroups)
451
- {
452
- NSUInteger count = [[newCounts objectForKey:group] unsignedIntegerValue];
453
-
454
- [counts setObject:@(count) forKey:group];
455
- }
456
-
457
- BOOL firstUpdate = (snapshotOfLastUpdate == UINT64_MAX);
458
- snapshotOfLastUpdate = 0;
459
-
460
- if (firstUpdate)
461
- [self initializeRangeOptsLength];
462
-
463
- [self updateVisibility];
464
- }
465
-
466
- - (void)initializeRangeOptsLength
467
- {
468
- NSAssert(snapshotOfLastUpdate != UINT64_MAX, @"The counts are needed to set rangeOpts.length");
469
-
470
- for (NSString *group in [rangeOptions allKeys])
471
- {
472
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
473
-
474
- // Go through the internal setter again so all the logic is in the same place.
475
- [self updateRangeOptions:rangeOpts forGroup:group];
476
- }
477
- }
478
-
479
- - (void)updateRangeOptions:(YapDatabaseViewRangeOptions *)rangeOpts forGroup:(NSString *)group
480
- {
481
- // Set a valid rangeOpts.length using the known group count
482
-
483
- NSUInteger count = [[counts objectForKey:group] unsignedIntegerValue];
484
-
485
- NSUInteger desiredLength = rangeOpts.length;
486
- NSUInteger offset = rangeOpts.offset;
487
-
488
- NSUInteger maxLength = (offset >= count) ? 0 : count - offset;
489
- NSUInteger length = MIN(desiredLength, maxLength);
490
-
491
- // Store private immutable copy
492
- rangeOpts = [rangeOpts copyWithNewLength:length];
493
- [rangeOptions setObject:rangeOpts forKey:group];
494
- }
495
-
496
- /**
497
- * This method is used by YapDatabaseViewChange.
498
- *
499
- * After processing changeset(s), the length and/or offset may change.
500
- * The new length and/or offsets are properly calculated,
501
- * and then this method is used to avoid duplicating the calculations.
502
- **/
503
- - (void)updateRangeOptionsForGroup:(NSString *)group withNewLength:(NSUInteger)newLength newOffset:(NSUInteger)newOffset
504
- {
505
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
506
- rangeOpts = [rangeOpts copyWithNewLength:newLength newOffset:newOffset];
507
-
508
- [rangeOptions setObject:rangeOpts forKey:group];
509
- }
510
-
511
- - (void)updateVisibility
512
- {
513
- [visibleGroups removeAllObjects];
514
- NSUInteger totalCount = 0;
515
-
516
- for (NSString *group in allGroups)
517
- {
518
- NSUInteger count;
519
-
520
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
521
- if (rangeOpts)
522
- count = rangeOpts.length;
523
- else
524
- count = [[counts objectForKey:group] unsignedIntegerValue];
525
-
526
- if (count > 0 || ![self isGroupDynamic:group]) {
527
- [visibleGroups addObject:group];
528
- }
529
-
530
- totalCount += count;
531
- }
532
-
533
- if (totalCount < autoConsolidateGroupsThreshold)
534
- isUsingConsolidatedGroup = YES;
535
- else
536
- isUsingConsolidatedGroup = NO;
537
- }
538
-
539
- -(BOOL)isGroupDynamic:(NSString *)group{
540
- if (!isDynamicSectionForAllGroups){
541
- return [dynamicSections containsObject:group];
542
- }
543
- return YES;
544
- }
545
-
546
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
547
- #pragma mark Internal
548
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
549
-
550
- - (NSMutableDictionary *)counts
551
- {
552
- return [counts mutableCopy];
553
- }
554
-
555
- - (NSUInteger)fullCountForGroup:(NSString *)group
556
- {
557
- return [[counts objectForKey:group] unsignedIntegerValue];
558
- }
559
-
560
- - (NSUInteger)visibleCountForGroup:(NSString *)group
561
- {
562
- return [self numberOfItemsInGroup:group];
563
- }
564
-
565
- - (NSDictionary *)rangeOptions
566
- {
567
- return [rangeOptions copy];
568
- }
569
-
570
- - (NSDictionary *)dependencies
571
- {
572
- return [dependencies copy];
573
- }
574
-
575
- - (NSSet *)reverse
576
- {
577
- return [reverse copy];
578
- }
579
-
580
- - (void)setAutoConsolidatingDisabled:(BOOL)disabled
581
- {
582
- autoConsolidationDisabled = disabled;
583
- }
584
-
585
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
586
- #pragma mark Getters
587
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
588
-
589
- /**
590
- * Returns the actual number of visible sections.
591
- *
592
- * This number may be less than the original count of groups passed in the init method.
593
- * That is, if dynamic sections are enabled for one or more groups, and some of these groups have zero items,
594
- * then those groups will be removed from the visible list of groups. And thus the section count may be less.
595
- **/
596
- - (NSUInteger)numberOfSections
597
- {
598
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
599
- return 1;
600
- else
601
- return [visibleGroups count];
602
- }
603
-
604
- /**
605
- * Returns the number of items in the given section.
606
- * @see groupForSection
607
- **/
608
- - (NSUInteger)numberOfItemsInSection:(NSUInteger)section
609
- {
610
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
611
- return [self numberOfItemsInAllGroups];
612
- else
613
- return [self numberOfItemsInGroup:[self groupForSection:section]];
614
- }
615
-
616
- /**
617
- * Returns the number of items in the given group.
618
- *
619
- * This is the cached value from the last time one of the following methods was invoked:
620
- * - updateWithTransaction:
621
- * which should be invoked when the mapping is first created and then will be invoked whenever
622
- * - (void)getSectionChanges:(NSArray **)sectionChangesPtr
623
- * rowChanges:(NSArray **)rowChangesPtr
624
- * forNotifications:(NSArray *)notifications
625
- * withMappings:(YapDatabaseViewMappings *)mappings
626
- * is called on the associated registered YapDatabaseView.
627
- **/
628
- - (NSUInteger)numberOfItemsInGroup:(NSString *)group
629
- {
630
- if (group == nil) return 0;
631
- if (snapshotOfLastUpdate == UINT64_MAX) return 0;
632
-
633
- if (isUsingConsolidatedGroup && [consolidatedGroupName isEqualToString:group])
634
- {
635
- return [self numberOfItemsInAllGroups];
636
- }
637
-
638
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
639
- if (rangeOpts)
640
- {
641
- return rangeOpts.length;
642
- }
643
- else
644
- {
645
- return [[counts objectForKey:group] unsignedIntegerValue];
646
- }
647
- }
648
-
649
- /**
650
- * The visibleGroups property returns the current sections setup.
651
- * That is, it only contains the visible groups that are being represented as sections in the view.
652
- *
653
- * If all sections are static, then visibleGroups will always be the same as allGroups.
654
- * However, if one or more sections are dynamic, then the visible groups may be a subset of allGroups.
655
- *
656
- * Dynamic groups/sections automatically "disappear" if/when they become empty.
657
- **/
658
- - (NSArray *)visibleGroups
659
- {
660
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
661
- return [NSArray arrayWithObjects:consolidatedGroupName, nil];
662
- else
663
- return [visibleGroups copy];
664
- }
665
-
666
- /**
667
- * Returns YES if there are zero items in all sections/groups.
668
- **/
669
- - (BOOL)isEmpty
670
- {
671
- if (snapshotOfLastUpdate == UINT64_MAX) return YES;
672
-
673
- for (NSString *group in visibleGroups) // NOT [self visibleGroups]
674
- {
675
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
676
- if (rangeOpts)
677
- {
678
- if (rangeOpts.length > 0)
679
- return NO;
680
- }
681
- else
682
- {
683
- if ([[counts objectForKey:group] unsignedIntegerValue] > 0)
684
- return NO;
685
- }
686
- }
687
-
688
- return YES;
689
- }
690
-
691
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
692
- #pragma mark Mapping UI -> View
693
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
694
-
695
- /**
696
- * Maps from a section (in the UI) to a group (in the View).
697
- *
698
- * Returns the group for the given section.
699
- * This method properly takes into account dynamic groups.
700
- *
701
- * If the section is out-of-bounds, returns nil.
702
- **/
703
- - (NSString *)groupForSection:(NSUInteger)section
704
- {
705
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
706
- {
707
- if (section == 0)
708
- return consolidatedGroupName;
709
- else
710
- return nil;
711
- }
712
- else
713
- {
714
- if (section < [visibleGroups count])
715
- return [visibleGroups objectAtIndex:section];
716
- else
717
- return nil;
718
- }
719
- }
720
-
721
- /**
722
- * Maps from an indexPath (in the UI) to a group & index (within the View).
723
- *
724
- * When using rangeOptions, the rows in your tableView/collectionView may not
725
- * directly match the index in the corresponding view & group.
726
- *
727
- * For example, say a view has a group named "elders" and contains 100 items.
728
- * A fixed range is used to display only the last 20 items in the "elders" group (the 20 oldest elders).
729
- * Thus row zero in the tableView is actually index 80 in the "elders" group.
730
- *
731
- * This method maps from an indexPath in the UI to the corresponding indexes and groups in the view.
732
- *
733
- * That is, you pass in an indexPath or row & section from the UI perspective,
734
- * and it spits out the corresponding index within the view's group.
735
- *
736
- * For example:
737
- *
738
- * - (UITableViewCell *)tableView:(UITableView *)sender cellForRowAtIndexPath:(NSIndexPath *)indexPath
739
- * {
740
- * NSString *group = nil;
741
- * NSUInteger groupIndex = 0;
742
- *
743
- * [mappings getGroup:&group index:&groupIndex forIndexPath:indexPath];
744
- *
745
- * __block Elder *elder = nil;
746
- * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
747
- *
748
- * elder = [[transaction extension:@"elders"] objectAtIndex:groupIndex inGroup:group];
749
- * }];
750
- *
751
- * // configure and return cell...
752
- * }
753
- **/
754
- - (BOOL)getGroup:(NSString **)groupPtr index:(NSUInteger *)indexPtr forIndexPath:(NSIndexPath *)indexPath
755
- {
756
- if (indexPath == nil)
757
- {
758
- if (groupPtr) *groupPtr = nil;
759
- if (indexPtr) *indexPtr = NSNotFound;
760
-
761
- return NO;
762
- }
763
-
764
- #if TARGET_OS_IPHONE
765
- NSUInteger section = indexPath.section;
766
- NSUInteger row = indexPath.row;
767
- #else
768
- NSUInteger section = [indexPath indexAtPosition:0];
769
- NSUInteger row = [indexPath indexAtPosition:1];
770
- #endif
771
-
772
- return [self getGroup:groupPtr index:indexPtr forRow:row inSection:section];
773
- }
774
-
775
- /**
776
- * Maps from an indexPath (in the UI) to a group & index (within the View).
777
- *
778
- * When your UI doesn't exactly match up with the View in the database, this method does all the math for you.
779
- *
780
- * For example, if using rangeOptions, the rows in your tableView/collectionView may not
781
- * directly match the index in the corresponding view & group (in the database).
782
- *
783
- * For example, say a view in the database has a group named "elders" and contains 100 items.
784
- * A fixed range is used to display only the last 20 items in the "elders" group (the 20 oldest elders).
785
- * Thus row zero in the tableView is actually index 80 in the "elders" group.
786
- *
787
- * So you pass in an indexPath or row & section from the UI perspective,
788
- * and it spits out the corresponding index within the database view's group.
789
- *
790
- * Code sample:
791
- *
792
- * - (UITableViewCell *)tableView:(UITableView *)sender cellForRowAtIndexPath:(NSIndexPath *)indexPath
793
- * {
794
- * NSString *group = nil;
795
- * NSUInteger groupIndex = 0;
796
- *
797
- * [mappings getGroup:&group index:&groupIndex forIndexPath:indexPath];
798
- *
799
- * __block Elder *elder = nil;
800
- * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
801
- *
802
- * elder = [[transaction extension:@"elders"] objectAtIndex:groupIndex inGroup:group];
803
- * }];
804
- *
805
- * // configure and return cell...
806
- * }
807
- **/
808
- - (BOOL)getGroup:(NSString **)groupPtr
809
- index:(NSUInteger *)indexPtr
810
- forRow:(NSUInteger)row
811
- inSection:(NSUInteger)section
812
- {
813
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
814
- {
815
- if (section == 0)
816
- {
817
- return [self getGroup:groupPtr index:indexPtr forConsolidatedRow:row];
818
- }
819
- else
820
- {
821
- if (groupPtr) *groupPtr = nil;
822
- if (indexPtr) *indexPtr = NSNotFound;
823
-
824
- return NO;
825
- }
826
- }
827
- else
828
- {
829
- NSString *group = [self groupForSection:section];
830
- if (group == nil)
831
- {
832
- if (groupPtr) *groupPtr = nil;
833
- if (indexPtr) *indexPtr = NSNotFound;
834
-
835
- return NO;
836
- }
837
-
838
- NSUInteger index = [self indexForRow:row inGroup:group];
839
-
840
- if (groupPtr) *groupPtr = group;
841
- if (indexPtr) *indexPtr = index;
842
-
843
- return (index != NSNotFound);
844
- }
845
- }
846
-
847
- /**
848
- * Maps from a row & section (in the UI) to an index (within the View).
849
- *
850
- * This method is shorthand for getGroup:index:forIndexPath: when you already know the group.
851
- * @see getGroup:index:forIndexPath:
852
- **/
853
- - (NSUInteger)indexForRow:(NSUInteger)row inSection:(NSUInteger)section
854
- {
855
- return [self indexForRow:row inGroup:[self groupForSection:section]];
856
- }
857
-
858
- /**
859
- * Maps from a row & section (in the UI) to an index (within the View).
860
- *
861
- * This method is shorthand for getGroup:index:forIndexPath: when you already know the group.
862
- * @see getGroup:index:forIndexPath:
863
- **/
864
- - (NSUInteger)indexForRow:(NSUInteger)row inGroup:(NSString *)group
865
- {
866
- if (group == nil) return NSNotFound;
867
-
868
- if (isUsingConsolidatedGroup && [group isEqualToString:consolidatedGroupName])
869
- {
870
- NSUInteger index = 0;
871
- if ([self getGroup:NULL index:&index forConsolidatedRow:row])
872
- return index;
873
- else
874
- return NSNotFound;
875
- }
876
-
877
- NSUInteger visibleCount = [self visibleCountForGroup:group];
878
- if (row >= visibleCount)
879
- return NSNotFound;
880
-
881
- BOOL needsReverse = [reverse containsObject:group];
882
-
883
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
884
- if (rangeOpts)
885
- {
886
- if (rangeOpts.pin == YapDatabaseViewBeginning)
887
- {
888
- // rangeOpts.offset is from beginning (index zero)
889
-
890
- if (needsReverse)
891
- {
892
- NSUInteger upperBound = rangeOpts.offset + rangeOpts.length - 1;
893
- return upperBound - row;
894
- }
895
- else
896
- {
897
- return rangeOpts.offset + row;
898
- }
899
- }
900
- else // if (rangeOpts.pin == YapDatabaseViewEnd)
901
- {
902
- // rangeOpts.offset is from end (index last)
903
-
904
- NSUInteger fullCount = [self fullCountForGroup:group];
905
-
906
- if (needsReverse)
907
- {
908
- NSUInteger upperBound = fullCount - rangeOpts.offset - 1;
909
- return upperBound - row;
910
- }
911
- else
912
- {
913
- NSUInteger lowerBound = fullCount - rangeOpts.offset - rangeOpts.length;
914
- return lowerBound + row;
915
- }
916
- }
917
- }
918
- else
919
- {
920
- if (needsReverse)
921
- {
922
- NSUInteger fullCount = [self fullCountForGroup:group];
923
- return fullCount - row - 1;
924
- }
925
- else
926
- {
927
- return row;
928
- }
929
- }
930
- }
931
-
932
- /**
933
- * Use this method to extract the true group & index from a row in the consolidatedGroup.
934
- *
935
- * view = @{
936
- * @"A" = @[ @"Alice" ]
937
- * @"B" = @[ @"Barney", @"Bob" ]
938
- * @"C" = @[ @"Chris" ]
939
- * }
940
- * mappings.isUsingConsolidateGroup == YES
941
- *
942
- * NSString *group = nil;
943
- * NSUInteger index = 0;
944
- *
945
- * [mappings getGroup:&group index:&index forConsolidatedRow:2];
946
- *
947
- * // group = @"B"
948
- * // index = 1 (Bob)
949
- *
950
- * [mappings getGroup:&group index:&index forConsolidatedRow:3];
951
- *
952
- * // group = @"C"
953
- * // index = 0 (Chris)
954
- **/
955
- - (BOOL)getGroup:(NSString **)groupPtr index:(NSUInteger *)indexPtr forConsolidatedRow:(NSUInteger)row
956
- {
957
- NSUInteger offset = 0;
958
-
959
- for (NSString *group in visibleGroups) // NOT [self visibleGroups]
960
- {
961
- NSUInteger count = [self visibleCountForGroup:group];
962
-
963
- if ((row < (offset + count)) && (count > 0))
964
- {
965
- NSUInteger index = [self indexForRow:(row - offset) inGroup:group];
966
-
967
- if (groupPtr) *groupPtr = group;
968
- if (indexPtr) *indexPtr = index;
969
-
970
- return YES;
971
- }
972
-
973
- offset += count;
974
- }
975
-
976
- if (groupPtr) *groupPtr = nil;
977
- if (indexPtr) *indexPtr = 0;
978
- return NO;
979
- }
980
-
981
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
982
- #pragma mark Mapping View -> UI
983
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
984
-
985
- /**
986
- * Maps from a group (in the View) to the corresponding section (in the UI).
987
- *
988
- * Returns the visible section number for the visible group.
989
- * If the group is NOT visible, returns NSNotFound.
990
- * If the group is NOT valid, returns NSNotFound.
991
- **/
992
- - (NSUInteger)sectionForGroup:(NSString *)group
993
- {
994
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
995
- {
996
- if ([consolidatedGroupName isEqualToString:group])
997
- return 0;
998
-
999
- // The thought process here is that the group may be technically visible.
1000
- // It's just that its consolidated into a bigger group.
1001
-
1002
- for (NSString *visibleGroup in visibleGroups)
1003
- {
1004
- if ([visibleGroup isEqualToString:group])
1005
- {
1006
- return 0;
1007
- }
1008
- }
1009
-
1010
- return NSNotFound;
1011
- }
1012
- else
1013
- {
1014
- NSUInteger section = 0;
1015
- for (NSString *visibleGroup in visibleGroups)
1016
- {
1017
- if ([visibleGroup isEqualToString:group])
1018
- {
1019
- return section;
1020
- }
1021
- section++;
1022
- }
1023
-
1024
- return NSNotFound;
1025
- }
1026
- }
1027
-
1028
- /**
1029
- * Maps from an index & group (in the View) to the corresponding row & section (in the UI).
1030
- *
1031
- * Returns YES if the proper row & section were found.
1032
- * Returns NO if the given index is NOT visible (or out-of-bounds).
1033
- * Returns NO if the given group is NOT visible (or invalid).
1034
- **/
1035
- - (BOOL)getRow:(NSUInteger *)rowPtr
1036
- section:(NSUInteger *)sectionPtr
1037
- forIndex:(NSUInteger)index
1038
- inGroup:(NSString *)group
1039
- {
1040
- if (isUsingConsolidatedGroup && !autoConsolidationDisabled)
1041
- {
1042
- NSUInteger row = 0;
1043
- if ([self getConsolidatedRow:&row forIndex:index inGroup:group])
1044
- {
1045
- if (rowPtr) *rowPtr = row;
1046
- if (sectionPtr) *sectionPtr = 0;
1047
-
1048
- return YES;
1049
- }
1050
- else
1051
- {
1052
- if (rowPtr) *rowPtr = 0;
1053
- if (sectionPtr) *sectionPtr = 0;
1054
-
1055
- return NO;
1056
- }
1057
- }
1058
- else
1059
- {
1060
- NSUInteger section = [self sectionForGroup:group];
1061
- if (section == NSNotFound)
1062
- {
1063
- if (rowPtr) *rowPtr = 0;
1064
- if (sectionPtr) *sectionPtr = 0;
1065
-
1066
- return NO;
1067
- }
1068
-
1069
- NSUInteger row = [self rowForIndex:index inGroup:group];
1070
- if (row == NSNotFound)
1071
- {
1072
- if (rowPtr) *rowPtr = 0;
1073
- if (sectionPtr) *sectionPtr = 0;
1074
-
1075
- return NO;
1076
- }
1077
-
1078
- if (rowPtr) *rowPtr = row;
1079
- if (sectionPtr) *sectionPtr = section;
1080
-
1081
- return YES;
1082
- }
1083
- }
1084
-
1085
- /**
1086
- * Maps from an index & group (in the View) to the corresponding indexPath (in the UI).
1087
- *
1088
- * Returns the indexPath with the proper section and row.
1089
- * Returns nil if the group is NOT visible (or invalid).
1090
- * Returns nil if the index is NOT visible (or out-of-bounds).
1091
- **/
1092
- - (NSIndexPath *)indexPathForIndex:(NSUInteger)index inGroup:(NSString *)group
1093
- {
1094
- NSUInteger row = 0;
1095
- NSUInteger section = 0;
1096
-
1097
- if ([self getRow:&row section:&section forIndex:index inGroup:group])
1098
- {
1099
- #if TARGET_OS_IPHONE
1100
- return [NSIndexPath indexPathForRow:row inSection:section];
1101
- #else
1102
- NSUInteger indexes[] = {section, row};
1103
- return [NSIndexPath indexPathWithIndexes:indexes length:2];
1104
- #endif
1105
- }
1106
- else
1107
- {
1108
- return nil;
1109
- }
1110
- }
1111
-
1112
- /**
1113
- * Maps from an index & group (in the View) to the corresponding row (in the UI).
1114
- *
1115
- * This method is shorthand for getRow:section:forIndex:inGroup: when you already know the section.
1116
- * @see getRow:section:forIndex:inGroup:
1117
- **/
1118
- - (NSUInteger)rowForIndex:(NSUInteger)index inGroup:(NSString *)group
1119
- {
1120
- if (group == nil) return NSNotFound;
1121
-
1122
- if (isUsingConsolidatedGroup && [consolidatedGroupName isEqualToString:group])
1123
- {
1124
- NSUInteger row = 0;
1125
- if ([self getConsolidatedRow:&row forIndex:index inGroup:group])
1126
- return row;
1127
- else
1128
- return NSNotFound;
1129
- }
1130
-
1131
- NSUInteger fullCount = [self fullCountForGroup:group];
1132
- if (index >= fullCount)
1133
- return NSNotFound;
1134
-
1135
- BOOL needsReverse = [reverse containsObject:group];
1136
-
1137
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
1138
- if (rangeOpts)
1139
- {
1140
- if (rangeOpts.pin == YapDatabaseViewBeginning)
1141
- {
1142
- // rangeOpts.offset is from beginning (index zero)
1143
-
1144
- if (index < rangeOpts.offset)
1145
- return NSNotFound;
1146
-
1147
- NSUInteger row = index - rangeOpts.offset;
1148
-
1149
- NSUInteger visibleCount = [self visibleCountForGroup:group];
1150
- if (row >= visibleCount)
1151
- return NSNotFound;
1152
-
1153
- if (needsReverse)
1154
- return visibleCount - row - 1;
1155
- else
1156
- return row;
1157
- }
1158
- else // if (rangeOpts.pin == YapDatabaseViewEnd)
1159
- {
1160
- // rangeOpts.offset is from end (index last)
1161
-
1162
- NSUInteger visibleCount = [self visibleCountForGroup:group];
1163
-
1164
- NSUInteger upperBound = fullCount - rangeOpts.offset - 1;
1165
- if (index > upperBound)
1166
- return NSNotFound;
1167
-
1168
- NSUInteger lowerBound = upperBound - visibleCount + 1;
1169
- if (index < lowerBound)
1170
- return NSNotFound;
1171
-
1172
- if (needsReverse)
1173
- return upperBound - index;
1174
- else
1175
- return index - lowerBound;
1176
- }
1177
- }
1178
- else
1179
- {
1180
- if (needsReverse)
1181
- return fullCount - index - 1; // we know fullCount > 0
1182
- else
1183
- return index;
1184
- }
1185
- }
1186
-
1187
- /**
1188
- * Use this method to extract the true row (in the consolidatedGroup) for a given group & index in the database.
1189
- **/
1190
- - (BOOL)getConsolidatedRow:(NSUInteger *)rowPtr forIndex:(NSUInteger)index inGroup:(NSString *)group
1191
- {
1192
- NSUInteger groupOffset = 0;
1193
-
1194
- for (NSString *visibleGroup in visibleGroups)
1195
- {
1196
- if ([visibleGroup isEqualToString:group])
1197
- {
1198
- NSUInteger row = [self rowForIndex:index inGroup:group];
1199
-
1200
- if (row == NSNotFound)
1201
- {
1202
- if (rowPtr) *rowPtr = 0;
1203
- return NO;
1204
- }
1205
- else
1206
- {
1207
- if (rowPtr) *rowPtr = (groupOffset + row);
1208
- return YES;
1209
- }
1210
- }
1211
- else
1212
- {
1213
- groupOffset += [self visibleCountForGroup:visibleGroup];
1214
- }
1215
- }
1216
-
1217
- if (rowPtr) *rowPtr = 0;
1218
- return NO;
1219
- }
1220
-
1221
- //- (NSUInteger)groupOffsetForGroup:
1222
-
1223
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1224
- #pragma mark Getters + RangeOptions
1225
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1226
-
1227
- /**
1228
- * The YapDatabaseViewRangePosition struct represents the range window within the full group.
1229
- * For example:
1230
- *
1231
- * You have a section in your tableView which represents a group that contains 100 items.
1232
- * However, you've setup rangeOptions to only display the first 20 items:
1233
- *
1234
- * YapDatabaseViewRangeOptions *rangeOptions =
1235
- * [YapDatabaseViewRangeOptions fixedRangeWithLength:20 offset:0 from:YapDatabaseViewBeginning];
1236
- * [mappings setRangeOptions:rangeOptions forGroup:@"sales"];
1237
- *
1238
- * The corresponding rangePosition would be: (YapDatabaseViewRangePosition){
1239
- * .offsetFromBeginning = 0,
1240
- * .offsetFromEnd = 80,
1241
- * .length = 20
1242
- * }
1243
- **/
1244
- - (YapDatabaseViewRangePosition)rangePositionForGroup:(NSString *)group
1245
- {
1246
- if (group == nil || [consolidatedGroupName isEqualToString:group])
1247
- {
1248
- return (YapDatabaseViewRangePosition){
1249
- .offsetFromBeginning = 0,
1250
- .offsetFromEnd = 0,
1251
- .length = 0
1252
- };
1253
- }
1254
-
1255
- NSUInteger groupCount = [[counts objectForKey:group] unsignedIntegerValue];
1256
-
1257
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
1258
- YapDatabaseViewRangePosition rangePosition;
1259
-
1260
- if (rangeOpts)
1261
- {
1262
- NSUInteger rangeOffset = rangeOpts.offset;
1263
- NSUInteger rangeLength = rangeOpts.length;
1264
-
1265
- if (rangeOpts.pin == YapDatabaseViewBeginning)
1266
- {
1267
- // Offset is from beginning (index zero)
1268
-
1269
- NSUInteger reverseOffset = rangeOffset + rangeLength;
1270
-
1271
- if (reverseOffset <= groupCount)
1272
- {
1273
- // Valid range
1274
-
1275
- rangePosition = (YapDatabaseViewRangePosition){
1276
- .offsetFromBeginning = rangeOffset,
1277
- .offsetFromEnd = groupCount - reverseOffset,
1278
- .length = rangeLength
1279
- };
1280
- }
1281
- else
1282
- {
1283
- // Range fell off the backside
1284
-
1285
- rangePosition = (YapDatabaseViewRangePosition){
1286
- .offsetFromBeginning = rangeOffset,
1287
- .offsetFromEnd = 0,
1288
- .length = 0
1289
- };
1290
- }
1291
- }
1292
- else
1293
- {
1294
- // Offset is from end (index last)
1295
-
1296
- NSUInteger reverseOffset = rangeOffset + rangeLength;
1297
-
1298
- if (reverseOffset <= groupCount)
1299
- {
1300
- // Valid range
1301
-
1302
- rangePosition = (YapDatabaseViewRangePosition){
1303
- .offsetFromBeginning = groupCount - reverseOffset,
1304
- .offsetFromEnd = rangeOffset,
1305
- .length = rangeLength
1306
- };
1307
- }
1308
- else
1309
- {
1310
- // Range fell off the backside
1311
-
1312
- rangePosition = (YapDatabaseViewRangePosition){
1313
- .offsetFromBeginning = 0,
1314
- .offsetFromEnd = rangeOffset,
1315
- .length = 0,
1316
- };
1317
- }
1318
- }
1319
- }
1320
- else
1321
- {
1322
- rangePosition = (YapDatabaseViewRangePosition){
1323
- .offsetFromBeginning = 0,
1324
- .offsetFromEnd = 0,
1325
- .length = groupCount
1326
- };
1327
- }
1328
-
1329
- if ([reverse containsObject:group])
1330
- {
1331
- NSUInteger swap = rangePosition.offsetFromEnd;
1332
- rangePosition.offsetFromEnd = rangePosition.offsetFromBeginning;
1333
- rangePosition.offsetFromBeginning = swap;
1334
- }
1335
-
1336
- return rangePosition;
1337
- }
1338
-
1339
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1340
- #pragma mark Getters + Consolidation
1341
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1342
-
1343
- - (BOOL)isUsingConsolidatedGroup
1344
- {
1345
- return isUsingConsolidatedGroup;
1346
- }
1347
-
1348
- /**
1349
- * Returns the total number of items by summing up the totals across all groups.
1350
- **/
1351
- - (NSUInteger)numberOfItemsInAllGroups
1352
- {
1353
- if (snapshotOfLastUpdate == UINT64_MAX) return 0;
1354
-
1355
- NSUInteger total = 0;
1356
-
1357
- for (NSString *group in visibleGroups) // NOT [self visibleGroups]
1358
- {
1359
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
1360
- if (rangeOpts)
1361
- {
1362
- total += rangeOpts.length;
1363
- }
1364
- else
1365
- {
1366
- total += [[counts objectForKey:group] unsignedIntegerValue];
1367
- }
1368
- }
1369
-
1370
- return total;
1371
- }
1372
-
1373
- /**
1374
- * When isUsingConsolidatedGroup, this method returns the offset of the given group
1375
- * within the flattened/consolidated group.
1376
- **/
1377
- - (NSUInteger)rowOffsetForGroup:(NSString *)searchGroup
1378
- {
1379
- NSUInteger offset = 0;
1380
-
1381
- for (NSString *group in visibleGroups) // NOT [self visibleGroups]
1382
- {
1383
- if ([group isEqualToString:searchGroup])
1384
- {
1385
- return offset;
1386
- }
1387
- else
1388
- {
1389
- YapDatabaseViewRangeOptions *rangeOpts = [rangeOptions objectForKey:group];
1390
- if (rangeOpts)
1391
- offset += rangeOpts.length;
1392
- else
1393
- offset += [[counts objectForKey:group] unsignedIntegerValue];
1394
- }
1395
- }
1396
-
1397
- return 0;
1398
- }
1399
-
1400
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1401
- #pragma mark Getters + Utilities
1402
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1403
-
1404
- /**
1405
- * This is a helper method to assist in maintaining the selection while updating the tableView/collectionView.
1406
- * In general the idea is this:
1407
- * - yapDatabaseModified is invoked on the main thread
1408
- * - at the beginning of the method, you grab some information about the current selection
1409
- * - you update the database connection, and then start the animation for the changes to the table
1410
- * - you reselect whatever was previously selected
1411
- * - if that's not possible (row was deleted) then you select the closest row to the previous selection
1412
- *
1413
- * The last step isn't always what you want to do. Maybe you don't want to select anything at that point.
1414
- * But if you do, then this method can simplify the task for you.
1415
- * It figures out what the closest row is, even if it's in a different section.
1416
- *
1417
- * Code example:
1418
- *
1419
- * - (void)yapDatabaseModified:(NSNotification *)notification {
1420
- *
1421
- * // Grab info about current selection
1422
- *
1423
- * NSString *selectedGroup = nil;
1424
- * NSUInteger selectedRow = 0;
1425
- * __block NSString *selectedWidgetId = nil;
1426
- *
1427
- * NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
1428
- * if (selectedIndexPath) {
1429
- * selectedGroup = [mappings groupForSection:selectedIndexPath.section];
1430
- * selectedRow = selectedIndexPath.row;
1431
- *
1432
- * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
1433
- * selectedWidgetId = [[transaction ext:@"widgets"] keyAtIndex:selectedRow inGroup:selectedGroup];
1434
- * }];
1435
- * }
1436
- *
1437
- * // Update the database connection (move it to the latest commit)
1438
- *
1439
- * NSArray *notifications = [databaseConnection beginLongLivedReadTransaction];
1440
- *
1441
- * // Process the notification(s),
1442
- * // and get the changeset as it applies to me, based on my view and my mappings setup.
1443
- *
1444
- * NSArray *sectionChanges = nil;
1445
- * NSArray *rowChanges = nil;
1446
- *
1447
- * [[databaseConnection ext:@"order"] getSectionChanges:&sectionChanges
1448
- * rowChanges:&rowChanges
1449
- * forNotifications:notifications
1450
- * withMappings:mappings];
1451
- *
1452
- * if ([sectionChanges count] == 0 & [rowChanges count] == 0)
1453
- * {
1454
- * // Nothing has changed that affects our tableView
1455
- * return;
1456
- * }
1457
- *
1458
- * // Update the table (animating the changes)
1459
- *
1460
- * [self.tableView beginUpdates];
1461
- *
1462
- * for (YapDatabaseViewSectionChange *sectionChange in sectionChanges)
1463
- * {
1464
- * // ... (see https://github.com/yaptv/YapDatabase/wiki/Views )
1465
- * }
1466
- *
1467
- * for (YapDatabaseViewRowChange *rowChange in rowChanges)
1468
- * {
1469
- * // ... (see https://github.com/yaptv/YapDatabase/wiki/Views )
1470
- * }
1471
- *
1472
- * [self.tableView endUpdates];
1473
- *
1474
- * // Try to reselect whatever was selected before
1475
- *
1476
- * __block NSIndexPath *indexPath = nil;
1477
- *
1478
- * if (selectedIndexPath) {
1479
- * [databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
1480
- * indexPath = [[transaction ext:@"widgets"] indexPathForKey:selectedWidgetId
1481
- * withMappings:mappings];
1482
- * }];
1483
- * }
1484
- *
1485
- * // Otherwise select the nearest row to whatever was selected before
1486
- *
1487
- * if (!indexPath && selectedGroup) {
1488
- * indexPath = [mappings nearestIndexPathForRow:selectedRow inGroup:selectedGroup];
1489
- * }
1490
- *
1491
- * if (indexPath) {
1492
- * [self.tableView selectRowAtIndexPath:indexPath
1493
- * animated:NO
1494
- * scrollPosition:UITableViewScrollPositionMiddle];
1495
- * }
1496
- * }
1497
- **/
1498
- - (NSIndexPath *)nearestIndexPathForRow:(NSUInteger)row inGroup:(NSString *)searchGroup
1499
- {
1500
- if (searchGroup == nil) return nil;
1501
- if (snapshotOfLastUpdate == UINT64_MAX) return nil;
1502
-
1503
- BOOL foundGroup = NO;
1504
- NSUInteger groupIndex = 0;
1505
-
1506
- for (NSString *group in allGroups)
1507
- {
1508
- if ([group isEqualToString:searchGroup])
1509
- {
1510
- foundGroup = YES;
1511
- break;
1512
- }
1513
- groupIndex++;
1514
- }
1515
-
1516
- if (!foundGroup)
1517
- {
1518
- // The given group doesn't exist.
1519
- //
1520
- // Note: You should NOT be passing the consolidatedGroup to this method.
1521
- // You need to pass the proper database view group.
1522
- // If the mappings are consolidated, this method will automatically translate the result for you.
1523
-
1524
- return nil;
1525
- }
1526
-
1527
- BOOL isGroupVisible = NO;
1528
- NSUInteger visibleGroupIndex = 0;
1529
-
1530
- for (NSString *visibleGroup in visibleGroups)
1531
- {
1532
- if ([visibleGroup isEqualToString:searchGroup])
1533
- {
1534
- isGroupVisible = YES;
1535
- break;
1536
- }
1537
- visibleGroupIndex++;
1538
- }
1539
-
1540
- if (isGroupVisible)
1541
- {
1542
- // The searchGroup is visible.
1543
-
1544
- NSUInteger rows = [self numberOfItemsInGroup:searchGroup];
1545
- if (rows > 0)
1546
- {
1547
- NSUInteger _row = (row < rows) ? row : rows-1;
1548
- NSUInteger _section = visibleGroupIndex;
1549
-
1550
- if (isUsingConsolidatedGroup)
1551
- {
1552
- _row += [self rowOffsetForGroup:searchGroup];
1553
- _section = 0;
1554
- }
1555
-
1556
- #if TARGET_OS_IPHONE
1557
- return [NSIndexPath indexPathForRow:_row inSection:_section];
1558
- #else
1559
- NSUInteger indexes[] = {_section, _row};
1560
- return [NSIndexPath indexPathWithIndexes:indexes length:2];
1561
- #endif
1562
- }
1563
- }
1564
-
1565
- NSUInteger nearbyGroupIndex;
1566
-
1567
- // Try to select the closest row below the given group.
1568
-
1569
- nearbyGroupIndex = groupIndex;
1570
- while (nearbyGroupIndex > 0)
1571
- {
1572
- nearbyGroupIndex--;
1573
- NSString *nearbyGroup = [allGroups objectAtIndex:nearbyGroupIndex];
1574
-
1575
- NSUInteger section = [self sectionForGroup:nearbyGroup];
1576
- if (section != NSNotFound)
1577
- {
1578
- NSUInteger rows = [self numberOfItemsInGroup:nearbyGroup];
1579
- if (rows > 0)
1580
- {
1581
- NSUInteger _row = rows-1;
1582
- NSUInteger _section = section;
1583
-
1584
- if (isUsingConsolidatedGroup)
1585
- {
1586
- _row += [self rowOffsetForGroup:nearbyGroup];
1587
- _section = 0;
1588
- }
1589
-
1590
- #if TARGET_OS_IPHONE
1591
- return [NSIndexPath indexPathForRow:_row inSection:_section];
1592
- #else
1593
- NSUInteger indexes[] = {_section, _row};
1594
- return [NSIndexPath indexPathWithIndexes:indexes length:2];
1595
- #endif
1596
- }
1597
- }
1598
- }
1599
-
1600
- // Try to select the closest row above the given group.
1601
-
1602
- nearbyGroupIndex = groupIndex;
1603
- while ((nearbyGroupIndex + 1) < [allGroups count])
1604
- {
1605
- nearbyGroupIndex++;
1606
- NSString *nearbyGroup = [allGroups objectAtIndex:nearbyGroupIndex];
1607
-
1608
- NSUInteger section = [self sectionForGroup:nearbyGroup];
1609
- if (section != NSNotFound)
1610
- {
1611
- NSUInteger rows = [self numberOfItemsInGroup:nearbyGroup];
1612
- if (rows > 0)
1613
- {
1614
- NSUInteger _row = 0;
1615
- NSUInteger _section = section;
1616
-
1617
- if (isUsingConsolidatedGroup)
1618
- {
1619
- _row += [self rowOffsetForGroup:nearbyGroup];
1620
- _section = 0;
1621
- }
1622
-
1623
- #if TARGET_OS_IPHONE
1624
- return [NSIndexPath indexPathForRow:_row inSection:_section];
1625
- #else
1626
- NSUInteger indexes[] = {_section, _row};
1627
- return [NSIndexPath indexPathWithIndexes:indexes length:2];
1628
- #endif
1629
- }
1630
- }
1631
- }
1632
-
1633
- return nil;
1634
- }
1635
-
1636
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1637
- #pragma mark Logging
1638
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1639
-
1640
- - (NSString *)description
1641
- {
1642
- NSMutableString *description = [NSMutableString string];
1643
- [description appendFormat:@"<YapDatabaseViewMappings[%p]: view(%@)\n", self, registeredViewName];
1644
-
1645
- if (isUsingConsolidatedGroup)
1646
- {
1647
- [description appendFormat:@" section(0) group(%@) totalCount(%lu) \n",
1648
- consolidatedGroupName, (unsigned long)[self numberOfItemsInAllGroups]];
1649
- }
1650
-
1651
- NSUInteger visibleIndex = 0;
1652
- NSString *visibleGroup = ([visibleGroups count] > 0) ? [visibleGroups objectAtIndex:visibleIndex] : nil;
1653
-
1654
- NSUInteger groupOffset = 0;
1655
-
1656
- for (NSString *group in allGroups)
1657
- {
1658
- BOOL isVisible = [group isEqualToString:visibleGroup];
1659
-
1660
- NSUInteger visibleCount = [self visibleCountForGroup:group];
1661
- BOOL hasRangeOptions = ([rangeOptions objectForKey:group] != nil);
1662
-
1663
- if (isVisible)
1664
- {
1665
- if (isUsingConsolidatedGroup)
1666
- [description appendFormat:@" -> groupOffset(%lu)", (unsigned long)groupOffset];
1667
- else
1668
- [description appendFormat:@" section(%lu)", (unsigned long)visibleIndex];
1669
-
1670
- }
1671
- else
1672
- {
1673
- if (isUsingConsolidatedGroup)
1674
- [description appendFormat:@" -> groupOffset(%lu)", (unsigned long)groupOffset];
1675
- else
1676
- [description appendString:@" section(-)"];
1677
- }
1678
-
1679
- [description appendFormat:@" group(%@)", group];
1680
-
1681
- if (hasRangeOptions)
1682
- {
1683
- [description appendFormat:@" groupCount(%lu) visibleCount(%lu)",
1684
- (unsigned long)[self fullCountForGroup:group],
1685
- (unsigned long)visibleCount];
1686
-
1687
- YapDatabaseViewRangePosition rangePosition = [self rangePositionForGroup:group];
1688
-
1689
- [description appendFormat:@" range.offsetFromBeginning(%lu) range.offsetFromEnd(%lu)",
1690
- (unsigned long)rangePosition.offsetFromBeginning,
1691
- (unsigned long)rangePosition.offsetFromEnd];
1692
- }
1693
- else
1694
- {
1695
- [description appendFormat:@" count(%lu)", (unsigned long)visibleCount];
1696
- }
1697
-
1698
- [description appendString:@"\n"];
1699
-
1700
- if (isVisible)
1701
- {
1702
- visibleIndex++;
1703
- visibleGroup = ([visibleGroups count] > visibleIndex) ? [visibleGroups objectAtIndex:visibleIndex] : nil;
1704
- }
1705
-
1706
- groupOffset += visibleCount;
1707
- }
1708
-
1709
- [description appendString:@">"];
1710
-
1711
- return description;
1712
- }
1713
-
1714
- @end