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,17 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
/**
|
4
|
+
* There are various situations in which we need to add a placeholder to signify a nil value.
|
5
|
+
* For example, we need to cache the fact that the metadata for a given key is nil.
|
6
|
+
*
|
7
|
+
* However, we cannot add a nil object to a dictionary.
|
8
|
+
* And we cannot use NSNull, or we prevent the user from using NSNull for their own purposes.
|
9
|
+
*
|
10
|
+
* And thus, we replicate NSNull, and use it instead.
|
11
|
+
* And now the user is free to use NSNull if needed.
|
12
|
+
**/
|
13
|
+
@interface YapNull : NSObject
|
14
|
+
|
15
|
+
+ (id)null;
|
16
|
+
|
17
|
+
@end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#import "YapNull.h"
|
2
|
+
|
3
|
+
|
4
|
+
@implementation YapNull
|
5
|
+
|
6
|
+
static YapNull *singleton;
|
7
|
+
|
8
|
+
+ (void)initialize
|
9
|
+
{
|
10
|
+
static BOOL initialized = NO;
|
11
|
+
if (!initialized)
|
12
|
+
{
|
13
|
+
initialized = YES;
|
14
|
+
singleton = [[YapNull alloc] init];
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
+ (id)null
|
19
|
+
{
|
20
|
+
return singleton;
|
21
|
+
}
|
22
|
+
|
23
|
+
- (id)init
|
24
|
+
{
|
25
|
+
NSAssert(singleton == nil, @"Must use singleton via [YapNull null]");
|
26
|
+
|
27
|
+
self = [super init];
|
28
|
+
return self;
|
29
|
+
}
|
30
|
+
|
31
|
+
@end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Singleton class to represent the "value" for a key that was touched. (i.e. value didn't change)
|
5
|
+
*
|
6
|
+
* YapDatabase stores changesets in dictionaries, where the object represents the updated value for a key.
|
7
|
+
* When an item is touched, we use this singleton as the value to signify internally that the item didn't change.
|
8
|
+
* This allows us to act as if the item did change in most all respects,
|
9
|
+
* but internally won't cause us to flush the item from the caches.
|
10
|
+
**/
|
11
|
+
@interface YapTouch : NSObject
|
12
|
+
|
13
|
+
+ (id)touch;
|
14
|
+
|
15
|
+
@end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#import "YapTouch.h"
|
2
|
+
|
3
|
+
|
4
|
+
@implementation YapTouch
|
5
|
+
|
6
|
+
static YapTouch *singleton;
|
7
|
+
|
8
|
+
+ (void)initialize
|
9
|
+
{
|
10
|
+
static BOOL initialized = NO;
|
11
|
+
if (!initialized)
|
12
|
+
{
|
13
|
+
initialized = YES;
|
14
|
+
singleton = [[YapTouch alloc] init];
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
+ (id)touch
|
19
|
+
{
|
20
|
+
return singleton;
|
21
|
+
}
|
22
|
+
|
23
|
+
- (id)init
|
24
|
+
{
|
25
|
+
NSAssert(singleton == nil, @"Must use singleton via [YapTouch touch]");
|
26
|
+
|
27
|
+
self = [super init];
|
28
|
+
return self;
|
29
|
+
}
|
30
|
+
|
31
|
+
@end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
|
4
|
+
/**
|
5
|
+
* An efficient collection/key tuple class.
|
6
|
+
*
|
7
|
+
* Combines collection & key into a single object,
|
8
|
+
* and provides the proper methods to use the object in various classes (such as NSDictionary, NSSet, etc).
|
9
|
+
**/
|
10
|
+
@interface YapCollectionKey : NSObject <NSCopying, NSCoding>
|
11
|
+
|
12
|
+
- (id)initWithCollection:(NSString *)collection key:(NSString *)key;
|
13
|
+
|
14
|
+
@property (nonatomic, strong, readonly) NSString *collection;
|
15
|
+
@property (nonatomic, strong, readonly) NSString *key;
|
16
|
+
|
17
|
+
- (BOOL)isEqual:(id)anObject;
|
18
|
+
- (NSUInteger)hash;
|
19
|
+
|
20
|
+
@end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
#import "YapCollectionKey.h"
|
2
|
+
|
3
|
+
|
4
|
+
/**
|
5
|
+
* MurmurHash2 was written by Austin Appleby, and is placed in the public domain.
|
6
|
+
* http://code.google.com/p/smhasher
|
7
|
+
**/
|
8
|
+
static NSUInteger YDB_MurmurHash(NSUInteger hash1, NSUInteger hash2)
|
9
|
+
{
|
10
|
+
if (NSUIntegerMax == UINT32_MAX) // Should be optimized out via compiler since these are constants
|
11
|
+
{
|
12
|
+
// MurmurHash2 (32-bit)
|
13
|
+
//
|
14
|
+
// uint32_t MurmurHash2 ( const void * key, int len, uint32_t seed )
|
15
|
+
//
|
16
|
+
// Normally one would pass a chunk of data ('key') and associated data chunk length ('len').
|
17
|
+
// Instead we're going to use our 2 hashes.
|
18
|
+
// And we're going to randomly make up a 'seed'.
|
19
|
+
|
20
|
+
const uint32_t seed = 0xa2f1b6f; // Some random value I made up
|
21
|
+
const uint32_t len = 8; // 2 hashes, each 4 bytes = 8 bytes
|
22
|
+
|
23
|
+
// 'm' and 'r' are mixing constants generated offline.
|
24
|
+
// They're not really 'magic', they just happen to work well.
|
25
|
+
|
26
|
+
const uint32_t m = 0x5bd1e995;
|
27
|
+
const int r = 24;
|
28
|
+
|
29
|
+
// Initialize the hash to a 'random' value
|
30
|
+
|
31
|
+
uint32_t h = seed ^ len;
|
32
|
+
uint32_t k;
|
33
|
+
|
34
|
+
// Mix hash1
|
35
|
+
|
36
|
+
k = hash1;
|
37
|
+
|
38
|
+
k *= m;
|
39
|
+
k ^= k >> r;
|
40
|
+
k *= m;
|
41
|
+
|
42
|
+
h *= m;
|
43
|
+
h ^= k;
|
44
|
+
|
45
|
+
// Mix khash
|
46
|
+
|
47
|
+
k = hash2;
|
48
|
+
|
49
|
+
k *= m;
|
50
|
+
k ^= k >> r;
|
51
|
+
k *= m;
|
52
|
+
|
53
|
+
h *= m;
|
54
|
+
h ^= k;
|
55
|
+
|
56
|
+
// Do a few final mixes of the hash to ensure the last few
|
57
|
+
// bytes are well-incorporated.
|
58
|
+
|
59
|
+
h ^= h >> 13;
|
60
|
+
h *= m;
|
61
|
+
h ^= h >> 15;
|
62
|
+
|
63
|
+
return (NSUInteger)h;
|
64
|
+
}
|
65
|
+
else
|
66
|
+
{
|
67
|
+
// MurmurHash2 (64-bit)
|
68
|
+
//
|
69
|
+
// uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed )
|
70
|
+
//
|
71
|
+
// Normally one would pass a chunk of data ('key') and associated data chunk length ('len').
|
72
|
+
// Instead we're going to use our 3 hashes.
|
73
|
+
// And we're going to randomly make up a 'seed'.
|
74
|
+
|
75
|
+
const uint32_t seed = 0xa2f1b6f; // Some random value I made up
|
76
|
+
const uint32_t len = 16; // 2 hashes, each 8 bytes = 16 bytes
|
77
|
+
|
78
|
+
// 'm' and 'r' are mixing constants generated offline.
|
79
|
+
// They're not really 'magic', they just happen to work well.
|
80
|
+
|
81
|
+
const uint64_t m = 0xc6a4a7935bd1e995LLU;
|
82
|
+
const int r = 47;
|
83
|
+
|
84
|
+
// Initialize the hash to a 'random' value
|
85
|
+
|
86
|
+
uint64_t h = seed ^ (len * m);
|
87
|
+
uint64_t k;
|
88
|
+
|
89
|
+
// Mix hash1
|
90
|
+
|
91
|
+
k = hash1;
|
92
|
+
|
93
|
+
k *= m;
|
94
|
+
k ^= k >> r;
|
95
|
+
k *= m;
|
96
|
+
|
97
|
+
h ^= k;
|
98
|
+
h *= m;
|
99
|
+
|
100
|
+
// Mix hash2
|
101
|
+
|
102
|
+
k = hash2;
|
103
|
+
|
104
|
+
k *= m;
|
105
|
+
k ^= k >> r;
|
106
|
+
k *= m;
|
107
|
+
|
108
|
+
h ^= k;
|
109
|
+
h *= m;
|
110
|
+
|
111
|
+
// Do a few final mixes of the hash to ensure the last few
|
112
|
+
// bytes are well-incorporated.
|
113
|
+
|
114
|
+
h ^= h >> r;
|
115
|
+
h *= m;
|
116
|
+
h ^= h >> r;
|
117
|
+
|
118
|
+
return (NSUInteger)h;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
123
|
+
#pragma mark -
|
124
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
125
|
+
|
126
|
+
@implementation YapCollectionKey
|
127
|
+
|
128
|
+
@synthesize collection = collection;
|
129
|
+
@synthesize key = key;
|
130
|
+
|
131
|
+
- (id)initWithCollection:(NSString *)aCollection key:(NSString *)aKey
|
132
|
+
{
|
133
|
+
if ((self = [super init]))
|
134
|
+
{
|
135
|
+
if (aCollection == nil)
|
136
|
+
collection = @"";
|
137
|
+
else
|
138
|
+
collection = [aCollection copy]; // copy == retain if aCollection is immutable
|
139
|
+
|
140
|
+
if (aKey == nil)
|
141
|
+
return nil;
|
142
|
+
else
|
143
|
+
key = [aKey copy]; // copy == retain if aKey is immutable
|
144
|
+
}
|
145
|
+
return self;
|
146
|
+
}
|
147
|
+
|
148
|
+
- (id)initWithCoder:(NSCoder *)decoder
|
149
|
+
{
|
150
|
+
if ((self = [super init]))
|
151
|
+
{
|
152
|
+
collection = [decoder decodeObjectForKey:@"collection"];
|
153
|
+
key = [decoder decodeObjectForKey:@"key"];
|
154
|
+
}
|
155
|
+
return self;
|
156
|
+
}
|
157
|
+
|
158
|
+
- (void)encodeWithCoder:(NSCoder *)coder
|
159
|
+
{
|
160
|
+
[coder encodeObject:collection forKey:@"collection"];
|
161
|
+
[coder encodeObject:key forKey:@"key"];
|
162
|
+
}
|
163
|
+
|
164
|
+
- (id)copyWithZone:(NSZone *)zone
|
165
|
+
{
|
166
|
+
return self; // Immutable
|
167
|
+
}
|
168
|
+
|
169
|
+
- (BOOL)isEqual:(id)obj
|
170
|
+
{
|
171
|
+
if ([obj isMemberOfClass:[YapCollectionKey class]])
|
172
|
+
{
|
173
|
+
YapCollectionKey *ck = (YapCollectionKey *)obj;
|
174
|
+
|
175
|
+
return [key isEqualToString:ck->key] && [collection isEqualToString:ck->collection];
|
176
|
+
}
|
177
|
+
|
178
|
+
return NO;
|
179
|
+
}
|
180
|
+
|
181
|
+
- (NSUInteger)hash
|
182
|
+
{
|
183
|
+
// We need a fast way to combine 2 hashes without creating a new string (which is slow).
|
184
|
+
// To accomplish this we use the murmur hashing algorithm.
|
185
|
+
|
186
|
+
return YDB_MurmurHash([collection hash], [key hash]);
|
187
|
+
}
|
188
|
+
|
189
|
+
- (NSString *)description
|
190
|
+
{
|
191
|
+
return [NSString stringWithFormat:@"<YapCollectionKey[%p] collection(%@) key(%@)>", self, collection, key];
|
192
|
+
}
|
193
|
+
|
194
|
+
@end
|
@@ -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,96 @@
|
|
1
|
+
#import "YapDatabaseQuery.h"
|
2
|
+
#import "YapDatabaseLogging.h"
|
3
|
+
|
4
|
+
#if ! __has_feature(objc_arc)
|
5
|
+
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
|
6
|
+
#endif
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
|
10
|
+
* See YapDatabaseLogging.h for more information.
|
11
|
+
**/
|
12
|
+
#if DEBUG
|
13
|
+
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
14
|
+
#else
|
15
|
+
static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
|
16
|
+
#endif
|
17
|
+
|
18
|
+
|
19
|
+
@implementation YapDatabaseQuery
|
20
|
+
{
|
21
|
+
NSString *queryString;
|
22
|
+
NSArray *queryParameters;
|
23
|
+
}
|
24
|
+
|
25
|
+
+ (instancetype)queryWithFormat:(NSString *)format, ...
|
26
|
+
{
|
27
|
+
if (format == nil) return nil;
|
28
|
+
|
29
|
+
NSUInteger paramCount = 0;
|
30
|
+
NSUInteger formatLength = [format length];
|
31
|
+
|
32
|
+
NSRange searchRange = NSMakeRange(0, formatLength);
|
33
|
+
NSRange paramRange = [format rangeOfString:@"?" options:0 range:searchRange];
|
34
|
+
|
35
|
+
while (paramRange.location != NSNotFound)
|
36
|
+
{
|
37
|
+
paramCount++;
|
38
|
+
|
39
|
+
searchRange.location = paramRange.location + 1;
|
40
|
+
searchRange.length = formatLength - searchRange.location;
|
41
|
+
|
42
|
+
paramRange = [format rangeOfString:@"?" options:0 range:searchRange];
|
43
|
+
}
|
44
|
+
|
45
|
+
// Please note that you can ONLY pass objective-c objects as parameters.
|
46
|
+
// Primitive types such as int, float, double, etc are NOT supported.
|
47
|
+
// You MUST wrap these using NSNumber.
|
48
|
+
|
49
|
+
NSMutableArray *queryParameters = [NSMutableArray arrayWithCapacity:paramCount];
|
50
|
+
|
51
|
+
va_list args;
|
52
|
+
va_start(args, format);
|
53
|
+
|
54
|
+
@try
|
55
|
+
{
|
56
|
+
for (NSUInteger i = 0; i < paramCount; i++)
|
57
|
+
{
|
58
|
+
id param = va_arg(args, id);
|
59
|
+
|
60
|
+
[queryParameters addObject:param];
|
61
|
+
}
|
62
|
+
}
|
63
|
+
@catch (NSException *exception)
|
64
|
+
{
|
65
|
+
YDBLogError(@"Error processing query. Expected %lu parameters. All parameters must be objects. %@",
|
66
|
+
(unsigned long)paramCount, exception);
|
67
|
+
|
68
|
+
queryParameters = nil;
|
69
|
+
}
|
70
|
+
|
71
|
+
va_end(args);
|
72
|
+
|
73
|
+
if (queryParameters)
|
74
|
+
{
|
75
|
+
return [[YapDatabaseQuery alloc] initWithQueryString:format queryParameters:queryParameters];
|
76
|
+
}
|
77
|
+
else
|
78
|
+
{
|
79
|
+
return nil;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
- (id)initWithQueryString:(NSString *)inQueryString queryParameters:(NSArray *)inQueryParameters
|
84
|
+
{
|
85
|
+
if ((self = [super init]))
|
86
|
+
{
|
87
|
+
queryString = [inQueryString copy];
|
88
|
+
queryParameters = [inQueryParameters copy];
|
89
|
+
}
|
90
|
+
return self;
|
91
|
+
}
|
92
|
+
|
93
|
+
@synthesize queryString;
|
94
|
+
@synthesize queryParameters;
|
95
|
+
|
96
|
+
@end
|