motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
|
4
|
+
/**
|
5
|
+
* A YapDatabaseQuery is used to pass SQL style queries into various extension classes.
|
6
|
+
* The query that you pass represents everything after the SELECT clause of a query.
|
7
|
+
**/
|
8
|
+
@interface YapDatabaseQuery : NSObject
|
9
|
+
|
10
|
+
/**
|
11
|
+
* A YapDatabaseQuery is everything after the SELECT clause of a query.
|
12
|
+
* Methods that take YapDatabaseQuery parameters will prefix your query string similarly to:
|
13
|
+
*
|
14
|
+
* fullQuery = @"SELECT rowid FROM 'database' " + [yapDatabaseQuery queryString];
|
15
|
+
*
|
16
|
+
* Example 1:
|
17
|
+
*
|
18
|
+
* query = [YapDatabaseQuery queryWithFormat:@"WHERE jid = ?", message.jid];
|
19
|
+
* [secondaryIndex enumerateKeysAndObjectsMatchingQuery:query
|
20
|
+
* usingBlock:^(NSString *key, id object, BOOL *stop){
|
21
|
+
* ...
|
22
|
+
* }];
|
23
|
+
*
|
24
|
+
* Please note that you can ONLY pass objective-c objects as parameters.
|
25
|
+
* Primitive types such as int, float, double, etc are NOT supported.
|
26
|
+
* You MUST wrap these using NSNumber.
|
27
|
+
*
|
28
|
+
* Example 2:
|
29
|
+
*
|
30
|
+
* query = [YapDatabaseQuery queryWithFormat:@"WHERE department = ? AND salary >= ?", dept, @(minSalary)];
|
31
|
+
* [secondaryIndex enumerateKeysAndObjectsMatchingQuery:query
|
32
|
+
* usingBlock:^(NSString *key, id object, BOOL *stop){
|
33
|
+
* ...
|
34
|
+
* }];
|
35
|
+
**/
|
36
|
+
+ (instancetype)queryWithFormat:(NSString *)format, ...;
|
37
|
+
|
38
|
+
|
39
|
+
@property (nonatomic, strong, readonly) NSString *queryString;
|
40
|
+
@property (nonatomic, strong, readonly) NSArray *queryParameters;
|
41
|
+
|
42
|
+
@end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
#import "YapDatabaseExtension.h"
|
4
|
+
#import "YapDatabaseSecondaryIndexSetup.h"
|
5
|
+
#import "YapDatabaseSecondaryIndexConnection.h"
|
6
|
+
#import "YapDatabaseSecondaryIndexTransaction.h"
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Welcome to YapDatabase!
|
10
|
+
*
|
11
|
+
* https://github.com/yaptv/YapDatabase
|
12
|
+
*
|
13
|
+
* The project wiki has a wealth of documentation if you have any questions.
|
14
|
+
* https://github.com/yaptv/YapDatabase/wiki
|
15
|
+
*
|
16
|
+
* YapDatabaseSecondaryIndex is an extension which allows you to add additional indexes.
|
17
|
+
* That is, it allows you to create index(es) within sqlite for particular properties of your objects.
|
18
|
+
* You can then issue queries to find or enumerate objects using the indexes. (e.g. age >= 62)
|
19
|
+
* This allows for increased flexibility above the traditional key-value model.
|
20
|
+
**/
|
21
|
+
|
22
|
+
/**
|
23
|
+
* The block handles extracting the column values for the secondary indexes.
|
24
|
+
*
|
25
|
+
* When you add or update rows in the databse the block is invoked.
|
26
|
+
* Your block can inspect the row and determine if it contains any values that should be added to the secondary indexes.
|
27
|
+
* If not, the block can simply return.
|
28
|
+
* Otherwise the block should extract any values and add them to the given dictionary.
|
29
|
+
*
|
30
|
+
* After the block returns, the dictionary parameter will be inspected,
|
31
|
+
* and any set values will be automatically inserted/updated within the sqlite indexes.
|
32
|
+
*
|
33
|
+
* You should choose a block type that takes the minimum number of required parameters.
|
34
|
+
* The extension can make various optimizations based on required parameters of the block.
|
35
|
+
* For example, if metadata isn't required, then the extension can ignore metadata-only updates.
|
36
|
+
**/
|
37
|
+
typedef id YapDatabaseSecondaryIndexBlock; // One of the YapDatabaseSecondaryIndexWith_X_Block types below.
|
38
|
+
|
39
|
+
typedef void (^YapDatabaseSecondaryIndexWithKeyBlock) \
|
40
|
+
(NSMutableDictionary *dict, NSString *collection, NSString *key);
|
41
|
+
typedef void (^YapDatabaseSecondaryIndexWithObjectBlock) \
|
42
|
+
(NSMutableDictionary *dict, NSString *collection, NSString *key, id object);
|
43
|
+
typedef void (^YapDatabaseSecondaryIndexWithMetadataBlock) \
|
44
|
+
(NSMutableDictionary *dict, NSString *collection, NSString *key, id metadata);
|
45
|
+
typedef void (^YapDatabaseSecondaryIndexWithRowBlock) \
|
46
|
+
(NSMutableDictionary *dict, NSString *collection, NSString *key, id object, id metadata);
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Use this enum to specify what kind of block you're passing.
|
50
|
+
**/
|
51
|
+
typedef enum {
|
52
|
+
YapDatabaseSecondaryIndexBlockTypeWithKey = 1031,
|
53
|
+
YapDatabaseSecondaryIndexBlockTypeWithObject = 1032,
|
54
|
+
YapDatabaseSecondaryIndexBlockTypeWithMetadata = 1033,
|
55
|
+
YapDatabaseSecondaryIndexBlockTypeWithRow = 1034
|
56
|
+
} YapDatabaseSecondaryIndexBlockType;
|
57
|
+
|
58
|
+
|
59
|
+
@interface YapDatabaseSecondaryIndex : YapDatabaseExtension
|
60
|
+
|
61
|
+
/* Inherited from YapDatabaseExtension
|
62
|
+
|
63
|
+
@property (nonatomic, strong, readonly) NSString *registeredName;
|
64
|
+
|
65
|
+
*/
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Creates a new secondary index extension.
|
69
|
+
* After creation, you'll need to register the extension with the database system.
|
70
|
+
*
|
71
|
+
* @param setup
|
72
|
+
*
|
73
|
+
* A YapDatabaseSecondaryIndexSetup instance allows you to specify the column names and type.
|
74
|
+
* The column names can be whatever you want, with a few exceptions for reserved names such as "rowid".
|
75
|
+
* The types can reflect numbers or text.
|
76
|
+
*
|
77
|
+
* @param block
|
78
|
+
*
|
79
|
+
* Pass a block that is one of the following types:
|
80
|
+
* - YapDatabaseSecondaryIndexWithKeyBlock
|
81
|
+
* - YapDatabaseSecondaryIndexWithObjectBlock
|
82
|
+
* - YapDatabaseSecondaryIndexWithMetadataBlock
|
83
|
+
* - YapDatabaseSecondaryIndexWithRowBlock
|
84
|
+
*
|
85
|
+
* @param blockType
|
86
|
+
*
|
87
|
+
* Pass the blockType enum that matches the passed block:
|
88
|
+
* - YapDatabaseSecondaryIndexBlockTypeWithKey
|
89
|
+
* - YapDatabaseSecondaryIndexBlockTypeWithObject
|
90
|
+
* - YapDatabaseSecondaryIndexBlockTypeWithMetadata
|
91
|
+
* - YapDatabaseSecondaryIndexBlockTypeWithRow
|
92
|
+
*
|
93
|
+
* @see YapDatabaseSecondaryIndexSetup
|
94
|
+
* @see YapDatabase registerExtension:withName:
|
95
|
+
**/
|
96
|
+
- (id)initWithSetup:(YapDatabaseSecondaryIndexSetup *)setup
|
97
|
+
block:(YapDatabaseSecondaryIndexBlock)block
|
98
|
+
blockType:(YapDatabaseSecondaryIndexBlockType)blockType;
|
99
|
+
|
100
|
+
@end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
#import "YapDatabaseExtensionConnection.h"
|
3
|
+
|
4
|
+
@class YapDatabaseSecondaryIndex;
|
5
|
+
|
6
|
+
|
7
|
+
@interface YapDatabaseSecondaryIndexConnection : YapDatabaseExtensionConnection
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Returns the parent instance.
|
11
|
+
**/
|
12
|
+
@property (nonatomic, strong, readonly) YapDatabaseSecondaryIndex *secondaryIndex;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The queryCache speeds up the transaction methods. (enumerateXMatchingQuery:usingBlock:)
|
16
|
+
*
|
17
|
+
* In order for a query to be executed, it first has to be compiled by SQLite into an executable routine.
|
18
|
+
* The queryCache stores these compiled reusable routines, so that repeated queries can be executed faster.
|
19
|
+
*
|
20
|
+
* Please note that, in terms of caching, only the queryString matters. The queryParameters do not.
|
21
|
+
* That is, if you use the same queryString over and over, but with different parameters,
|
22
|
+
* you will get a nice benefit from caching as it will be able to recyle the compiled routine,
|
23
|
+
* and simply bind the different parameters each time.
|
24
|
+
*
|
25
|
+
* By default the queryCache is enabled and has a limit of 10.
|
26
|
+
*
|
27
|
+
* To disable the cache entirely, set queryCacheEnabled to NO.
|
28
|
+
* To use an inifinite cache size, set the queryCacheLimit to ZERO.
|
29
|
+
**/
|
30
|
+
@property (atomic, assign, readwrite) BOOL queryCacheEnabled;
|
31
|
+
@property (atomic, assign, readwrite) NSUInteger queryCacheLimit;
|
32
|
+
|
33
|
+
@end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#import "YapDatabase.h"
|
2
|
+
#import "YapDatabaseConnection.h"
|
3
|
+
#import "YapDatabaseTransaction.h"
|
4
|
+
|
5
|
+
#import "YapDatabaseSecondaryIndex.h"
|
6
|
+
#import "YapDatabaseSecondaryIndexConnection.h"
|
7
|
+
#import "YapDatabaseSecondaryIndexTransaction.h"
|
8
|
+
|
9
|
+
#import "YapDatabaseSecondaryIndexSetup.h"
|
10
|
+
#import "YapCache.h"
|
11
|
+
|
12
|
+
#import "sqlite3.h"
|
13
|
+
|
14
|
+
@interface YapDatabaseSecondaryIndex () {
|
15
|
+
@public
|
16
|
+
|
17
|
+
YapDatabaseSecondaryIndexSetup *setup;
|
18
|
+
|
19
|
+
YapDatabaseSecondaryIndexBlock block;
|
20
|
+
YapDatabaseSecondaryIndexBlockType blockType;
|
21
|
+
|
22
|
+
int version;
|
23
|
+
|
24
|
+
id columnNamesSharedKeySet;
|
25
|
+
}
|
26
|
+
|
27
|
+
- (NSString *)tableName;
|
28
|
+
|
29
|
+
@end
|
30
|
+
|
31
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
32
|
+
#pragma mark -
|
33
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
34
|
+
|
35
|
+
@interface YapDatabaseSecondaryIndexConnection () {
|
36
|
+
@public
|
37
|
+
|
38
|
+
__strong YapDatabaseSecondaryIndex *secondaryIndex;
|
39
|
+
__unsafe_unretained YapDatabaseConnection *databaseConnection;
|
40
|
+
|
41
|
+
NSMutableDictionary *blockDict;
|
42
|
+
|
43
|
+
YapCache *queryCache;
|
44
|
+
NSUInteger queryCacheLimit;
|
45
|
+
}
|
46
|
+
|
47
|
+
- (id)initWithSecondaryIndex:(YapDatabaseSecondaryIndex *)secondaryIndex
|
48
|
+
databaseConnection:(YapDatabaseConnection *)databaseConnection;
|
49
|
+
|
50
|
+
- (sqlite3_stmt *)insertStatement;
|
51
|
+
- (sqlite3_stmt *)updateStatement;
|
52
|
+
- (sqlite3_stmt *)removeStatement;
|
53
|
+
- (sqlite3_stmt *)removeAllStatement;
|
54
|
+
|
55
|
+
@end
|
56
|
+
|
57
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
58
|
+
#pragma mark -
|
59
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
+
|
61
|
+
@interface YapDatabaseSecondaryIndexTransaction () {
|
62
|
+
@private
|
63
|
+
|
64
|
+
__unsafe_unretained YapDatabaseSecondaryIndexConnection *secondaryIndexConnection;
|
65
|
+
__unsafe_unretained YapDatabaseReadTransaction *databaseTransaction;
|
66
|
+
|
67
|
+
BOOL isMutated;
|
68
|
+
}
|
69
|
+
|
70
|
+
- (id)initWithSecondaryIndexConnection:(YapDatabaseSecondaryIndexConnection *)secondaryIndexConnection
|
71
|
+
databaseTransaction:(YapDatabaseReadTransaction *)databaseTransaction;
|
72
|
+
|
73
|
+
@end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
@class YapDatabaseSecondaryIndexColumn;
|
4
|
+
|
5
|
+
typedef enum {
|
6
|
+
YapDatabaseSecondaryIndexTypeInteger,
|
7
|
+
YapDatabaseSecondaryIndexTypeReal,
|
8
|
+
YapDatabaseSecondaryIndexTypeText
|
9
|
+
} YapDatabaseSecondaryIndexType;
|
10
|
+
|
11
|
+
|
12
|
+
@interface YapDatabaseSecondaryIndexSetup : NSObject <NSCopying, NSFastEnumeration>
|
13
|
+
|
14
|
+
- (id)init;
|
15
|
+
- (id)initWithCapacity:(NSUInteger)capacity;
|
16
|
+
|
17
|
+
- (void)addColumn:(NSString *)name withType:(YapDatabaseSecondaryIndexType)type;
|
18
|
+
|
19
|
+
- (NSUInteger)count;
|
20
|
+
- (YapDatabaseSecondaryIndexColumn *)columnAtIndex:(NSUInteger)index;
|
21
|
+
|
22
|
+
- (NSArray *)columnNames;
|
23
|
+
|
24
|
+
@end
|
25
|
+
|
26
|
+
#pragma mark -
|
27
|
+
|
28
|
+
@interface YapDatabaseSecondaryIndexColumn : NSObject
|
29
|
+
|
30
|
+
@property (nonatomic, copy, readonly) NSString *name;
|
31
|
+
@property (nonatomic, assign, readonly) YapDatabaseSecondaryIndexType type;
|
32
|
+
|
33
|
+
@end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
#import "YapDatabaseExtensionTransaction.h"
|
4
|
+
#import "YapDatabaseQuery.h"
|
5
|
+
|
6
|
+
|
7
|
+
@interface YapDatabaseSecondaryIndexTransaction : YapDatabaseExtensionTransaction
|
8
|
+
|
9
|
+
/**
|
10
|
+
* These methods allow you to enumerates matches from the secondary index(es) using a given query.
|
11
|
+
*
|
12
|
+
* The query that you input is an SQL style query (appropriate for SQLite semantics),
|
13
|
+
* excluding the "SELECT ... FROM 'tableName'" component.
|
14
|
+
*
|
15
|
+
* For example:
|
16
|
+
*
|
17
|
+
* query = [YapDatabaseQuery queryWithFormat:@"WHERE age >= 62"];
|
18
|
+
* [[transaction ext:@"idx"] enumerateKeysMatchingQuery:query usingBlock:^(NSString *key, BOOL *stop) {
|
19
|
+
*
|
20
|
+
* // ...
|
21
|
+
* }];
|
22
|
+
*
|
23
|
+
* You can also pass parameters to the query using the standard SQLite placeholder:
|
24
|
+
*
|
25
|
+
* query = [YapDatabaseQuery queryWithFormat:@"WHERE age >= ? AND state == ?", @(age), state];
|
26
|
+
* [[transaction ext:@"idx"] enumerateKeysMatchingQuery:query usingBlock:^(NSString *key, BOOL *stop) {
|
27
|
+
*
|
28
|
+
* // ...
|
29
|
+
* }];
|
30
|
+
*
|
31
|
+
* For more information, and more examples, please see YapDatabaseQuery.
|
32
|
+
*
|
33
|
+
* @return NO if there was a problem with the given query. YES otherwise.
|
34
|
+
*
|
35
|
+
* @see YapDatabaseQuery
|
36
|
+
**/
|
37
|
+
|
38
|
+
- (BOOL)enumerateKeysMatchingQuery:(YapDatabaseQuery *)query
|
39
|
+
usingBlock:(void (^)(NSString *collection, NSString *key, BOOL *stop))block;
|
40
|
+
|
41
|
+
- (BOOL)enumerateKeysAndMetadataMatchingQuery:(YapDatabaseQuery *)query
|
42
|
+
usingBlock:
|
43
|
+
(void (^)(NSString *collection, NSString *key, id metadata, BOOL *stop))block;
|
44
|
+
|
45
|
+
- (BOOL)enumerateKeysAndObjectsMatchingQuery:(YapDatabaseQuery *)query
|
46
|
+
usingBlock:
|
47
|
+
(void (^)(NSString *collection, NSString *key, id object, BOOL *stop))block;
|
48
|
+
|
49
|
+
- (BOOL)enumerateRowsMatchingQuery:(YapDatabaseQuery *)query
|
50
|
+
usingBlock:
|
51
|
+
(void (^)(NSString *collection, NSString *key, id object, id metadata, BOOL *stop))block;
|
52
|
+
/**
|
53
|
+
* Skips the enumeration process, and just gives you the count of matching rows.
|
54
|
+
**/
|
55
|
+
|
56
|
+
- (BOOL)getNumberOfRows:(NSUInteger *)count matchingQuery:(YapDatabaseQuery *)query;
|
57
|
+
|
58
|
+
@end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
#import "sqlite3.h"
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Simple wrapper class to facilitate storing sqlite3_stmt items as objects (primarily in YapCache).
|
6
|
+
**/
|
7
|
+
@interface YapDatabaseStatement : NSObject
|
8
|
+
|
9
|
+
- (id)initWithStatement:(sqlite3_stmt *)stmt;
|
10
|
+
|
11
|
+
@property (nonatomic, assign, readonly) sqlite3_stmt *stmt;
|
12
|
+
|
13
|
+
@end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
/**
|
2
|
+
* There are a LOT of conversions from NSString to char array.
|
3
|
+
* This happens in almost every method, where we bind text to prepared sqlite3 statements.
|
4
|
+
*
|
5
|
+
* It is inefficient to use [key UTF8String] for these situations.
|
6
|
+
* The Apple documentation is very explicit concerning the UTF8String method:
|
7
|
+
*
|
8
|
+
* > The returned C string is automatically freed just as a returned object would be released;
|
9
|
+
* > you should copy the C string if [you need] to store it outside of the
|
10
|
+
* > autorelease context in which the C string is created.
|
11
|
+
*
|
12
|
+
* In other words, the UTF8String method does a malloc for character buffer, copies the characters,
|
13
|
+
* and autoreleases the buffer (just like an autoreleased NSData instance).
|
14
|
+
*
|
15
|
+
* Thus we suffer a bunch of malloc's if we use UTF8String.
|
16
|
+
*
|
17
|
+
* Considering that almost all keys are likely to be relatively small,
|
18
|
+
* a much faster technique is to use the stack instead of the heap (with obvious precautions, see below).
|
19
|
+
*
|
20
|
+
* Note: This technique ONLY applies to key names and collection names.
|
21
|
+
* It does NOT apply to object/primitiveData or metadata. Those are binded to sqlite3 statements using binary blobs.
|
22
|
+
**/
|
23
|
+
|
24
|
+
|
25
|
+
/**
|
26
|
+
* We must be cautious and conservative so as to avoid stack overflow.
|
27
|
+
* This is possibe if really huge key names or collection names are used.
|
28
|
+
*
|
29
|
+
* The number below represents the largest amount of memory (in bytes) that will be allocated on the stack per string.
|
30
|
+
**/
|
31
|
+
#define YapDatabaseStringMaxStackLength (1024 * 4)
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Struct designed to be allocated on the stack.
|
35
|
+
* You then use the inline functions below to "setup" and "teardown" the struct.
|
36
|
+
* For example:
|
37
|
+
*
|
38
|
+
* > YapDatabaseString myKeyChar;
|
39
|
+
* > MakeYapDatabaseString(&myKeyChar, myNSStringKey);
|
40
|
+
* > ...
|
41
|
+
* > sqlite3_bind_text(statement, position, myKeyChar.str, myKeyChar.length, SQLITE_STATIC);
|
42
|
+
* > ...
|
43
|
+
* > sqlite3_clear_bindings(statement);
|
44
|
+
* > sqlite3_reset(statement);
|
45
|
+
* > FreeYapDatabaseString(&myKeyChar);
|
46
|
+
*
|
47
|
+
* There are 2 "public" fields:
|
48
|
+
* str - Pointer to the char[] string.
|
49
|
+
* length - Represents the length (in bytes) of the char[] str (excluding the NULL termination byte, as usual).
|
50
|
+
*
|
51
|
+
* The other 2 "private" fields are for internal use:
|
52
|
+
* strStack - If the string doesn't exceed YapDatabaseStringMaxStackLength,
|
53
|
+
* then the bytes are copied here (onto stack storage), and str actually points to strStack.
|
54
|
+
* strHeap - If the string exceeds YapDatabaseStringMaxStackLength,
|
55
|
+
* the space is allocated on the heap, strHeap holds the pointer, and str has the same pointer.
|
56
|
+
*
|
57
|
+
* Thus the "setup" and "teardown" methods below will automatically switch to heap storage (just like UTF8String),
|
58
|
+
* if the key/collection name is too long, and performance will be equivalent.
|
59
|
+
* But in the common case of short key/collection names, we can skip the more expensive heap allocation/deallocation.
|
60
|
+
**/
|
61
|
+
struct YapDatabaseString {
|
62
|
+
int length;
|
63
|
+
char strStack[YapDatabaseStringMaxStackLength];
|
64
|
+
char *strHeap;
|
65
|
+
char *str; // Pointer to either strStack or strHeap
|
66
|
+
};
|
67
|
+
typedef struct YapDatabaseString YapDatabaseString;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Initializes the YapDatabaseString structure.
|
71
|
+
* It will automatically use heap storage if the given NSString is too long.
|
72
|
+
*
|
73
|
+
* This method should always be balanced with a call to FreeYapDatabaseString.
|
74
|
+
**/
|
75
|
+
NS_INLINE void MakeYapDatabaseString(YapDatabaseString *dbStr, NSString *nsStr)
|
76
|
+
{
|
77
|
+
if (nsStr)
|
78
|
+
{
|
79
|
+
// We convert to int because the sqlite3_bind_text() function expects an int parameter.
|
80
|
+
// So we can change it to int here, or we can cast everywhere throughout the project.
|
81
|
+
|
82
|
+
dbStr->length = (int)[nsStr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
83
|
+
|
84
|
+
if ((dbStr->length + 1) <= YapDatabaseStringMaxStackLength)
|
85
|
+
{
|
86
|
+
dbStr->strHeap = NULL;
|
87
|
+
dbStr->str = dbStr->strStack;
|
88
|
+
}
|
89
|
+
else
|
90
|
+
{
|
91
|
+
dbStr->strHeap = (char *)malloc((dbStr->length + 1));
|
92
|
+
dbStr->str = dbStr->strHeap;
|
93
|
+
}
|
94
|
+
|
95
|
+
[nsStr getCString:dbStr->str maxLength:(dbStr->length + 1) encoding:NSUTF8StringEncoding];
|
96
|
+
}
|
97
|
+
else
|
98
|
+
{
|
99
|
+
dbStr->length = 0;
|
100
|
+
dbStr->strHeap = NULL;
|
101
|
+
dbStr->str = NULL;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* If heap storage was needed (because the string length exceeded YapDatabaseStringMaxStackLength),
|
107
|
+
* this method frees the heap allocated memory.
|
108
|
+
*
|
109
|
+
* In the common case of stack storage, strHeap will be NULL, and this method is essentially a no-op.
|
110
|
+
*
|
111
|
+
* This method should be invoked AFTER sqlite3_clear_bindings (assuming SQLITE_STATIC is used).
|
112
|
+
**/
|
113
|
+
NS_INLINE void FreeYapDatabaseString(YapDatabaseString *dbStr)
|
114
|
+
{
|
115
|
+
if (dbStr->strHeap)
|
116
|
+
{
|
117
|
+
free(dbStr->strHeap);
|
118
|
+
dbStr->strHeap = NULL;
|
119
|
+
dbStr->str = NULL;
|
120
|
+
}
|
121
|
+
}
|