├── DatabasePersistencePattern.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── sakaifumiya.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── sakaifumiya.xcuserdatad │ └── xcschemes │ ├── DatabasePersistencePattern.xcscheme │ └── xcschememanagement.plist ├── DatabasePersistencePattern.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── sakaifumiya.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── DatabasePersistencePattern ├── AddController.swift ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CDOmiyage+CoreDataProperties.swift ├── CDOmiyage.swift ├── CDOmiyageComment+CoreDataProperties.swift ├── CDOmiyageComment.swift ├── CommentAddController.swift ├── CommentCell.swift ├── CommentCell.xib ├── ConvertNSDate.swift ├── DatabasePersistencePattern.xcdatamodeld │ ├── .xccurrentversion │ └── DatabasePersistencePattern.xcdatamodel │ │ └── contents ├── DbDefinition.swift ├── DetailController.swift ├── Info.plist ├── ListCell.swift ├── ListCell.xib ├── Omiyage.swift ├── OmiyageComment.swift ├── SortDedinition.swift ├── ViewController.swift ├── noimage_omiyage.jpg └── noimage_omiyage_comment.jpg ├── DatabasePersistencePatternTests ├── DatabasePersistencePatternTests.swift └── Info.plist ├── DatabasePersistencePatternUITests ├── DatabasePersistencePatternUITests.swift └── Info.plist ├── Podfile ├── Podfile.lock ├── Pods ├── Manifest.lock ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── sakaifumiya.xcuserdatad │ │ └── xcschemes │ │ ├── Pods-DatabasePersistencePattern.xcscheme │ │ ├── Realm.xcscheme │ │ ├── RealmSwift.xcscheme │ │ └── xcschememanagement.plist ├── Realm │ ├── LICENSE │ ├── README.md │ ├── Realm │ │ ├── ObjectStore │ │ │ ├── collection_notifications.cpp │ │ │ ├── impl │ │ │ │ ├── apple │ │ │ │ │ ├── external_commit_helper.cpp │ │ │ │ │ └── weak_realm_notifier.cpp │ │ │ │ ├── collection_change_builder.cpp │ │ │ │ ├── collection_notifier.cpp │ │ │ │ ├── list_notifier.cpp │ │ │ │ ├── realm_coordinator.cpp │ │ │ │ ├── results_notifier.cpp │ │ │ │ └── transact_log_handler.cpp │ │ │ ├── index_set.cpp │ │ │ ├── list.cpp │ │ │ ├── object_schema.cpp │ │ │ ├── object_store.cpp │ │ │ ├── results.cpp │ │ │ ├── schema.cpp │ │ │ ├── shared_realm.cpp │ │ │ └── util │ │ │ │ └── format.cpp │ │ ├── RLMAccessor.mm │ │ ├── RLMAnalytics.mm │ │ ├── RLMArray.mm │ │ ├── RLMArrayLinkView.mm │ │ ├── RLMCollection.mm │ │ ├── RLMConstants.m │ │ ├── RLMListBase.mm │ │ ├── RLMMigration.mm │ │ ├── RLMObject.mm │ │ ├── RLMObjectBase.mm │ │ ├── RLMObjectSchema.mm │ │ ├── RLMObjectStore.mm │ │ ├── RLMObservation.mm │ │ ├── RLMOptionalBase.mm │ │ ├── RLMPredicateUtil.mm │ │ ├── RLMProperty.mm │ │ ├── RLMQueryUtil.mm │ │ ├── RLMRealm.mm │ │ ├── RLMRealmConfiguration.mm │ │ ├── RLMRealmUtil.mm │ │ ├── RLMResults.mm │ │ ├── RLMSchema.mm │ │ ├── RLMSwiftSupport.m │ │ ├── RLMUpdateChecker.mm │ │ ├── RLMUtil.mm │ │ └── module.modulemap │ ├── build.sh │ ├── core │ │ └── librealm-ios.a │ └── include │ │ ├── RLMAccessor.h │ │ ├── RLMAnalytics.hpp │ │ ├── RLMArray.h │ │ ├── RLMArray_Private.h │ │ ├── RLMArray_Private.hpp │ │ ├── RLMCollection.h │ │ ├── RLMCollection_Private.hpp │ │ ├── RLMConstants.h │ │ ├── RLMListBase.h │ │ ├── RLMMigration.h │ │ ├── RLMMigration_Private.h │ │ ├── RLMObject.h │ │ ├── RLMObjectBase.h │ │ ├── RLMObjectBase_Dynamic.h │ │ ├── RLMObjectSchema.h │ │ ├── RLMObjectSchema_Private.h │ │ ├── RLMObjectSchema_Private.hpp │ │ ├── RLMObjectStore.h │ │ ├── RLMObject_Private.h │ │ ├── RLMObject_Private.hpp │ │ ├── RLMObservation.hpp │ │ ├── RLMOptionalBase.h │ │ ├── RLMPlatform.h │ │ ├── RLMPredicateUtil.hpp │ │ ├── RLMPrefix.h │ │ ├── RLMProperty.h │ │ ├── RLMProperty_Private.h │ │ ├── RLMProperty_Private.hpp │ │ ├── RLMQueryUtil.hpp │ │ ├── RLMRealm.h │ │ ├── RLMRealmConfiguration.h │ │ ├── RLMRealmConfiguration_Private.h │ │ ├── RLMRealmConfiguration_Private.hpp │ │ ├── RLMRealmUtil.hpp │ │ ├── RLMRealm_Dynamic.h │ │ ├── RLMRealm_Private.h │ │ ├── RLMRealm_Private.hpp │ │ ├── RLMResults.h │ │ ├── RLMResults_Private.h │ │ ├── RLMSchema.h │ │ ├── RLMSchema_Private.h │ │ ├── RLMSchema_Private.hpp │ │ ├── RLMSwiftBridgingHeader.h │ │ ├── RLMSwiftSupport.h │ │ ├── RLMUpdateChecker.hpp │ │ ├── RLMUtil.hpp │ │ ├── Realm.h │ │ ├── binding_context.hpp │ │ ├── collection_notifications.hpp │ │ ├── core │ │ ├── realm.hpp │ │ └── realm │ │ │ ├── alloc.hpp │ │ │ ├── alloc_slab.hpp │ │ │ ├── array.hpp │ │ │ ├── array_basic.hpp │ │ │ ├── array_basic_tpl.hpp │ │ │ ├── array_binary.hpp │ │ │ ├── array_blob.hpp │ │ │ ├── array_blobs_big.hpp │ │ │ ├── array_integer.hpp │ │ │ ├── array_string.hpp │ │ │ ├── array_string_long.hpp │ │ │ ├── binary_data.hpp │ │ │ ├── bptree.hpp │ │ │ ├── column.hpp │ │ │ ├── column_backlink.hpp │ │ │ ├── column_binary.hpp │ │ │ ├── column_fwd.hpp │ │ │ ├── column_link.hpp │ │ │ ├── column_linkbase.hpp │ │ │ ├── column_linklist.hpp │ │ │ ├── column_mixed.hpp │ │ │ ├── column_mixed_tpl.hpp │ │ │ ├── column_string.hpp │ │ │ ├── column_string_enum.hpp │ │ │ ├── column_table.hpp │ │ │ ├── column_timestamp.hpp │ │ │ ├── column_tpl.hpp │ │ │ ├── column_type.hpp │ │ │ ├── column_type_traits.hpp │ │ │ ├── commit_log.hpp │ │ │ ├── data_type.hpp │ │ │ ├── descriptor.hpp │ │ │ ├── descriptor_fwd.hpp │ │ │ ├── disable_sync_to_disk.hpp │ │ │ ├── exceptions.hpp │ │ │ ├── group.hpp │ │ │ ├── group_shared.hpp │ │ │ ├── group_writer.hpp │ │ │ ├── handover_defs.hpp │ │ │ ├── history.hpp │ │ │ ├── impl │ │ │ ├── array_writer.hpp │ │ │ ├── continuous_transactions_history.hpp │ │ │ ├── destroy_guard.hpp │ │ │ ├── input_stream.hpp │ │ │ ├── output_stream.hpp │ │ │ ├── sequential_getter.hpp │ │ │ ├── simulated_failure.hpp │ │ │ └── transact_log.hpp │ │ │ ├── importer.hpp │ │ │ ├── index_string.hpp │ │ │ ├── lang_bind_helper.hpp │ │ │ ├── link_view.hpp │ │ │ ├── link_view_fwd.hpp │ │ │ ├── mixed.hpp │ │ │ ├── null.hpp │ │ │ ├── olddatetime.hpp │ │ │ ├── owned_data.hpp │ │ │ ├── query.hpp │ │ │ ├── query_conditions.hpp │ │ │ ├── query_engine.hpp │ │ │ ├── query_expression.hpp │ │ │ ├── realm_nmmintrin.h │ │ │ ├── replication.hpp │ │ │ ├── row.hpp │ │ │ ├── spec.hpp │ │ │ ├── string_data.hpp │ │ │ ├── table.hpp │ │ │ ├── table_accessors.hpp │ │ │ ├── table_basic.hpp │ │ │ ├── table_basic_fwd.hpp │ │ │ ├── table_macros.hpp │ │ │ ├── table_ref.hpp │ │ │ ├── table_view.hpp │ │ │ ├── table_view_basic.hpp │ │ │ ├── timestamp.hpp │ │ │ ├── unicode.hpp │ │ │ ├── util │ │ │ ├── assert.hpp │ │ │ ├── basic_system_errors.hpp │ │ │ ├── bind_ptr.hpp │ │ │ ├── buffer.hpp │ │ │ ├── call_with_tuple.hpp │ │ │ ├── cf_ptr.hpp │ │ │ ├── config.h │ │ │ ├── encrypted_file_mapping.hpp │ │ │ ├── event_loop.hpp │ │ │ ├── features.h │ │ │ ├── file.hpp │ │ │ ├── file_mapper.hpp │ │ │ ├── hex_dump.hpp │ │ │ ├── inspect.hpp │ │ │ ├── interprocess_condvar.hpp │ │ │ ├── interprocess_mutex.hpp │ │ │ ├── logger.hpp │ │ │ ├── memory_stream.hpp │ │ │ ├── meta.hpp │ │ │ ├── misc_errors.hpp │ │ │ ├── miscellaneous.hpp │ │ │ ├── network.hpp │ │ │ ├── optional.hpp │ │ │ ├── priority_queue.hpp │ │ │ ├── safe_int_ops.hpp │ │ │ ├── scope_exit.hpp │ │ │ ├── shared_ptr.hpp │ │ │ ├── string_buffer.hpp │ │ │ ├── terminate.hpp │ │ │ ├── thread.hpp │ │ │ ├── to_string.hpp │ │ │ ├── tuple.hpp │ │ │ ├── type_list.hpp │ │ │ ├── type_traits.hpp │ │ │ ├── uri.hpp │ │ │ └── utf8.hpp │ │ │ ├── utilities.hpp │ │ │ ├── version.hpp │ │ │ └── views.hpp │ │ ├── impl │ │ ├── apple │ │ │ ├── external_commit_helper.hpp │ │ │ └── weak_realm_notifier.hpp │ │ ├── collection_change_builder.hpp │ │ ├── collection_notifier.hpp │ │ ├── external_commit_helper.hpp │ │ ├── list_notifier.hpp │ │ ├── realm_coordinator.hpp │ │ ├── results_notifier.hpp │ │ ├── transact_log_handler.hpp │ │ ├── weak_realm_notifier.hpp │ │ └── weak_realm_notifier_base.hpp │ │ ├── index_set.hpp │ │ ├── list.hpp │ │ ├── object_schema.hpp │ │ ├── object_store.hpp │ │ ├── property.hpp │ │ ├── results.hpp │ │ ├── schema.hpp │ │ ├── shared_realm.hpp │ │ └── util │ │ ├── atomic_shared_ptr.hpp │ │ └── format.hpp ├── RealmSwift │ ├── LICENSE │ ├── README.md │ ├── RealmSwift │ │ ├── Aliases.swift │ │ ├── Error.swift │ │ ├── LinkingObjects.swift │ │ ├── List.swift │ │ ├── Migration.swift │ │ ├── Object.swift │ │ ├── ObjectSchema.swift │ │ ├── Optional.swift │ │ ├── Property.swift │ │ ├── Realm.swift │ │ ├── RealmCollectionType.swift │ │ ├── RealmConfiguration.swift │ │ ├── Results.swift │ │ ├── Schema.swift │ │ ├── SortDescriptor.swift │ │ ├── SwiftVersion.swift │ │ └── Util.swift │ └── build.sh └── Target Support Files │ ├── Pods-DatabasePersistencePattern │ ├── Info.plist │ ├── Pods-DatabasePersistencePattern-acknowledgements.markdown │ ├── Pods-DatabasePersistencePattern-acknowledgements.plist │ ├── Pods-DatabasePersistencePattern-dummy.m │ ├── Pods-DatabasePersistencePattern-frameworks.sh │ ├── Pods-DatabasePersistencePattern-resources.sh │ ├── Pods-DatabasePersistencePattern-umbrella.h │ ├── Pods-DatabasePersistencePattern.debug.xcconfig │ ├── Pods-DatabasePersistencePattern.modulemap │ └── Pods-DatabasePersistencePattern.release.xcconfig │ ├── Realm │ ├── Info.plist │ ├── Realm-dummy.m │ ├── Realm-prefix.pch │ ├── Realm.modulemap │ └── Realm.xcconfig │ └── RealmSwift │ ├── Info.plist │ ├── RealmSwift-dummy.m │ ├── RealmSwift-prefix.pch │ ├── RealmSwift-umbrella.h │ ├── RealmSwift.modulemap │ └── RealmSwift.xcconfig └── README.md /DatabasePersistencePattern.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DatabasePersistencePattern.xcodeproj/project.xcworkspace/xcuserdata/sakaifumiya.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumiyasac/DatabasePersistencePattern/9cac78996b89e0b81b635dec616c0aa9a0e36cbf/DatabasePersistencePattern.xcodeproj/project.xcworkspace/xcuserdata/sakaifumiya.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DatabasePersistencePattern.xcodeproj/xcuserdata/sakaifumiya.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DatabasePersistencePattern.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DE5098C71C2A596100BB94A1 16 | 17 | primary 18 | 19 | 20 | DE5098DE1C2A596200BB94A1 21 | 22 | primary 23 | 24 | 25 | DE5098E91C2A596200BB94A1 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /DatabasePersistencePattern.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /DatabasePersistencePattern.xcworkspace/xcuserdata/sakaifumiya.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumiyasac/DatabasePersistencePattern/9cac78996b89e0b81b635dec616c0aa9a0e36cbf/DatabasePersistencePattern.xcworkspace/xcuserdata/sakaifumiya.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /DatabasePersistencePattern.xcworkspace/xcuserdata/sakaifumiya.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /DatabasePersistencePattern/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/CDOmiyage+CoreDataProperties.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CDOmiyage+CoreDataProperties.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | // Choose "Create NSManagedObject Subclass…" from the Core Data editor menu 9 | // to delete and recreate this implementation file for your updated model. 10 | // 11 | 12 | import Foundation 13 | import CoreData 14 | 15 | extension CDOmiyage { 16 | 17 | @NSManaged var cd_average: NSNumber? 18 | @NSManaged var cd_createDate: NSDate? 19 | @NSManaged var cd_detail: String? 20 | @NSManaged var cd_id: NSNumber? 21 | @NSManaged var cd_imageData: NSData? 22 | @NSManaged var cd_title: String? 23 | 24 | } 25 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/CDOmiyage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CDOmiyage.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreData 11 | 12 | class CDOmiyage: NSManagedObject { 13 | 14 | // Insert code here to add functionality to your managed object subclass 15 | 16 | } 17 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/CDOmiyageComment+CoreDataProperties.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CDOmiyageComment+CoreDataProperties.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | // Choose "Create NSManagedObject Subclass…" from the Core Data editor menu 9 | // to delete and recreate this implementation file for your updated model. 10 | // 11 | 12 | import Foundation 13 | import CoreData 14 | 15 | extension CDOmiyageComment { 16 | 17 | @NSManaged var cd_comment_comment: String? 18 | @NSManaged var cd_comment_id: NSNumber? 19 | @NSManaged var cd_comment_imageData: NSData? 20 | @NSManaged var cd_comment_star: NSNumber? 21 | @NSManaged var cd_id: NSNumber? 22 | 23 | } 24 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/CDOmiyageComment.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CDOmiyageComment.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import CoreData 11 | 12 | class CDOmiyageComment: NSManagedObject { 13 | 14 | // Insert code here to add functionality to your managed object subclass 15 | 16 | } 17 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/CommentCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommentCell.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/04. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CommentCell: UITableViewCell { 12 | 13 | //Outlet 14 | @IBOutlet weak var commentImage: UIImageView! 15 | @IBOutlet weak var commentStar: UILabel! 16 | @IBOutlet weak var commentPoint: UILabel! 17 | @IBOutlet weak var commentText: UILabel! 18 | 19 | override func awakeFromNib() { 20 | super.awakeFromNib() 21 | // Initialization code 22 | } 23 | 24 | override func setSelected(selected: Bool, animated: Bool) { 25 | super.setSelected(selected, animated: animated) 26 | 27 | // Configure the view for the selected state 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/ConvertNSDate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConvertNSDate.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | //日付をNSDateからStringの変換用のstruct 12 | struct ConvertNSDate { 13 | 14 | //NSDate → Stringへの変換 15 | static func convertNSDateToString (date: NSDate) -> String { 16 | 17 | let dateFormatter: NSDateFormatter = NSDateFormatter() 18 | dateFormatter.locale = NSLocale(localeIdentifier: "ja_JP") 19 | dateFormatter.dateFormat = "yyyy.MM.dd" 20 | let dateString: String = dateFormatter.stringFromDate(date) 21 | return dateString 22 | } 23 | } -------------------------------------------------------------------------------- /DatabasePersistencePattern/DatabasePersistencePattern.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | DatabasePersistencePattern.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/DatabasePersistencePattern.xcdatamodeld/DatabasePersistencePattern.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/DbDefinition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DbDefinition.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | //格納用DBの選択enum 10 | enum DbDefinition: Int { 11 | 12 | //セグメント番号の名称 13 | case RealmUse, CoreDataUse 14 | 15 | //enumの値を返す 16 | func returnValue() -> Int { 17 | return self.rawValue 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/ListCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListCell.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/04. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ListCell: UITableViewCell { 12 | 13 | //Outlet 14 | @IBOutlet weak var listDate: UILabel! 15 | @IBOutlet weak var listAverage: UILabel! 16 | @IBOutlet weak var listImage: UIImageView! 17 | @IBOutlet weak var listTitle: UILabel! 18 | @IBOutlet weak var listComments: UILabel! 19 | 20 | override func awakeFromNib() { 21 | super.awakeFromNib() 22 | // Initialization code 23 | } 24 | 25 | override func setSelected(selected: Bool, animated: Bool) { 26 | super.setSelected(selected, animated: animated) 27 | 28 | // Configure the view for the selected state 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/OmiyageComment.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OmiyageComment.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | //Realmクラスのインポート 12 | import RealmSwift 13 | 14 | class OmiyageComment: Object { 15 | 16 | //Realmクラスのインスタンス 17 | static let realm = try! Realm() 18 | 19 | //id 20 | dynamic var id = 0 21 | 22 | //おみやげid 23 | dynamic var omiyage_id = 0 24 | 25 | //コメント 26 | dynamic var comment = "" 27 | 28 | //評価 29 | dynamic var star = 0 30 | 31 | //その時の写真 32 | /** 33 | * 下記記事で紹介されている実装を元に作成 34 | * 35 | * JFYI:(Qiita) Realm × Swift2 でシームレスに画像を保存する 36 | * http://qiita.com/_ha1f/items/593ca4f9c97ae697fc75 37 | * 38 | */ 39 | // 40 | dynamic private var _image: UIImage? = nil 41 | 42 | dynamic var image: UIImage? { 43 | 44 | //画像のセッター 45 | set { 46 | self._image = newValue 47 | if let value = newValue { 48 | self.imageData = UIImagePNGRepresentation(value) 49 | } 50 | } 51 | 52 | //画像のゲッター 53 | get { 54 | if let image = self._image { 55 | return image 56 | } 57 | if let data = self.imageData { 58 | self._image = UIImage(data: data) 59 | return self._image 60 | } 61 | return nil 62 | } 63 | } 64 | 65 | dynamic private var imageData: NSData? = nil 66 | 67 | //PrimaryKeyの設定 68 | override static func primaryKey() -> String? { 69 | return "id" 70 | } 71 | 72 | //保存しないプロパティの一覧 73 | override static func ignoredProperties() -> [String] { 74 | return ["image", "_image"] 75 | } 76 | 77 | //新規追加用のインスタンス生成メソッド 78 | static func create() -> OmiyageComment { 79 | let omiyageComment = OmiyageComment() 80 | omiyageComment.id = self.getLastId() 81 | return omiyageComment 82 | } 83 | 84 | //プライマリキーの作成メソッド 85 | static func getLastId() -> Int { 86 | if let omiyageComment = realm.objects(OmiyageComment).last { 87 | return omiyageComment.id + 1 88 | } else { 89 | return 1 90 | } 91 | } 92 | 93 | //インスタンス保存用メソッド 94 | func save() { 95 | try! OmiyageComment.realm.write { 96 | OmiyageComment.realm.add(self) 97 | } 98 | } 99 | 100 | //平均値を取得 101 | static func getAverage(target_id: Int) -> Double { 102 | 103 | if let average: Double = realm.objects(OmiyageComment).filter("omiyage_id = %@", target_id).average("star") { 104 | return average 105 | } else { 106 | return 0.0 107 | } 108 | } 109 | 110 | //インスタンス削除用メソッド 111 | func delete() { 112 | try! OmiyageComment.realm.write { 113 | OmiyageComment.realm.delete(self) 114 | } 115 | } 116 | 117 | //ソートをかけた順のデータの全件取得をする 118 | static func fetchAllOmiyageList(target_id: Int) -> [OmiyageComment] { 119 | 120 | var omiyageComments: Results 121 | omiyageComments = realm.objects(OmiyageComment).filter("omiyage_id = %@", target_id).sorted("id", ascending: true) 122 | 123 | var omiyageCommentList: [OmiyageComment] = [] 124 | for omiyageComment in omiyageComments { 125 | omiyageCommentList.append(omiyageComment) 126 | } 127 | return omiyageCommentList 128 | } 129 | 130 | } 131 | 132 | 133 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/SortDedinition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SortDedinition.swift 3 | // DatabasePersistencePattern 4 | // 5 | // Created by 酒井文也 on 2016/01/05. 6 | // Copyright © 2016年 just1factory. All rights reserved. 7 | // 8 | 9 | //ソートの選択enum 10 | enum SortDefinition: Int { 11 | 12 | //セグメント番号の名称 13 | case SortScore, SortId 14 | 15 | //enumの値を返す 16 | func returnValue() -> Int { 17 | return self.rawValue 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DatabasePersistencePattern/noimage_omiyage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumiyasac/DatabasePersistencePattern/9cac78996b89e0b81b635dec616c0aa9a0e36cbf/DatabasePersistencePattern/noimage_omiyage.jpg -------------------------------------------------------------------------------- /DatabasePersistencePattern/noimage_omiyage_comment.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumiyasac/DatabasePersistencePattern/9cac78996b89e0b81b635dec616c0aa9a0e36cbf/DatabasePersistencePattern/noimage_omiyage_comment.jpg -------------------------------------------------------------------------------- /DatabasePersistencePatternTests/DatabasePersistencePatternTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DatabasePersistencePatternTests.swift 3 | // DatabasePersistencePatternTests 4 | // 5 | // Created by 酒井文也 on 2015/12/23. 6 | // Copyright © 2015年 just1factory. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import DatabasePersistencePattern 11 | 12 | class DatabasePersistencePatternTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /DatabasePersistencePatternTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /DatabasePersistencePatternUITests/DatabasePersistencePatternUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DatabasePersistencePatternUITests.swift 3 | // DatabasePersistencePatternUITests 4 | // 5 | // Created by 酒井文也 on 2015/12/23. 6 | // Copyright © 2015年 just1factory. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class DatabasePersistencePatternUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /DatabasePersistencePatternUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | target 'DatabasePersistencePattern' do 3 | pod 'RealmSwift' 4 | end 5 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Realm (1.0.2): 3 | - Realm/Headers (= 1.0.2) 4 | - Realm/Headers (1.0.2) 5 | - RealmSwift (1.0.2): 6 | - Realm (= 1.0.2) 7 | 8 | DEPENDENCIES: 9 | - RealmSwift 10 | 11 | SPEC CHECKSUMS: 12 | Realm: 9d5c46a4d7d27958530a8dfc58f63a99e5c2cba3 13 | RealmSwift: 82f3ac5e24530143dddfde2033acc0d308f27d96 14 | 15 | PODFILE CHECKSUM: 560c5262b82959a1531457b166fc8a43031eefec 16 | 17 | COCOAPODS: 1.0.1 18 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Realm (1.0.2): 3 | - Realm/Headers (= 1.0.2) 4 | - Realm/Headers (1.0.2) 5 | - RealmSwift (1.0.2): 6 | - Realm (= 1.0.2) 7 | 8 | DEPENDENCIES: 9 | - RealmSwift 10 | 11 | SPEC CHECKSUMS: 12 | Realm: 9d5c46a4d7d27958530a8dfc58f63a99e5c2cba3 13 | RealmSwift: 82f3ac5e24530143dddfde2033acc0d308f27d96 14 | 15 | PODFILE CHECKSUM: 560c5262b82959a1531457b166fc8a43031eefec 16 | 17 | COCOAPODS: 1.0.1 18 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/sakaifumiya.xcuserdatad/xcschemes/Pods-DatabasePersistencePattern.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 66 | 67 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/sakaifumiya.xcuserdatad/xcschemes/Realm.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/sakaifumiya.xcuserdatad/xcschemes/RealmSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/sakaifumiya.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-DatabasePersistencePattern.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Realm.xcscheme 13 | 14 | isShown 15 | 16 | 17 | RealmSwift.xcscheme 18 | 19 | isShown 20 | 21 | 22 | 23 | SuppressBuildableAutocreation 24 | 25 | 36B5F025B7DA2B6128779B97EDC667A5 26 | 27 | primary 28 | 29 | 30 | AE94E5EB1EEA064C3E8F989C1F7FBC37 31 | 32 | primary 33 | 34 | 35 | B1130B0BDC28121AB57F3E9E7A43CEBA 36 | 37 | primary 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/ObjectStore/collection_notifications.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #include "collection_notifications.hpp" 20 | 21 | #include "impl/collection_notifier.hpp" 22 | 23 | using namespace realm; 24 | using namespace realm::_impl; 25 | 26 | NotificationToken::NotificationToken(std::shared_ptr<_impl::CollectionNotifier> notifier, size_t token) 27 | : m_notifier(std::move(notifier)), m_token(token) 28 | { 29 | } 30 | 31 | NotificationToken::~NotificationToken() 32 | { 33 | // m_notifier itself (and not just the pointed-to thing) needs to be accessed 34 | // atomically to ensure that there are no data races when the token is 35 | // destroyed after being modified on a different thread. 36 | // This is needed despite the token not being thread-safe in general as 37 | // users find it very surprising for obj-c objects to care about what 38 | // thread they are deallocated on. 39 | if (auto notifier = m_notifier.exchange({})) { 40 | notifier->remove_callback(m_token); 41 | } 42 | } 43 | 44 | NotificationToken::NotificationToken(NotificationToken&&) = default; 45 | 46 | NotificationToken& NotificationToken::operator=(realm::NotificationToken&& rgt) 47 | { 48 | if (this != &rgt) { 49 | if (auto notifier = m_notifier.exchange({})) { 50 | notifier->remove_callback(m_token); 51 | } 52 | m_notifier = std::move(rgt.m_notifier); 53 | m_token = rgt.m_token; 54 | } 55 | return *this; 56 | } 57 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/ObjectStore/impl/apple/weak_realm_notifier.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #include "impl/weak_realm_notifier.hpp" 20 | 21 | #include "shared_realm.hpp" 22 | 23 | #include 24 | 25 | using namespace realm; 26 | using namespace realm::_impl; 27 | 28 | WeakRealmNotifier::WeakRealmNotifier(const std::shared_ptr& realm, bool cache) 29 | : WeakRealmNotifierBase(realm, cache) 30 | { 31 | struct RefCountedWeakPointer { 32 | std::weak_ptr realm; 33 | std::atomic ref_count; 34 | }; 35 | 36 | CFRunLoopSourceContext ctx{}; 37 | ctx.info = new RefCountedWeakPointer{realm, {0}}; 38 | ctx.perform = [](void* info) { 39 | if (auto realm = static_cast(info)->realm.lock()) { 40 | realm->notify(); 41 | } 42 | }; 43 | ctx.retain = [](const void* info) { 44 | static_cast(const_cast(info))->ref_count.fetch_add(1, std::memory_order_relaxed); 45 | return info; 46 | }; 47 | ctx.release = [](const void* info) { 48 | auto ptr = static_cast(const_cast(info)); 49 | if (ptr->ref_count.fetch_add(-1, std::memory_order_acq_rel) == 1) { 50 | delete ptr; 51 | } 52 | }; 53 | 54 | m_runloop = CFRunLoopGetCurrent(); 55 | CFRetain(m_runloop); 56 | m_signal = CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &ctx); 57 | CFRunLoopAddSource(m_runloop, m_signal, kCFRunLoopDefaultMode); 58 | } 59 | 60 | WeakRealmNotifier::WeakRealmNotifier(WeakRealmNotifier&& rgt) 61 | : WeakRealmNotifierBase(std::move(rgt)) 62 | , m_runloop(rgt.m_runloop) 63 | , m_signal(rgt.m_signal) 64 | { 65 | rgt.m_runloop = nullptr; 66 | rgt.m_signal = nullptr; 67 | } 68 | 69 | WeakRealmNotifier& WeakRealmNotifier::operator=(WeakRealmNotifier&& rgt) 70 | { 71 | WeakRealmNotifierBase::operator=(std::move(rgt)); 72 | 73 | invalidate(); 74 | m_runloop = rgt.m_runloop; 75 | m_signal = rgt.m_signal; 76 | rgt.m_runloop = nullptr; 77 | rgt.m_signal = nullptr; 78 | 79 | return *this; 80 | } 81 | 82 | WeakRealmNotifier::~WeakRealmNotifier() 83 | { 84 | invalidate(); 85 | } 86 | 87 | void WeakRealmNotifier::invalidate() 88 | { 89 | if (m_signal) { 90 | CFRunLoopSourceInvalidate(m_signal); 91 | CFRelease(m_signal); 92 | CFRelease(m_runloop); 93 | } 94 | } 95 | 96 | void WeakRealmNotifier::notify() 97 | { 98 | CFRunLoopSourceSignal(m_signal); 99 | // Signalling the source makes it run the next time the runloop gets 100 | // to it, but doesn't make the runloop start if it's currently idle 101 | // waiting for events 102 | CFRunLoopWakeUp(m_runloop); 103 | } 104 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/ObjectStore/util/format.cpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #include "util/format.hpp" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace realm { namespace _impl { 27 | Printable::Printable(StringData value) : m_type(Type::String), m_string(value.data()) { } 28 | 29 | void Printable::print(std::ostream& out) const 30 | { 31 | switch (m_type) { 32 | case Printable::Type::Bool: 33 | out << (m_uint ? "true" : "false"); 34 | break; 35 | case Printable::Type::Uint: 36 | out << m_uint; 37 | break; 38 | case Printable::Type::Int: 39 | out << m_int; 40 | break; 41 | case Printable::Type::String: 42 | out << m_string; 43 | break; 44 | } 45 | } 46 | 47 | std::string format(const char* fmt, std::initializer_list values) 48 | { 49 | std::stringstream ss; 50 | while (*fmt) { 51 | auto next = strchr(fmt, '%'); 52 | 53 | // emit the rest of the format string if there are no more percents 54 | if (!next) { 55 | ss << fmt; 56 | break; 57 | } 58 | 59 | // emit everything up to the next percent 60 | ss.write(fmt, next - fmt); 61 | ++next; 62 | REALM_ASSERT(*next); 63 | 64 | // %% produces a single escaped % 65 | if (*next == '%') { 66 | ss << '%'; 67 | fmt = next + 1; 68 | continue; 69 | } 70 | REALM_ASSERT(isdigit(*next)); 71 | 72 | // The const_cast is safe because stroul does not actually modify 73 | // the pointed-to string, but it lacks a const overload 74 | auto index = strtoul(next, const_cast(&fmt), 10) - 1; 75 | REALM_ASSERT(index < values.size()); 76 | (values.begin() + index)->print(ss); 77 | } 78 | return ss.str(); 79 | } 80 | 81 | } // namespace _impl 82 | } // namespace realm 83 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/RLMConstants.m: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | RLMNotification const RLMRealmRefreshRequiredNotification = @"RLMRealmRefreshRequiredNotification"; 22 | RLMNotification const RLMRealmDidChangeNotification = @"RLMRealmDidChangeNotification"; 23 | 24 | NSString * const RLMErrorDomain = @"io.realm"; 25 | 26 | NSString * const RLMUnknownSystemErrorDomain = @"io.realm.unknown"; 27 | 28 | NSString * const RLMExceptionName = @"RLMException"; 29 | 30 | NSString * const RLMRealmVersionKey = @"RLMRealmVersion"; 31 | 32 | NSString * const RLMRealmCoreVersionKey = @"RLMRealmCoreVersion"; 33 | 34 | NSString * const RLMInvalidatedKey = @"invalidated"; 35 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/RLMListBase.mm: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMListBase.h" 20 | 21 | #import "RLMArray_Private.hpp" 22 | #import "RLMObservation.hpp" 23 | 24 | @interface RLMArray (KVO) 25 | - (NSArray *)objectsAtIndexes:(__unused NSIndexSet *)indexes; 26 | @end 27 | 28 | @implementation RLMListBase { 29 | std::unique_ptr _observationInfo; 30 | } 31 | 32 | - (instancetype)initWithArray:(RLMArray *)array { 33 | self = [super init]; 34 | if (self) { 35 | __rlmArray = array; 36 | } 37 | return self; 38 | } 39 | 40 | - (id)valueForKey:(NSString *)key { 41 | return [__rlmArray valueForKey:key]; 42 | } 43 | 44 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len { 45 | return [__rlmArray countByEnumeratingWithState:state objects:buffer count:len]; 46 | } 47 | 48 | - (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes { 49 | return [__rlmArray objectsAtIndexes:indexes]; 50 | } 51 | 52 | - (void)addObserver:(id)observer 53 | forKeyPath:(NSString *)keyPath 54 | options:(NSKeyValueObservingOptions)options 55 | context:(void *)context { 56 | RLMEnsureArrayObservationInfo(_observationInfo, keyPath, __rlmArray, self); 57 | [super addObserver:observer forKeyPath:keyPath options:options context:context]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/RLMOptionalBase.mm: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMAccessor.h" 20 | #import "RLMOptionalBase.h" 21 | #import "RLMObject_Private.h" 22 | #import "RLMObjectStore.h" 23 | #import "RLMProperty.h" 24 | #import "RLMUtil.hpp" 25 | 26 | #import 27 | 28 | @interface RLMOptionalBase () 29 | @property (nonatomic) id unmanagedValue; 30 | @end 31 | 32 | @implementation RLMOptionalBase 33 | 34 | - (instancetype)init { 35 | return self; 36 | } 37 | 38 | - (id)underlyingValue { 39 | if ((_object && _object->_realm) || _object.isInvalidated) { 40 | return RLMDynamicGet(_object, _property); 41 | } 42 | else { 43 | return _unmanagedValue; 44 | } 45 | } 46 | 47 | - (void)setUnderlyingValue:(id)underlyingValue { 48 | if ((_object && _object->_realm) || _object.isInvalidated) { 49 | RLMDynamicSet(_object, _property, underlyingValue, RLMCreationOptionsNone); 50 | } 51 | else { 52 | NSString *propertyName = _property.name; 53 | [_object willChangeValueForKey:propertyName]; 54 | _unmanagedValue = underlyingValue; 55 | [_object didChangeValueForKey:propertyName]; 56 | } 57 | } 58 | 59 | - (BOOL)isKindOfClass:(Class)aClass { 60 | return [self.underlyingValue isKindOfClass:aClass] || RLMIsKindOfClass(object_getClass(self), aClass); 61 | } 62 | 63 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)sel { 64 | return [self.underlyingValue methodSignatureForSelector:sel]; 65 | } 66 | 67 | - (void)forwardInvocation:(NSInvocation *)invocation { 68 | [invocation invokeWithTarget:self.underlyingValue]; 69 | } 70 | 71 | - (id)forwardingTargetForSelector:(__unused SEL)sel { 72 | return self.underlyingValue; 73 | } 74 | 75 | - (BOOL)respondsToSelector:(SEL)aSelector { 76 | if (id val = self.underlyingValue) { 77 | return [val respondsToSelector:aSelector]; 78 | } 79 | return NO; 80 | } 81 | 82 | - (void)doesNotRecognizeSelector:(SEL)aSelector { 83 | [self.underlyingValue doesNotRecognizeSelector:aSelector]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/RLMSwiftSupport.m: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMSwiftSupport.h" 20 | 21 | @implementation RLMSwiftSupport 22 | 23 | + (BOOL)isSwiftClassName:(NSString *)className { 24 | return [className rangeOfString:@"."].location != NSNotFound; 25 | } 26 | 27 | + (NSString *)demangleClassName:(NSString *)className { 28 | return [className substringFromIndex:[className rangeOfString:@"."].location + 1]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/RLMUpdateChecker.mm: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMUpdateChecker.hpp" 20 | 21 | #import "RLMRealm.h" 22 | #import "RLMUtil.hpp" 23 | 24 | #if TARGET_IPHONE_SIMULATOR && !defined(REALM_COCOA_VERSION) 25 | #import "RLMVersion.h" 26 | #endif 27 | 28 | void RLMCheckForUpdates() { 29 | #if TARGET_IPHONE_SIMULATOR 30 | if (getenv("REALM_DISABLE_UPDATE_CHECKER") || RLMIsRunningInPlayground()) { 31 | return; 32 | } 33 | 34 | auto handler = ^(NSData *data, NSURLResponse *response, NSError *error) { 35 | if (error || ((NSHTTPURLResponse *)response).statusCode != 200) { 36 | return; 37 | } 38 | 39 | NSString *latestVersion = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 40 | if (![REALM_COCOA_VERSION isEqualToString:latestVersion]) { 41 | NSLog(@"Version %@ of Realm is now available: https://github.com/realm/realm-cocoa/blob/v%@/CHANGELOG.md", latestVersion, latestVersion); 42 | } 43 | }; 44 | 45 | NSString *url = [NSString stringWithFormat:@"https://static.realm.io/update/cocoa?%@", REALM_COCOA_VERSION]; 46 | [[NSURLSession.sharedSession dataTaskWithURL:[NSURL URLWithString:url] completionHandler:handler] resume]; 47 | #endif 48 | } 49 | -------------------------------------------------------------------------------- /Pods/Realm/Realm/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module Realm { 2 | umbrella header "Realm.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Private { 8 | header "RLMAccessor.h" 9 | header "RLMArray_Private.h" 10 | header "RLMListBase.h" 11 | header "RLMMigration_Private.h" 12 | header "RLMObjectSchema_Private.h" 13 | header "RLMObjectStore.h" 14 | header "RLMObject_Private.h" 15 | header "RLMOptionalBase.h" 16 | header "RLMProperty_Private.h" 17 | header "RLMRealmConfiguration_Private.h" 18 | header "RLMRealm_Private.h" 19 | header "RLMResults_Private.h" 20 | header "RLMSchema_Private.h" 21 | } 22 | 23 | explicit module Dynamic { 24 | header "RLMRealm_Dynamic.h" 25 | header "RLMObjectBase_Dynamic.h" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Pods/Realm/core/librealm-ios.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumiyasac/DatabasePersistencePattern/9cac78996b89e0b81b635dec616c0aa9a0e36cbf/Pods/Realm/core/librealm-ios.a -------------------------------------------------------------------------------- /Pods/Realm/include/RLMAccessor.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | 22 | @class RLMObjectSchema, RLMProperty, RLMObjectBase, RLMProperty; 23 | 24 | #ifdef __cplusplus 25 | typedef NSUInteger RLMCreationOptions; 26 | #else 27 | typedef NS_OPTIONS(NSUInteger, RLMCreationOptions); 28 | #endif 29 | 30 | NS_ASSUME_NONNULL_BEGIN 31 | 32 | // 33 | // Accessors Class Creation/Caching 34 | // 35 | 36 | // get accessor classes for an object class - generates classes if not cached 37 | Class RLMAccessorClassForObjectClass(Class objectClass, RLMObjectSchema *schema, NSString *prefix); 38 | Class RLMUnmanagedAccessorClassForObjectClass(Class objectClass, RLMObjectSchema *schema); 39 | 40 | // Check if a given class is a generated accessor class 41 | bool RLMIsGeneratedClass(Class cls); 42 | 43 | // 44 | // Dynamic getters/setters 45 | // 46 | FOUNDATION_EXTERN void RLMDynamicValidatedSet(RLMObjectBase *obj, NSString *propName, id __nullable val); 47 | FOUNDATION_EXTERN RLMProperty *RLMValidatedGetProperty(RLMObjectBase *obj, NSString *propName); 48 | FOUNDATION_EXTERN id __nullable RLMDynamicGet(RLMObjectBase *obj, RLMProperty *prop); 49 | 50 | // by property/column 51 | FOUNDATION_EXTERN void RLMDynamicSet(RLMObjectBase *obj, RLMProperty *prop, id val, RLMCreationOptions options); 52 | 53 | // 54 | // Class modification 55 | // 56 | 57 | // Replace className method for the given class 58 | void RLMReplaceClassNameMethod(Class accessorClass, NSString *className); 59 | 60 | // Replace sharedSchema method for the given class 61 | void RLMReplaceSharedSchemaMethod(Class accessorClass, RLMObjectSchema * __nullable schema); 62 | 63 | NS_ASSUME_NONNULL_END 64 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMAnalytics.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | // Asynchronously submits build information to Realm if running in an iOS 20 | // simulator or on OS X if a debugger is attached. Does nothing if running on an 21 | // iOS / watchOS device or if a debugger is *not* attached. 22 | // 23 | // To be clear: this does *not* run when your app is in production or on 24 | // your end-user’s devices; it will only run in the simulator or when a debugger 25 | // is attached. 26 | // 27 | // Why are we doing this? In short, because it helps us build a better product 28 | // for you. None of the data personally identifies you, your employer or your 29 | // app, but it *will* help us understand what language you use, what iOS 30 | // versions you target, etc. Having this info will help prioritizing our time, 31 | // adding new features and deprecating old features. Collecting an anonymized 32 | // bundle & anonymized MAC is the only way for us to count actual usage of the 33 | // other metrics accurately. If we don’t have a way to deduplicate the info 34 | // reported, it will be useless, as a single developer building their Swift app 35 | // 10 times would report 10 times more than a single Objective-C developer that 36 | // only builds once, making the data all but useless. 37 | // No one likes sharing data unless it’s necessary, we get it, and we’ve 38 | // debated adding this for a long long time. Since Realm is a free product 39 | // without an email signup, we feel this is a necessary step so we can collect 40 | // relevant data to build a better product for you. If you truly, absolutely 41 | // feel compelled to not send this data back to Realm, then you can set an env 42 | // variable named REALM_DISABLE_ANALYTICS. Since Realm is free we believe 43 | // letting these analytics run is a small price to pay for the product & support 44 | // we give you. 45 | // 46 | // Currently the following information is reported: 47 | // - What version of Realm is being used, and from which language (obj-c or Swift). 48 | // - What version of OS X it's running on (in case Xcode aggressively drops 49 | // support for older versions again, we need to know what we need to support). 50 | // - The minimum iOS/OS X version that the application is targeting (again, to 51 | // help us decide what versions we need to support). 52 | // - An anonymous MAC address and bundle ID to aggregate the other information on. 53 | // - What version of Swift is being used (if applicable). 54 | 55 | void RLMSendAnalytics(); 56 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMArray_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @interface RLMArray () 22 | - (instancetype)initWithObjectClassName:(NSString *)objectClassName; 23 | - (NSString *)descriptionWithMaxDepth:(NSUInteger)depth; 24 | @end 25 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMArray_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMArray_Private.h" 20 | 21 | #import "RLMCollection_Private.hpp" 22 | 23 | #import 24 | 25 | #import 26 | #import 27 | 28 | namespace realm { 29 | class LinkView; 30 | class Results; 31 | class TableView; 32 | struct SortOrder; 33 | } 34 | 35 | @class RLMObjectBase; 36 | @class RLMObjectSchema; 37 | class RLMObservationInfo; 38 | 39 | @interface RLMArray () { 40 | @protected 41 | NSString *_objectClassName; 42 | @public 43 | // The name of the property which this RLMArray represents 44 | NSString *_key; 45 | __weak RLMObjectBase *_parentObject; 46 | } 47 | @end 48 | 49 | // 50 | // LinkView backed RLMArray subclass 51 | // 52 | @interface RLMArrayLinkView : RLMArray 53 | @property (nonatomic, unsafe_unretained) RLMObjectSchema *objectSchema; 54 | 55 | + (RLMArrayLinkView *)arrayWithObjectClassName:(NSString *)objectClassName 56 | view:(realm::LinkViewRef)view 57 | realm:(RLMRealm *)realm 58 | key:(NSString *)key 59 | parentSchema:(RLMObjectSchema *)parentSchema; 60 | 61 | // deletes all objects in the RLMArray from their containing realms 62 | - (void)deleteObjectsFromRealm; 63 | @end 64 | 65 | void RLMValidateArrayObservationKey(NSString *keyPath, RLMArray *array); 66 | 67 | // Initialize the observation info for an array if needed 68 | void RLMEnsureArrayObservationInfo(std::unique_ptr& info, 69 | NSString *keyPath, RLMArray *array, id observed); 70 | 71 | 72 | // 73 | // RLMResults private methods 74 | // 75 | @interface RLMResults () 76 | + (instancetype)resultsWithObjectSchema:(RLMObjectSchema *)objectSchema 77 | results:(realm::Results)results; 78 | 79 | - (void)deleteObjectsFromRealm; 80 | @end 81 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMCollection_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | #import 22 | 23 | namespace realm { 24 | class List; 25 | class Results; 26 | class TableView; 27 | struct CollectionChangeSet; 28 | struct NotificationToken; 29 | } 30 | @class RLMObjectSchema; 31 | 32 | @protocol RLMFastEnumerable 33 | @property (nonatomic, readonly) RLMRealm *realm; 34 | @property (nonatomic, readonly) RLMObjectSchema *objectSchema; 35 | @property (nonatomic, readonly) NSUInteger count; 36 | 37 | - (NSUInteger)indexInSource:(NSUInteger)index; 38 | - (realm::TableView)tableView; 39 | @end 40 | 41 | // An object which encapulates the shared logic for fast-enumerating RLMArray 42 | // and RLMResults, and has a buffer to store strong references to the current 43 | // set of enumerated items 44 | @interface RLMFastEnumerator : NSObject 45 | - (instancetype)initWithCollection:(id)collection 46 | objectSchema:(RLMObjectSchema *)objectSchema; 47 | 48 | // Detach this enumerator from the source collection. Must be called before the 49 | // source collection is changed. 50 | - (void)detach; 51 | 52 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state 53 | count:(NSUInteger)len; 54 | @end 55 | 56 | @interface RLMCancellationToken : RLMNotificationToken 57 | - (instancetype)initWithToken:(realm::NotificationToken)token; 58 | @end 59 | 60 | @interface RLMCollectionChange () 61 | - (instancetype)initWithChanges:(realm::CollectionChangeSet)indices; 62 | @end 63 | 64 | template 65 | RLMNotificationToken *RLMAddNotificationBlock(id objcCollection, 66 | Collection& collection, 67 | void (^block)(id, RLMCollectionChange *, NSError *), 68 | bool suppressInitialChange=false); 69 | 70 | NSArray *RLMCollectionValueForKey(id collection, NSString *key); 71 | void RLMCollectionSetValueForKey(id collection, NSString *key, id value); 72 | NSString *RLMDescriptionWithMaxDepth(NSString *name, id collection, NSUInteger depth); 73 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMListBase.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @class RLMArray; 22 | 23 | // A base class for Swift generic Lists to make it possible to interact with 24 | // them from obj-c 25 | @interface RLMListBase : NSObject 26 | @property (nonatomic, strong) RLMArray *_rlmArray; 27 | 28 | - (instancetype)initWithArray:(RLMArray *)array; 29 | @end 30 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMMigration_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | #import 21 | #import 22 | 23 | typedef void (^RLMObjectBaseMigrationBlock)(RLMObjectBase *oldObject, RLMObjectBase *newObject); 24 | 25 | @interface RLMMigration () 26 | 27 | @property (nonatomic, strong) RLMRealm *oldRealm; 28 | @property (nonatomic, strong) RLMRealm *realm; 29 | 30 | - (instancetype)initWithRealm:(RLMRealm *)realm oldRealm:(RLMRealm *)oldRealm; 31 | 32 | - (void)execute:(RLMMigrationBlock)block; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObjectBase.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | @class RLMRealm; 24 | @class RLMSchema; 25 | @class RLMObjectSchema; 26 | 27 | /// :nodoc: 28 | @interface RLMObjectBase : NSObject 29 | 30 | @property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; 31 | 32 | - (instancetype)init NS_DESIGNATED_INITIALIZER; 33 | 34 | + (NSString *)className; 35 | 36 | // Returns whether the class is included in the default set of classes managed by a Realm. 37 | + (BOOL)shouldIncludeInDefaultSchema; 38 | 39 | @end 40 | 41 | NS_ASSUME_NONNULL_END 42 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObjectBase_Dynamic.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @class RLMObjectSchema, RLMRealm; 22 | 23 | /** 24 | Returns the Realm that manages the object, if one exists. 25 | 26 | @warning This function is useful only in specialized circumstances, for example, when building components 27 | that integrate with Realm. If you are simply building an app on Realm, it is 28 | recommended to retrieve the Realm that manages the object via `RLMObject`. 29 | 30 | @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. 31 | 32 | @return The Realm which manages this object. Returns `nil `for unmanaged objects. 33 | */ 34 | FOUNDATION_EXTERN RLMRealm *RLMObjectBaseRealm(RLMObjectBase *object); 35 | 36 | /** 37 | Returns an `RLMObjectSchema` which describes the managed properties of the object. 38 | 39 | @warning This function is useful only in specialized circumstances, for example, when building components 40 | that integrate with Realm. If you are simply building an app on Realm, it is 41 | recommended to retrieve `objectSchema` via `RLMObject`. 42 | 43 | @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. 44 | 45 | @return The object schema which lists the managed properties for the object. 46 | */ 47 | FOUNDATION_EXTERN RLMObjectSchema *RLMObjectBaseObjectSchema(RLMObjectBase *object); 48 | 49 | /** 50 | Returns the object corresponding to a key value. 51 | 52 | @warning This function is useful only in specialized circumstances, for example, when building components 53 | that integrate with Realm. If you are simply building an app on Realm, it is 54 | recommended to retrieve key values via `RLMObject`. 55 | 56 | @warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object. 57 | 58 | @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. 59 | @param key The name of the property. 60 | 61 | @return The object for the property requested. 62 | */ 63 | FOUNDATION_EXTERN id RLMObjectBaseObjectForKeyedSubscript(RLMObjectBase *object, NSString *key); 64 | 65 | /** 66 | Sets a value for a key on the object. 67 | 68 | @warning This function is useful only in specialized circumstances, for example, when building components 69 | that integrate with Realm. If you are simply building an app on Realm, it is 70 | recommended to set key values via `RLMObject`. 71 | 72 | @warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object. 73 | 74 | @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. 75 | @param key The name of the property. 76 | @param obj The object to set as the value of the key. 77 | */ 78 | FOUNDATION_EXTERN void RLMObjectBaseSetObjectForKeyedSubscript(RLMObjectBase *object, NSString *key, id obj); 79 | 80 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObjectSchema.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | @class RLMProperty; 24 | 25 | /** 26 | This class represents Realm model object schemas. 27 | 28 | When using Realm, `RLMObjectSchema` instances allow performing migrations and 29 | introspecting the database's schema. 30 | 31 | Object schemas map to tables in the core database. 32 | */ 33 | @interface RLMObjectSchema : NSObject 34 | 35 | #pragma mark - Properties 36 | 37 | /** 38 | An array of `RLMProperty` instances representing the managed properties of a class described by the schema. 39 | 40 | @see `RLMProperty` 41 | */ 42 | @property (nonatomic, readonly, copy) NSArray *properties; 43 | 44 | /** 45 | The name of the class the schema describes. 46 | */ 47 | @property (nonatomic, readonly) NSString *className; 48 | 49 | /** 50 | The property which serves as the primary key for the class the schema describes, if any. 51 | */ 52 | @property (nonatomic, readonly, nullable) RLMProperty *primaryKeyProperty; 53 | 54 | #pragma mark - Methods 55 | 56 | /** 57 | Retrieves an `RLMProperty` object by the property name. 58 | 59 | @param propertyName The property's name. 60 | 61 | @return An `RLMProperty` object, or `nil` if there is no property with the given name. 62 | */ 63 | - (nullable RLMProperty *)objectForKeyedSubscript:(id )propertyName; 64 | 65 | /** 66 | Returns a Boolean value that indicates whether two `RLMObjectSchema` instances are equal. 67 | */ 68 | - (BOOL)isEqualToObjectSchema:(RLMObjectSchema *)objectSchema; 69 | 70 | @end 71 | 72 | NS_ASSUME_NONNULL_END 73 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObjectSchema_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | @class RLMRealm; 24 | 25 | // RLMObjectSchema private 26 | @interface RLMObjectSchema () { 27 | @public 28 | bool _isSwiftClass; 29 | } 30 | 31 | // writable redecleration 32 | @property (nonatomic, readwrite, copy) NSArray *properties; 33 | @property (nonatomic, readwrite, assign) bool isSwiftClass; 34 | 35 | // class used for this object schema 36 | @property (nonatomic, readwrite, assign) Class objectClass; 37 | @property (nonatomic, readwrite, assign) Class accessorClass; 38 | @property (nonatomic, readwrite, assign) Class unmanagedClass; 39 | 40 | @property (nonatomic, readwrite, nullable) RLMProperty *primaryKeyProperty; 41 | 42 | @property (nonatomic, copy) NSArray *computedProperties; 43 | @property (nonatomic, readonly) NSArray *swiftGenericProperties; 44 | 45 | // The Realm retains its object schemas, so they need to not retain the Realm 46 | @property (nonatomic, unsafe_unretained, nullable) RLMRealm *realm; 47 | // returns a cached or new schema for a given object class 48 | + (instancetype)schemaForObjectClass:(Class)objectClass; 49 | 50 | - (RLMProperty *)propertyForTableColumn:(size_t)tableCol; 51 | 52 | @end 53 | 54 | @interface RLMObjectSchema (Dynamic) 55 | /** 56 | This method is useful only in specialized circumstances, for example, when accessing objects 57 | in a Realm produced externally. If you are simply building an app on Realm, it is not recommended 58 | to use this method as an [RLMObjectSchema](RLMObjectSchema) is generated automatically for every [RLMObject](RLMObject) subclass. 59 | 60 | Initialize an RLMObjectSchema with classname, objectClass, and an array of properties 61 | 62 | @warning This method is useful only in specialized circumstances. 63 | 64 | @param objectClassName The name of the class used to refer to objects of this type. 65 | @param objectClass The Objective-C class used when creating instances of this type. 66 | @param properties An array of RLMProperty instances describing the managed properties for this type. 67 | 68 | @return An initialized instance of RLMObjectSchema. 69 | */ 70 | - (instancetype)initWithClassName:(NSString *)objectClassName objectClass:(Class)objectClass properties:(NSArray *)properties; 71 | @end 72 | 73 | NS_ASSUME_NONNULL_END 74 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObjectSchema_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMObjectSchema_Private.h" 20 | 21 | #import "object_schema.hpp" 22 | #import "RLMObject_Private.hpp" 23 | 24 | #import 25 | #import 26 | 27 | namespace realm { 28 | class Table; 29 | } 30 | 31 | class RLMObservationInfo; 32 | 33 | // RLMObjectSchema private 34 | @interface RLMObjectSchema () { 35 | @public 36 | std::vector _observedObjects; 37 | } 38 | @property (nonatomic) realm::Table *table; 39 | 40 | // shallow copy reusing properties and property map 41 | - (instancetype)shallowCopy; 42 | 43 | // create realm::ObjectSchema copy 44 | - (realm::ObjectSchema)objectStoreCopy; 45 | 46 | // initialize with realm::ObjectSchema 47 | + (instancetype)objectSchemaForObjectStoreSchema:(realm::ObjectSchema &)objectSchema; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObjectStore.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | @class RLMRealm, RLMSchema, RLMObjectSchema, RLMObjectBase, RLMResults, RLMProperty; 26 | 27 | // 28 | // Accessor Creation 29 | // 30 | 31 | // create or get cached accessors for the given schema 32 | void RLMRealmCreateAccessors(RLMSchema *schema); 33 | 34 | // Clear the cache of created accessor classes 35 | void RLMClearAccessorCache(); 36 | 37 | 38 | // 39 | // Options for object creation 40 | // 41 | typedef NS_OPTIONS(NSUInteger, RLMCreationOptions) { 42 | // Normal object creation 43 | RLMCreationOptionsNone = 0, 44 | // If the property is a link or array property, upsert the linked objects 45 | // if they have a primary key, and insert them otherwise. 46 | RLMCreationOptionsCreateOrUpdate = 1 << 0, 47 | // Allow unmanaged objects to be promoted to managed objects 48 | // if false objects are copied during object creation 49 | RLMCreationOptionsPromoteUnmanaged = 1 << 1, 50 | }; 51 | 52 | 53 | // 54 | // Adding, Removing, Getting Objects 55 | // 56 | 57 | // add an object to the given realm 58 | void RLMAddObjectToRealm(RLMObjectBase *object, RLMRealm *realm, bool createOrUpdate); 59 | 60 | // delete an object from its realm 61 | void RLMDeleteObjectFromRealm(RLMObjectBase *object, RLMRealm *realm); 62 | 63 | // deletes all objects from a realm 64 | void RLMDeleteAllObjectsFromRealm(RLMRealm *realm); 65 | 66 | // get objects of a given class 67 | RLMResults *RLMGetObjects(RLMRealm *realm, NSString *objectClassName, NSPredicate *predicate) NS_RETURNS_RETAINED; 68 | 69 | // get an object with the given primary key 70 | id RLMGetObject(RLMRealm *realm, NSString *objectClassName, id key) NS_RETURNS_RETAINED; 71 | 72 | // create object from array or dictionary 73 | RLMObjectBase *RLMCreateObjectInRealmWithValue(RLMRealm *realm, NSString *className, id value, bool createOrUpdate) NS_RETURNS_RETAINED; 74 | 75 | 76 | // 77 | // Accessor Creation 78 | // 79 | 80 | 81 | // switch List<> properties from being backed by unmanaged RLMArrays to RLMArrayLinkView 82 | void RLMInitializeSwiftAccessorGenerics(RLMObjectBase *object); 83 | 84 | #ifdef __cplusplus 85 | } 86 | 87 | namespace realm { 88 | class Table; 89 | template class BasicRowExpr; 90 | using RowExpr = BasicRowExpr; 91 | } 92 | // Create accessors 93 | RLMObjectBase *RLMCreateObjectAccessor(RLMRealm *realm, 94 | RLMObjectSchema *objectSchema, 95 | NSUInteger index) NS_RETURNS_RETAINED; 96 | RLMObjectBase *RLMCreateObjectAccessor(RLMRealm *realm, 97 | RLMObjectSchema *objectSchema, 98 | realm::RowExpr row) NS_RETURNS_RETAINED; 99 | #endif 100 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMObject_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMObject_Private.h" 20 | 21 | #import "RLMRealm_Private.hpp" 22 | 23 | #import // required by row.hpp 24 | #import 25 | 26 | class RLMObservationInfo; 27 | 28 | // RLMObject accessor and read/write realm 29 | @interface RLMObjectBase () { 30 | @public 31 | realm::Row _row; 32 | RLMObservationInfo *_observationInfo; 33 | } 34 | @end 35 | 36 | // throw an exception if the object is invalidated or on the wrong thread 37 | static inline void RLMVerifyAttached(__unsafe_unretained RLMObjectBase *const obj) { 38 | if (!obj->_row.is_attached()) { 39 | @throw RLMException(@"Object has been deleted or invalidated."); 40 | } 41 | [obj->_realm verifyThread]; 42 | } 43 | 44 | // throw an exception if the object can't be modified for any reason 45 | static inline void RLMVerifyInWriteTransaction(__unsafe_unretained RLMObjectBase *const obj) { 46 | // first verify is attached 47 | RLMVerifyAttached(obj); 48 | 49 | if (!obj->_realm.inWriteTransaction) { 50 | @throw RLMException(@"Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first."); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMOptionalBase.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | #import 21 | 22 | @class RLMObjectBase, RLMProperty; 23 | 24 | @interface RLMOptionalBase : NSProxy 25 | 26 | - (instancetype)init; 27 | 28 | @property (nonatomic, weak) RLMObjectBase *object; 29 | 30 | @property (nonatomic, unsafe_unretained) RLMProperty *property; 31 | 32 | @property (nonatomic, strong) id underlyingValue; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMPlatform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fumiyasac/DatabasePersistencePattern/9cac78996b89e0b81b635dec616c0aa9a0e36cbf/Pods/Realm/include/RLMPlatform.h -------------------------------------------------------------------------------- /Pods/Realm/include/RLMPredicateUtil.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | 18 | #import 19 | 20 | using ExpressionVisitor = NSExpression *(*)(NSExpression *); 21 | NSPredicate *transformPredicate(NSPredicate *, ExpressionVisitor); 22 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMPrefix.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifdef __OBJC__ 20 | #import 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | 30 | #import 31 | #import 32 | #import 33 | #import 34 | #import 35 | #endif 36 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMProperty.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | #import 21 | 22 | NS_ASSUME_NONNULL_BEGIN 23 | 24 | /// :nodoc: 25 | @protocol RLMInt 26 | @end 27 | 28 | /// :nodoc: 29 | @protocol RLMBool 30 | @end 31 | 32 | /// :nodoc: 33 | @protocol RLMDouble 34 | @end 35 | 36 | /// :nodoc: 37 | @protocol RLMFloat 38 | @end 39 | 40 | /// :nodoc: 41 | @interface NSNumber () 42 | @end 43 | 44 | /** 45 | `RLMProperty` instances represent properties managed by a Realm in the context of an object schema. Such properties may 46 | be persisted to a Realm file or computed from other data from the Realm. 47 | 48 | When using Realm, `RLMProperty` instances allow performing migrations and introspecting the database's schema. 49 | 50 | These property instances map to columns in the core database. 51 | */ 52 | @interface RLMProperty : NSObject 53 | 54 | #pragma mark - Properties 55 | 56 | /** 57 | The name of the property. 58 | */ 59 | @property (nonatomic, readonly) NSString *name; 60 | 61 | /** 62 | The type of the property. 63 | 64 | @see `RLMPropertyType` 65 | */ 66 | @property (nonatomic, readonly) RLMPropertyType type; 67 | 68 | /** 69 | Indicates whether this property is indexed. 70 | 71 | @see `RLMObject` 72 | */ 73 | @property (nonatomic, readonly) BOOL indexed; 74 | 75 | /** 76 | For `RLMObject` and `RLMArray` properties, the name of the class of object stored in the property. 77 | */ 78 | @property (nonatomic, readonly, copy, nullable) NSString *objectClassName; 79 | 80 | /** 81 | For linking objects properties, the property name of the property the linking objects property is linked to. 82 | */ 83 | @property (nonatomic, readonly, copy, nullable) NSString *linkOriginPropertyName; 84 | 85 | /** 86 | Indicates whether this property is optional. 87 | */ 88 | @property (nonatomic, readonly) BOOL optional; 89 | 90 | #pragma mark - Methods 91 | 92 | /** 93 | Returns a Boolean value that indicates whether a given property object is equal to the receiver. 94 | */ 95 | - (BOOL)isEqualToProperty:(RLMProperty *)property; 96 | 97 | @end 98 | 99 | 100 | /** 101 | An `RLMPropertyDescriptor` instance represents a specific property on a given class. 102 | */ 103 | @interface RLMPropertyDescriptor : NSObject 104 | 105 | /** 106 | Creates and returns a property descriptor. 107 | 108 | @param objectClass The class of this property descriptor. 109 | @param propertyName The name of this property descriptor. 110 | */ 111 | + (instancetype)descriptorWithClass:(Class)objectClass propertyName:(NSString *)propertyName; 112 | 113 | /// The class of the property. 114 | @property (nonatomic, readonly) Class objectClass; 115 | 116 | /// The name of the property. 117 | @property (nonatomic, readonly) NSString *propertyName; 118 | 119 | @end 120 | 121 | NS_ASSUME_NONNULL_END 122 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMProperty_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | #import "property.hpp" 22 | 23 | @interface RLMProperty () 24 | 25 | + (instancetype)propertyForObjectStoreProperty:(const realm::Property&)property; 26 | 27 | - (realm::Property)objectStoreCopy; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMQueryUtil.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | #import 22 | 23 | namespace realm { 24 | class Group; 25 | class Query; 26 | class Table; 27 | struct SortOrder; 28 | } 29 | 30 | @class RLMObjectSchema, RLMProperty, RLMSchema, RLMSortDescriptor; 31 | 32 | extern NSString * const RLMPropertiesComparisonTypeMismatchException; 33 | extern NSString * const RLMUnsupportedTypesFoundInPropertyComparisonException; 34 | 35 | realm::Query RLMPredicateToQuery(NSPredicate *predicate, RLMObjectSchema *objectSchema, 36 | RLMSchema *schema, realm::Group &group); 37 | 38 | // return property - throw for invalid column name 39 | RLMProperty *RLMValidatedProperty(RLMObjectSchema *objectSchema, NSString *columnName); 40 | 41 | // validate the array of RLMSortDescriptors and convert it to a realm::SortOrder 42 | realm::SortOrder RLMSortOrderFromDescriptors(realm::Table& table, NSArray *descriptors); 43 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMRealmConfiguration_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @class RLMSchema; 22 | 23 | @interface RLMRealmConfiguration () 24 | 25 | @property (nonatomic, readwrite) bool cache; 26 | @property (nonatomic, readwrite) bool dynamic; 27 | @property (nonatomic, readwrite) bool disableFormatUpgrade; 28 | @property (nonatomic, copy) RLMSchema *customSchema; 29 | 30 | // Get the default confiugration without copying it 31 | + (RLMRealmConfiguration *)rawDefaultConfiguration; 32 | 33 | + (void)resetRealmConfigurationState; 34 | @end 35 | 36 | // Get a path in the platform-appropriate documents directory with the given filename 37 | FOUNDATION_EXTERN NSString *RLMRealmPathForFile(NSString *fileName); 38 | FOUNDATION_EXTERN NSString *RLMRealmPathForFileAndBundleIdentifier(NSString *fileName, NSString *mainBundleIdentifier); 39 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMRealmConfiguration_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMRealmConfiguration_Private.h" 20 | #import "shared_realm.hpp" 21 | 22 | @interface RLMRealmConfiguration () 23 | - (realm::Realm::Config&)config; 24 | @end 25 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMRealmUtil.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | #import 21 | #import 22 | 23 | @class RLMRealm; 24 | 25 | namespace realm { 26 | class BindingContext; 27 | } 28 | 29 | // Add a Realm to the weak cache 30 | void RLMCacheRealm(std::string const& path, RLMRealm *realm); 31 | // Get a Realm for the given path which can be used on the current thread 32 | RLMRealm *RLMGetThreadLocalCachedRealmForPath(std::string const& path); 33 | // Get a Realm for the given path 34 | RLMRealm *RLMGetAnyCachedRealmForPath(std::string const& path); 35 | // Clear the weak cache of Realms 36 | void RLMClearRealmCache(); 37 | 38 | // Install an uncaught exception handler that cancels write transactions 39 | // for all cached realms on the current thread 40 | void RLMInstallUncaughtExceptionHandler(); 41 | 42 | std::unique_ptr RLMCreateBindingContext(RLMRealm *realm); 43 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMRealm_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @class RLMFastEnumerator; 22 | 23 | // Disable syncing files to disk. Cannot be re-enabled. Use only for tests. 24 | FOUNDATION_EXTERN void RLMDisableSyncToDisk(); 25 | 26 | FOUNDATION_EXTERN NSData *RLMRealmValidatedEncryptionKey(NSData *key); 27 | 28 | // Translate an in-flight exception resulting from opening a SharedGroup to 29 | // an NSError or NSException (if error is nil) 30 | void RLMRealmTranslateException(NSError **error); 31 | 32 | // RLMRealm private members 33 | @interface RLMRealm () 34 | 35 | @property (nonatomic, readonly) BOOL dynamic; 36 | @property (nonatomic, readwrite) RLMSchema *schema; 37 | 38 | + (void)resetRealmState; 39 | 40 | - (void)registerEnumerator:(RLMFastEnumerator *)enumerator; 41 | - (void)unregisterEnumerator:(RLMFastEnumerator *)enumerator; 42 | - (void)detachAllEnumerators; 43 | 44 | - (void)sendNotifications:(RLMNotification)notification; 45 | - (void)verifyThread; 46 | - (void)verifyNotificationsAreSupported; 47 | 48 | + (NSString *)writeableTemporaryPathForFile:(NSString *)fileName; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMRealm_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMRealm_Private.h" 20 | #import "RLMUtil.hpp" 21 | #import "shared_realm.hpp" 22 | 23 | #import 24 | 25 | namespace realm { 26 | class Group; 27 | class Realm; 28 | typedef std::shared_ptr SharedRealm; 29 | } 30 | 31 | @interface RLMRealm () { 32 | @public 33 | realm::SharedRealm _realm; 34 | } 35 | 36 | // FIXME - group should not be exposed 37 | @property (nonatomic, readonly) realm::Group *group; 38 | @end 39 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMResults_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @class RLMObjectSchema; 22 | 23 | @interface RLMResults () 24 | @property (nonatomic, unsafe_unretained) RLMObjectSchema *objectSchema; 25 | @property (nonatomic, readonly, getter=isAttached) BOOL attached; 26 | 27 | + (instancetype)emptyDetachedResults; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMSchema.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | NS_ASSUME_NONNULL_BEGIN 22 | 23 | @class RLMObjectSchema; 24 | 25 | /** 26 | `RLMSchema` instances represent collections of model object schemas managed by a Realm. 27 | 28 | When using Realm, `RLMSchema` instances allow performing migrations and 29 | introspecting the database's schema. 30 | 31 | Schemas map to collections of tables in the core database. 32 | */ 33 | @interface RLMSchema : NSObject 34 | 35 | #pragma mark - Properties 36 | 37 | /** 38 | An `NSArray` containing `RLMObjectSchema`s for all object types in the Realm. 39 | 40 | This property is intended to be used during migrations for dynamic introspection. 41 | 42 | @see `RLMObjectSchema` 43 | */ 44 | @property (nonatomic, readonly, copy) NSArray *objectSchema; 45 | 46 | #pragma mark - Methods 47 | 48 | /** 49 | Returns an `RLMObjectSchema` for the given class name in the schema. 50 | 51 | @param className The object class name. 52 | @return An `RLMObjectSchema` for the given class in the schema. 53 | 54 | @see `RLMObjectSchema` 55 | */ 56 | - (nullable RLMObjectSchema *)schemaForClassName:(NSString *)className; 57 | 58 | /** 59 | Looks up and returns an `RLMObjectSchema` for the given class name in the Realm. 60 | 61 | If there is no object of type `className` in the schema, an exception will be thrown. 62 | 63 | @param className The object class name. 64 | @return An `RLMObjectSchema` for the given class in this Realm. 65 | 66 | @see `RLMObjectSchema` 67 | */ 68 | - (RLMObjectSchema *)objectForKeyedSubscript:(id )className; 69 | 70 | /** 71 | Returns a Boolean value that indicates whether two `RLMSchema` instances are equivalent. 72 | */ 73 | - (BOOL)isEqualToSchema:(RLMSchema *)schema; 74 | 75 | @end 76 | 77 | NS_ASSUME_NONNULL_END 78 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMSchema_Private.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #import 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | @class RLMRealm; 28 | 29 | // 30 | // RLMSchema private interface 31 | // 32 | @interface RLMSchema () 33 | 34 | /** 35 | Returns an `RLMSchema` containing only the given `RLMObject` subclasses. 36 | 37 | @param classes The classes to be included in the schema. 38 | 39 | @return An `RLMSchema` containing only the given classes. 40 | */ 41 | + (instancetype)schemaWithObjectClasses:(NSArray *)classes; 42 | 43 | @property (nonatomic, readwrite, copy) NSArray *objectSchema; 44 | 45 | // schema based on runtime objects 46 | + (instancetype)sharedSchema; 47 | 48 | // schema based upon all currently registered object classes 49 | + (instancetype)partialSharedSchema; 50 | 51 | // class for string 52 | + (nullable Class)classForString:(NSString *)className; 53 | 54 | // shallow copy for reusing schema properties accross the same Realm on multiple threads 55 | - (instancetype)shallowCopy; 56 | 57 | + (nullable RLMObjectSchema *)sharedSchemaForClass:(Class)cls; 58 | 59 | @end 60 | 61 | NS_ASSUME_NONNULL_END 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMSchema_Private.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "RLMSchema_Private.h" 20 | 21 | #import 22 | 23 | namespace realm { 24 | class Schema; 25 | class ObjectSchema; 26 | } 27 | 28 | @interface RLMSchema () 29 | + (instancetype)dynamicSchemaFromObjectStoreSchema:(realm::Schema &)objectStoreSchema; 30 | - (std::unique_ptr)objectStoreCopy; 31 | @end 32 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMSwiftBridgingHeader.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | #import 21 | 22 | @interface RLMRealm (Swift) 23 | + (void)resetRealmState; 24 | @end 25 | 26 | @interface RLMArray (Swift) 27 | 28 | - (instancetype)initWithObjectClassName:(NSString *)objectClassName; 29 | 30 | - (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; 31 | - (RLMResults *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; 32 | 33 | @end 34 | 35 | @interface RLMResults (Swift) 36 | 37 | - (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; 38 | - (RLMResults *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; 39 | 40 | @end 41 | 42 | @interface RLMObjectBase (Swift) 43 | 44 | - (instancetype)initWithRealm:(RLMRealm *)realm schema:(RLMObjectSchema *)schema defaultValues:(BOOL)useDefaults; 45 | 46 | + (RLMResults *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; 47 | + (RLMResults *)objectsInRealm:(RLMRealm *)realm where:(NSString *)predicateFormat args:(va_list)args; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMSwiftSupport.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | @interface RLMSwiftSupport : NSObject 22 | 23 | + (BOOL)isSwiftClassName:(NSString *)className; 24 | + (NSString *)demangleClassName:(NSString *)className; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/Realm/include/RLMUpdateChecker.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | // Asynchronously check for updates to Realm if running on a simulator 20 | void RLMCheckForUpdates(); 21 | -------------------------------------------------------------------------------- /Pods/Realm/include/Realm.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #import 20 | 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | -------------------------------------------------------------------------------- /Pods/Realm/include/collection_notifications.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_COLLECTION_NOTIFICATIONS_HPP 20 | #define REALM_COLLECTION_NOTIFICATIONS_HPP 21 | 22 | #include "index_set.hpp" 23 | #include "util/atomic_shared_ptr.hpp" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace realm { 31 | namespace _impl { 32 | class CollectionNotifier; 33 | } 34 | 35 | // A token which keeps an asynchronous query alive 36 | struct NotificationToken { 37 | NotificationToken() = default; 38 | NotificationToken(std::shared_ptr<_impl::CollectionNotifier> notifier, size_t token); 39 | ~NotificationToken(); 40 | 41 | NotificationToken(NotificationToken&&); 42 | NotificationToken& operator=(NotificationToken&&); 43 | 44 | NotificationToken(NotificationToken const&) = delete; 45 | NotificationToken& operator=(NotificationToken const&) = delete; 46 | 47 | private: 48 | util::AtomicSharedPtr<_impl::CollectionNotifier> m_notifier; 49 | size_t m_token; 50 | }; 51 | 52 | struct CollectionChangeSet { 53 | struct Move { 54 | size_t from; 55 | size_t to; 56 | 57 | bool operator==(Move m) const { return from == m.from && to == m.to; } 58 | }; 59 | 60 | IndexSet deletions; 61 | IndexSet insertions; 62 | IndexSet modifications; 63 | std::vector moves; 64 | 65 | bool empty() const { return deletions.empty() && insertions.empty() && modifications.empty() && moves.empty(); } 66 | }; 67 | 68 | using CollectionChangeCallback = std::function; 69 | } // namespace realm 70 | 71 | #endif // REALM_COLLECTION_NOTIFICATIONS_HPP 72 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_HPP 21 | #define REALM_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #endif // REALM_HPP 29 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/column_fwd.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_COLUMN_FWD_HPP 21 | #define REALM_COLUMN_FWD_HPP 22 | 23 | #include 24 | 25 | namespace realm { 26 | 27 | // Regular classes 28 | class ColumnBase; 29 | class StringColumn; 30 | class StringEnumColumn; 31 | class BinaryColumn; 32 | class SubtableColumn; 33 | class MixedColumn; 34 | class LinkColumn; 35 | class LinkListColumn; 36 | 37 | // Templated classes 38 | template 39 | class Column; 40 | template 41 | class BasicColumn; 42 | 43 | namespace util { 44 | template class Optional; 45 | } 46 | 47 | // Shortcuts, aka typedefs. 48 | using IntegerColumn = Column; 49 | using IntNullColumn = Column>; 50 | using DoubleColumn = Column; 51 | using FloatColumn = Column; 52 | 53 | } // namespace realm 54 | 55 | #endif // REALM_COLUMN_FWD_HPP 56 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/column_type.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_COLUMN_TYPE_HPP 21 | #define REALM_COLUMN_TYPE_HPP 22 | 23 | namespace realm { 24 | 25 | 26 | // Note: Enumeration value assignments must be kept in sync with 27 | // . 28 | enum ColumnType { 29 | // Column types 30 | col_type_Int = 0, 31 | col_type_Bool = 1, 32 | col_type_String = 2, 33 | col_type_StringEnum = 3, // double refs 34 | col_type_Binary = 4, 35 | col_type_Table = 5, 36 | col_type_Mixed = 6, 37 | col_type_OldDateTime = 7, 38 | col_type_Timestamp = 8, 39 | col_type_Float = 9, 40 | col_type_Double = 10, 41 | col_type_Reserved4 = 11, // Decimal 42 | col_type_Link = 12, 43 | col_type_LinkList = 13, 44 | col_type_BackLink = 14 45 | }; 46 | 47 | 48 | // Column attributes can be combined using bitwise or. 49 | enum ColumnAttr { 50 | col_attr_None = 0, 51 | col_attr_Indexed = 1, 52 | 53 | /// Specifies that this column forms a unique constraint. It requires 54 | /// `col_attr_Indexed`. 55 | col_attr_Unique = 2, 56 | 57 | /// Reserved for future use. 58 | col_attr_Reserved = 4, 59 | 60 | /// Specifies that the links of this column are strong, not weak. Applies 61 | /// only to link columns (`type_Link` and `type_LinkList`). 62 | col_attr_StrongLinks = 8, 63 | 64 | /// Specifies that elements in the column can be null. 65 | col_attr_Nullable = 16 66 | }; 67 | 68 | 69 | } // namespace realm 70 | 71 | #endif // REALM_COLUMN_TYPE_HPP 72 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/commit_log.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_COMMIT_LOG_HPP 21 | #define REALM_COMMIT_LOG_HPP 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | 30 | namespace realm { 31 | 32 | // FIXME: Why is this exception class exposed? 33 | class LogFileError: public std::runtime_error { 34 | public: 35 | LogFileError(const std::string& file_name): 36 | std::runtime_error(file_name) 37 | { 38 | } 39 | }; 40 | 41 | /// Create a writelog collector and associate it with a filepath. You'll need 42 | /// one writelog collector for each shared group. Commits from writelog 43 | /// collectors for a specific filepath may later be obtained through other 44 | /// writelog collectors associated with said filepath. The caller assumes 45 | /// ownership of the writelog collector and must destroy it, but only AFTER 46 | /// destruction of the shared group using it. 47 | std::unique_ptr 48 | make_client_history(const std::string& path, const char* encryption_key = nullptr); 49 | 50 | } // namespace realm 51 | 52 | 53 | #endif // REALM_COMMIT_LOG_HPP 54 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/data_type.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_DATA_TYPE_HPP 21 | #define REALM_DATA_TYPE_HPP 22 | 23 | namespace realm { 24 | 25 | // Note: Value assignments must be kept in sync with 26 | // Note: Value assignments must be kept in sync with 27 | // Note: Value assignments must be kept in sync with 28 | // Note: Value assignments must be kept in sync with "com/realm/ColumnType.java" 29 | enum DataType { 30 | type_Int = 0, 31 | type_Bool = 1, 32 | type_Float = 9, 33 | type_Double = 10, 34 | type_String = 2, 35 | type_Binary = 4, 36 | type_OldDateTime = 7, 37 | type_Timestamp = 8, 38 | type_Table = 5, 39 | type_Mixed = 6, 40 | type_Link = 12, 41 | type_LinkList = 13 42 | }; 43 | 44 | /// See Descriptor::set_link_type(). 45 | enum LinkType { 46 | link_Strong, 47 | link_Weak 48 | }; 49 | 50 | } // namespace realm 51 | 52 | #endif // REALM_DATA_TYPE_HPP 53 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/descriptor_fwd.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_DESCRIPTOR_FWD_HPP 21 | #define REALM_DESCRIPTOR_FWD_HPP 22 | 23 | #include 24 | 25 | 26 | namespace realm { 27 | 28 | class Descriptor; 29 | typedef util::bind_ptr DescriptorRef; 30 | typedef util::bind_ptr ConstDescriptorRef; 31 | 32 | } // namespace realm 33 | 34 | #endif // REALM_DESCRIPTOR_FWD_HPP 35 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/disable_sync_to_disk.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_DISABLE_SYNC_TO_DISK_HPP 21 | #define REALM_DISABLE_SYNC_TO_DISK_HPP 22 | 23 | #include 24 | 25 | namespace realm { 26 | 27 | /// Completely disable synchronization with storage device to speed up unit 28 | /// testing. This is an unsafe mode of operation, and should never be used in 29 | /// production. This function is thread safe. 30 | void disable_sync_to_disk(); 31 | 32 | /// Returns true after disable_sync_to_disk() has been called. This function is 33 | /// thread safe. 34 | bool get_disable_sync_to_disk() noexcept; 35 | 36 | } // namespace realm 37 | 38 | #endif // REALM_DISABLE_SYNC_TO_DISK_HPP 39 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/handover_defs.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_HANDOVER_DEFS 21 | #define REALM_HANDOVER_DEFS 22 | 23 | #include 24 | #include 25 | 26 | namespace realm { 27 | 28 | enum class ConstSourcePayload { Copy, Stay }; 29 | enum class MutableSourcePayload { Move }; 30 | 31 | struct RowBaseHandoverPatch; 32 | struct TableViewHandoverPatch; 33 | 34 | struct TableHandoverPatch { 35 | size_t m_table_num; 36 | }; 37 | 38 | struct LinkViewHandoverPatch { 39 | std::unique_ptr m_table; 40 | size_t m_col_num; 41 | size_t m_row_ndx; 42 | }; 43 | 44 | // Base class for handover patches for query nodes. Subclasses are declared in query_engine.hpp. 45 | struct QueryNodeHandoverPatch { 46 | virtual ~QueryNodeHandoverPatch() = default; 47 | }; 48 | 49 | using QueryNodeHandoverPatches = std::vector>; 50 | 51 | struct QueryHandoverPatch { 52 | std::unique_ptr m_table; 53 | std::unique_ptr table_view_data; 54 | std::unique_ptr link_view_data; 55 | QueryNodeHandoverPatches m_node_data; 56 | }; 57 | 58 | struct TableViewHandoverPatch { 59 | std::unique_ptr m_table; 60 | std::unique_ptr linked_table; 61 | std::unique_ptr linked_row; 62 | bool was_in_sync; 63 | QueryHandoverPatch query_patch; 64 | std::unique_ptr linkview_patch; 65 | }; 66 | 67 | 68 | struct RowBaseHandoverPatch { 69 | std::unique_ptr m_table; 70 | size_t row_ndx; 71 | }; 72 | 73 | 74 | } // end namespace Realm 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/history.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_HISTORY_HPP 21 | #define REALM_HISTORY_HPP 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | 29 | namespace realm { 30 | 31 | std::unique_ptr make_in_realm_history(const std::string& realm_path); 32 | 33 | } // namespace realm 34 | 35 | 36 | #endif // REALM_HISTORY_HPP 37 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/impl/array_writer.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | ***************************************************************************/ 20 | 21 | #ifndef REALM_ARRAY_WRITER_HPP 22 | #define REALM_ARRAY_WRITER_HPP 23 | 24 | #include 25 | 26 | namespace realm { 27 | namespace _impl { 28 | 29 | class ArrayWriterBase { 30 | public: 31 | virtual ~ArrayWriterBase() {} 32 | 33 | /// Write the specified array data and its checksum into free 34 | /// space. 35 | /// 36 | /// Returns the ref (position in the target stream) of the written copy of 37 | /// the specified array data. 38 | virtual ref_type write_array(const char* data, size_t size, uint32_t checksum) = 0; 39 | }; 40 | 41 | } // namespace impl_ 42 | } // namespace realm 43 | 44 | #endif // REALM_ARRAY_WRITER_HPP 45 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/impl/output_stream.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_IMPL_OUTPUT_STREAM_HPP 21 | #define REALM_IMPL_OUTPUT_STREAM_HPP 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | namespace realm { 33 | namespace _impl { 34 | 35 | 36 | class OutputStream: public ArrayWriterBase { 37 | public: 38 | OutputStream(std::ostream&); 39 | ~OutputStream() noexcept; 40 | 41 | ref_type get_ref_of_next_array() const noexcept; 42 | 43 | void write(const char* data, size_t size); 44 | 45 | ref_type write_array(const char* data, size_t size, uint32_t checksum) override; 46 | 47 | private: 48 | ref_type m_next_ref; 49 | std::ostream& m_out; 50 | 51 | void do_write(const char* data, size_t size); 52 | }; 53 | 54 | 55 | 56 | 57 | 58 | // Implementation: 59 | 60 | inline OutputStream::OutputStream(std::ostream& out): 61 | m_next_ref(0), 62 | m_out(out) 63 | { 64 | } 65 | 66 | inline OutputStream::~OutputStream() noexcept 67 | { 68 | } 69 | 70 | inline size_t OutputStream::get_ref_of_next_array() const noexcept 71 | { 72 | return m_next_ref; 73 | } 74 | 75 | 76 | } // namespace _impl 77 | } // namespace realm 78 | 79 | #endif // REALM_IMPL_OUTPUT_STREAM_HPP 80 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/link_view_fwd.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_LINK_VIEW_FWD_HPP 21 | #define REALM_LINK_VIEW_FWD_HPP 22 | 23 | #include 24 | 25 | namespace realm { 26 | 27 | class LinkView; 28 | using LinkViewRef = std::shared_ptr; 29 | using ConstLinkViewRef = std::shared_ptr; 30 | 31 | } // namespace realm 32 | 33 | #endif // REALM_LINK_VIEW_FWD_HPP 34 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/owned_data.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_OWNED_DATA_HPP 21 | #define REALM_OWNED_DATA_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace realm { 27 | 28 | /// A chunk of owned data. 29 | class OwnedData { 30 | public: 31 | /// Construct a null reference. 32 | OwnedData() noexcept {} 33 | 34 | /// If \a data_to_copy is 'null', \a data_size must be zero. 35 | OwnedData(const char* data_to_copy, size_t data_size) : m_size(data_size) 36 | { 37 | REALM_ASSERT_DEBUG(data_to_copy || data_size == 0); 38 | if (data_to_copy) { 39 | m_data = std::unique_ptr(new char[data_size]); 40 | memcpy(m_data.get(), data_to_copy, data_size); 41 | } 42 | } 43 | 44 | /// If \a unique_data is 'null', \a data_size must be zero. 45 | OwnedData(std::unique_ptr unique_data, size_t data_size) noexcept : 46 | m_data(std::move(unique_data)), m_size(data_size) 47 | { 48 | REALM_ASSERT_DEBUG(m_data || m_size == 0); 49 | } 50 | 51 | OwnedData(const OwnedData& other) : OwnedData(other.m_data.get(), other.m_size) { } 52 | OwnedData& operator=(const OwnedData& other); 53 | 54 | OwnedData(OwnedData&&) = default; 55 | OwnedData& operator=(OwnedData&&) = default; 56 | 57 | const char* data() const { return m_data.get(); } 58 | size_t size() const { return m_size; } 59 | 60 | private: 61 | std::unique_ptr m_data; 62 | size_t m_size = 0; 63 | }; 64 | 65 | inline OwnedData& OwnedData::operator=(const OwnedData& other) 66 | { 67 | if (this != &other) { 68 | if (other.m_data) { 69 | m_data = std::unique_ptr(new char[other.m_size]); 70 | memcpy(m_data.get(), other.m_data.get(), other.m_size); 71 | } else { 72 | m_data = nullptr; 73 | } 74 | m_size = other.m_size; 75 | } 76 | return *this; 77 | } 78 | 79 | } // namespace realm 80 | 81 | #endif // REALM_OWNED_DATA_HPP 82 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/table_basic_fwd.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_TABLE_BASIC_FWD_HPP 21 | #define REALM_TABLE_BASIC_FWD_HPP 22 | 23 | namespace realm { 24 | 25 | 26 | template 27 | class BasicTable; 28 | 29 | template 30 | struct IsBasicTable { static const bool value = false; }; 31 | template 32 | struct IsBasicTable> { static const bool value = true; }; 33 | template 34 | struct IsBasicTable> { static const bool value = true; }; 35 | 36 | 37 | } // namespace realm 38 | 39 | #endif // REALM_TABLE_BASIC_FWD_HPP 40 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/basic_system_errors.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_BASIC_SYSTEM_ERRORS_HPP 21 | #define REALM_UTIL_BASIC_SYSTEM_ERRORS_HPP 22 | 23 | #include 24 | #include 25 | 26 | 27 | namespace realm { 28 | namespace util { 29 | namespace error { 30 | 31 | enum basic_system_errors { 32 | /// Address family not supported by protocol. 33 | address_family_not_supported = EAFNOSUPPORT, 34 | 35 | /// Invalid argument. 36 | invalid_argument = EINVAL, 37 | 38 | /// Cannot allocate memory. 39 | no_memory = ENOMEM, 40 | 41 | /// Operation cancelled. 42 | operation_aborted = ECANCELED, 43 | 44 | /// Connection aborted. 45 | connection_aborted = ECONNABORTED, 46 | 47 | /// Connection reset by peer 48 | connection_reset = ECONNRESET, 49 | 50 | /// Broken pipe 51 | broken_pipe = EPIPE, 52 | 53 | /// Resource temporarily unavailable 54 | resource_unavailable_try_again = EAGAIN, 55 | }; 56 | 57 | std::error_code make_error_code(basic_system_errors) noexcept; 58 | 59 | } // namespace error 60 | } // namespace util 61 | } // namespace realm 62 | 63 | namespace std { 64 | 65 | template<> 66 | class is_error_code_enum 67 | { 68 | public: 69 | static const bool value = true; 70 | }; 71 | 72 | } // namespace std 73 | 74 | namespace realm { 75 | namespace util { 76 | 77 | std::error_code make_basic_system_error_code(int) noexcept; 78 | 79 | 80 | 81 | 82 | // implementation 83 | 84 | inline std::error_code make_basic_system_error_code(int err) noexcept 85 | { 86 | using namespace error; 87 | return make_error_code(basic_system_errors(err)); 88 | } 89 | 90 | } // namespace util 91 | } // namespace realm 92 | 93 | #endif // REALM_UTIL_BASIC_SYSTEM_ERRORS_HPP 94 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/call_with_tuple.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_CALL_WITH_TUPLE_HPP 21 | #define REALM_UTIL_CALL_WITH_TUPLE_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace realm { 27 | namespace _impl { 28 | 29 | template struct Indexes {}; 30 | template struct GenIndexes: GenIndexes {}; 31 | template struct GenIndexes<0, I...> { typedef Indexes type; }; 32 | 33 | template 34 | auto call_with_tuple(F func, std::tuple args, Indexes) 35 | -> decltype(func(std::get(args)...)) 36 | { 37 | static_cast(args); // Prevent GCC warning when tuple is empty 38 | return func(std::get(args)...); 39 | } 40 | 41 | } // namespace _impl 42 | 43 | namespace util { 44 | 45 | template 46 | auto call_with_tuple(F func, std::tuple args) 47 | -> decltype(_impl::call_with_tuple(std::move(func), std::move(args), 48 | typename _impl::GenIndexes::type())) 49 | { 50 | return _impl::call_with_tuple(std::move(func), std::move(args), 51 | typename _impl::GenIndexes::type()); 52 | } 53 | 54 | } // namespace util 55 | } // namespace realm 56 | 57 | #endif // REALM_UTIL_CALL_WITH_TUPLE_HPP 58 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/cf_ptr.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2016] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | 21 | #ifndef REALM_UTIL_CF_PTR_HPP 22 | #define REALM_UTIL_CF_PTR_HPP 23 | 24 | #include 25 | 26 | #if REALM_PLATFORM_APPLE 27 | 28 | #include 29 | 30 | namespace realm { 31 | namespace util { 32 | 33 | template 34 | class CFPtr { 35 | public: 36 | explicit CFPtr(Ref ref = nullptr) noexcept: 37 | m_ref(ref) 38 | { 39 | } 40 | 41 | CFPtr(CFPtr&& rg) noexcept: 42 | m_ref(rg.m_ref) 43 | { 44 | rg.m_ref = nullptr; 45 | } 46 | 47 | ~CFPtr() noexcept 48 | { 49 | if (m_ref) 50 | CFRelease(m_ref); 51 | } 52 | 53 | CFPtr& operator=(CFPtr&& rg) noexcept 54 | { 55 | REALM_ASSERT(!m_ref || m_ref != rg.m_ref); 56 | if (m_ref) 57 | CFRelease(m_ref); 58 | m_ref = rg.m_ref; 59 | rg.m_ref = nullptr; 60 | return *this; 61 | } 62 | 63 | explicit operator bool() const noexcept 64 | { 65 | return bool(m_ref); 66 | } 67 | 68 | Ref get() const noexcept 69 | { 70 | return m_ref; 71 | } 72 | 73 | Ref release() noexcept 74 | { 75 | Ref ref = m_ref; 76 | m_ref = nullptr; 77 | return ref; 78 | } 79 | 80 | void reset(Ref ref = nullptr) noexcept 81 | { 82 | REALM_ASSERT(!m_ref || m_ref != ref); 83 | if (m_ref) 84 | CFRelease(m_ref); 85 | m_ref = ref; 86 | } 87 | 88 | private: 89 | Ref m_ref; 90 | }; 91 | 92 | template 93 | CFPtr adoptCF(Ref ptr) { 94 | return CFPtr(ptr); 95 | } 96 | 97 | template 98 | CFPtr retainCF(Ref ptr) { 99 | CFRetain(ptr); 100 | return CFPtr(ptr); 101 | } 102 | 103 | 104 | } 105 | } 106 | 107 | 108 | #endif // REALM_PLATFORM_APPLE 109 | 110 | #endif // REALM_UTIL_CF_PTR_HPP 111 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/config.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * CAUTION: DO NOT EDIT THIS FILE -- YOUR CHANGES WILL BE LOST! 4 | * 5 | * This file is generated by config.sh 6 | * 7 | *************************************************************************/ 8 | 9 | #define REALM_VERSION "unknown" 10 | 11 | #define REALM_INSTALL_PREFIX "/Users/realm/workspace/core_osx/install" 12 | #define REALM_INSTALL_EXEC_PREFIX "/Users/realm/workspace/core_osx/install" 13 | #define REALM_INSTALL_INCLUDEDIR "/Users/realm/workspace/core_osx/install/include" 14 | #define REALM_INSTALL_BINDIR "/Users/realm/workspace/core_osx/install/bin" 15 | #define REALM_INSTALL_LIBDIR "/Users/realm/workspace/core_osx/install/lib" 16 | #define REALM_INSTALL_LIBEXECDIR "/Users/realm/workspace/core_osx/install/libexec" 17 | 18 | #ifdef REALM_DEBUG 19 | # define REALM_MAX_BPNODE_SIZE 1000 20 | #else 21 | # define REALM_MAX_BPNODE_SIZE 1000 22 | #endif 23 | 24 | #define REALM_ENABLE_ALLOC_SET_ZERO 0 25 | #define REALM_ENABLE_ENCRYPTION 1 26 | #define REALM_ENABLE_ASSERTIONS 1 27 | #define REALM_ENABLE_MEMDEBUG 0 28 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/hex_dump.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_HEX_DUMP_HPP 21 | #define REALM_UTIL_HEX_DUMP_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace realm { 33 | namespace util { 34 | 35 | template 36 | std::string hex_dump(const T* data, size_t size, const char* separator = " ", int min_digits = -1) 37 | { 38 | using U = typename std::make_unsigned::type; 39 | 40 | if (min_digits < 0) 41 | min_digits = (std::numeric_limits::digits+3) / 4; 42 | 43 | std::ostringstream out; 44 | for (const T* i = data; i != data+size; ++i) { 45 | if (i != data) 46 | out << separator; 47 | out << std::setw(min_digits)< 25 | 26 | namespace realm { 27 | namespace util { 28 | 29 | // LCOV_EXCL_START 30 | // 31 | // Because these are templated functions, every combination of output stream 32 | // type and value(s) type(s) generates a new function. This makes LCOV/GCOVR 33 | // report over 70 functions in this file, with only 6.6% function coverage, 34 | // even though line coverage is at 100%. 35 | 36 | template 37 | void inspect_value(OS& os, const T& value) 38 | { 39 | os << value; 40 | } 41 | 42 | template 43 | void inspect_value(OS& os, const std::string& value) 44 | { 45 | // FIXME: Escape the string. 46 | os << "\"" << value << "\""; 47 | } 48 | 49 | template 50 | void inspect_value(OS& os, const char* value) 51 | { 52 | // FIXME: Escape the string. 53 | os << "\"" << value << "\""; 54 | } 55 | 56 | template 57 | void inspect_all(OS&) 58 | { 59 | // No-op 60 | } 61 | 62 | /// Convert all arguments to strings, and quote string arguments. 63 | template 64 | void inspect_all(OS& os, First&& first, Args&&... args) 65 | { 66 | inspect_value(os, std::forward(first)); 67 | if (sizeof...(Args) != 0) { 68 | os << ", "; 69 | } 70 | inspect_all(os, std::forward(args)...); 71 | } 72 | 73 | // LCOV_EXCL_STOP 74 | 75 | } // namespace util 76 | } // namespace realm 77 | 78 | #endif // REALM_UTIL_INSPECT_HPP 79 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/meta.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_META_HPP 21 | #define REALM_UTIL_META_HPP 22 | 23 | namespace realm { 24 | namespace util { 25 | 26 | 27 | template 28 | struct EitherTypeIs { static const bool value = false; }; 29 | template 30 | struct EitherTypeIs { static const bool value = true; }; 31 | template 32 | struct EitherTypeIs { static const bool value = true; }; 33 | template 34 | struct EitherTypeIs { static const bool value = true; }; 35 | 36 | 37 | } // namespace util 38 | } // namespace realm 39 | 40 | #endif // REALM_UTIL_META_HPP 41 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/misc_errors.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_MISC_ERRORS_HPP 21 | #define REALM_UTIL_MISC_ERRORS_HPP 22 | 23 | #include 24 | 25 | 26 | namespace realm { 27 | namespace util { 28 | namespace error { 29 | 30 | enum misc_errors { 31 | unknown = 1 32 | }; 33 | 34 | std::error_code make_error_code(misc_errors); 35 | 36 | } // namespace error 37 | } // namespace util 38 | } // namespace realm 39 | 40 | namespace std { 41 | 42 | template<> 43 | class is_error_code_enum 44 | { 45 | public: 46 | static const bool value = true; 47 | }; 48 | 49 | } // namespace std 50 | 51 | #endif // REALM_UTIL_MISC_ERRORS_HPP 52 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/miscellaneous.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_MISCELLANEOUS_HPP 21 | #define REALM_UTIL_MISCELLANEOUS_HPP 22 | 23 | #include 24 | 25 | namespace realm { 26 | namespace util { 27 | 28 | // FIXME: Replace this with std::add_const_t when we switch over to C++14 by 29 | // default. 30 | /// \brief Adds const qualifier, unless T already has the const qualifier 31 | template 32 | using add_const_t = typename std::add_const::type; 33 | 34 | // FIXME: Replace this with std::as_const when we switch over to C++17 by 35 | // default. 36 | /// \brief Forms an lvalue reference to const T 37 | template 38 | constexpr add_const_t& as_const(T& v) noexcept 39 | { 40 | return v; 41 | } 42 | 43 | /// \brief Disallows rvalue arguments 44 | template 45 | add_const_t& as_const(const T&&) = delete; 46 | 47 | } // namespace util 48 | } // namespace realm 49 | 50 | #endif // REALM_UTIL_MISCELLANEOUS_HPP 51 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/scope_exit.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_SCOPE_EXIT_HPP 21 | #define REALM_UTIL_SCOPE_EXIT_HPP 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace realm { 29 | namespace util { 30 | 31 | template 32 | class ScopeExit { 33 | public: 34 | explicit ScopeExit(const H& handler) noexcept(std::is_nothrow_copy_constructible::value): 35 | m_handler(handler) 36 | { 37 | } 38 | 39 | explicit ScopeExit(H&& handler) noexcept(std::is_nothrow_move_constructible::value): 40 | m_handler(std::move(handler)) 41 | { 42 | } 43 | 44 | ScopeExit(ScopeExit&& se) noexcept(std::is_nothrow_move_constructible::value): 45 | m_handler(std::move(se.m_handler)) 46 | { 47 | se.m_handler = none; 48 | } 49 | 50 | ~ScopeExit() noexcept 51 | { 52 | if (m_handler) 53 | (*m_handler)(); 54 | } 55 | 56 | static_assert(noexcept(std::declval()()), "Handler must be nothrow executable"); 57 | static_assert(std::is_nothrow_destructible::value, "Handler must be nothrow destructible"); 58 | 59 | private: 60 | util::Optional m_handler; 61 | }; 62 | 63 | template 64 | ScopeExit::type> make_scope_exit(H&& handler) 65 | noexcept(noexcept(ScopeExit::type>(std::forward(handler)))) 66 | { 67 | return ScopeExit::type>(std::forward(handler)); 68 | } 69 | 70 | } // namespace util 71 | } // namespace realm 72 | 73 | #endif // REALM_UTIL_SCOPE_EXIT_HPP 74 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/shared_ptr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef REALM_SHARED_PTR_HPP 2 | #define REALM_SHARED_PTR_HPP 3 | 4 | #include // size_t 5 | 6 | namespace realm { 7 | namespace util { 8 | 9 | template 10 | class SharedPtr 11 | { 12 | public: 13 | SharedPtr(T* p) 14 | { 15 | init(p); 16 | } 17 | 18 | SharedPtr() 19 | { 20 | init(0); 21 | } 22 | 23 | ~SharedPtr() 24 | { 25 | decref(); 26 | } 27 | 28 | SharedPtr(const SharedPtr& o) : m_ptr(o.m_ptr), m_count(o.m_count) 29 | { 30 | incref(); 31 | } 32 | 33 | SharedPtr& operator=(const SharedPtr& o) { 34 | if (m_ptr == o.m_ptr) 35 | return *this; 36 | decref(); 37 | m_ptr = o.m_ptr; 38 | m_count = o.m_count; 39 | incref(); 40 | return *this; 41 | } 42 | 43 | T* operator->() const 44 | { 45 | return m_ptr; 46 | } 47 | 48 | T& operator*() const 49 | { 50 | return *m_ptr; 51 | } 52 | 53 | T* get() const 54 | { 55 | return m_ptr; 56 | } 57 | 58 | bool operator==(const SharedPtr& o) const 59 | { 60 | return m_ptr == o.m_ptr; 61 | } 62 | 63 | bool operator!=(const SharedPtr& o) const 64 | { 65 | return m_ptr != o.m_ptr; 66 | } 67 | 68 | bool operator<(const SharedPtr& o) const 69 | { 70 | return m_ptr < o.m_ptr; 71 | } 72 | 73 | size_t ref_count() const 74 | { 75 | return *m_count; 76 | } 77 | 78 | private: 79 | void init(T* p) 80 | { 81 | m_ptr = p; 82 | try { 83 | m_count = new size_t(1); 84 | } 85 | catch (...) { 86 | delete p; 87 | throw; 88 | } 89 | } 90 | 91 | void decref() 92 | { 93 | if (--(*m_count) == 0) { 94 | delete m_ptr; 95 | delete m_count; 96 | } 97 | } 98 | 99 | void incref() 100 | { 101 | ++(*m_count); 102 | } 103 | 104 | T* m_ptr; 105 | size_t* m_count; 106 | }; 107 | 108 | } 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/terminate.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_TERMINATE_HPP 21 | #define REALM_UTIL_TERMINATE_HPP 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #define REALM_TERMINATE(msg) realm::util::terminate((msg), __FILE__, __LINE__) 30 | 31 | namespace realm { 32 | namespace util { 33 | /// Install a custom termination notification callback. This will only be called as a result of 34 | /// Realm crashing internally, i.e. a failed assertion or an otherwise irrecoverable error 35 | /// condition. The termination notification callback is supplied with a zero-terminated string 36 | /// containing information relevant for debugging the issue leading to the crash. 37 | /// 38 | /// The termination notification callback is shared by all threads, which is another way of saying 39 | /// that it must be reentrant, in case multiple threads crash simultaneously. 40 | /// 41 | /// Furthermore, the provided callback must be `noexcept`, indicating that if an exception 42 | /// is thrown in the callback, the process is terminated with a call to `std::terminate`. 43 | void set_termination_notification_callback(void(*callback)(const char* message) noexcept) noexcept; 44 | 45 | REALM_NORETURN void terminate(const char* message, const char* file, long line, 46 | std::initializer_list&&={}) noexcept; 47 | REALM_NORETURN void terminate_with_info(const char* message, const char* file, long line, 48 | const char* interesting_names, 49 | std::initializer_list&&={}) noexcept; 50 | 51 | // LCOV_EXCL_START 52 | template 53 | REALM_NORETURN void terminate(const char* message, const char* file, long line, Ts... infos) noexcept 54 | { 55 | static_assert(sizeof...(infos) == 2 || sizeof...(infos) == 4 || sizeof...(infos) == 6, 56 | "Called realm::util::terminate() with wrong number of arguments"); 57 | terminate(message, file, line, {Printable(infos)...}); 58 | } 59 | 60 | template 61 | REALM_NORETURN void terminate_with_info(const char* assert_message, int line, const char* file, 62 | const char* interesting_names, 63 | Args&&... interesting_values) noexcept 64 | { 65 | terminate_with_info(assert_message, file, line, interesting_names, {Printable(interesting_values)...}); 66 | 67 | } 68 | // LCOV_EXCL_STOP 69 | 70 | } // namespace util 71 | } // namespace realm 72 | 73 | #endif // REALM_UTIL_TERMINATE_HPP 74 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/util/to_string.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2016] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_UTIL_TO_STRING_HPP 21 | #define REALM_UTIL_TO_STRING_HPP 22 | 23 | #include 24 | #include 25 | 26 | namespace realm { 27 | namespace util { 28 | 29 | class Printable { 30 | public: 31 | Printable(bool value) : m_type(Type::Bool), m_uint(value) { } 32 | Printable(unsigned char value) : m_type(Type::Uint), m_uint(value) { } 33 | Printable(unsigned int value) : m_type(Type::Uint), m_uint(value) { } 34 | Printable(unsigned long value) : m_type(Type::Uint), m_uint(value) { } 35 | Printable(unsigned long long value) : m_type(Type::Uint), m_uint(value) { } 36 | Printable(char value) : m_type(Type::Int), m_int(value) { } 37 | Printable(int value) : m_type(Type::Int), m_int(value) { } 38 | Printable(long value) : m_type(Type::Int), m_int(value) { } 39 | Printable(long long value) : m_type(Type::Int), m_int(value) { } 40 | Printable(const char* value) : m_type(Type::String), m_string(value) { } 41 | 42 | void print(std::ostream& out, bool quote) const; 43 | std::string str() const; 44 | 45 | static void print_all(std::ostream& out, const std::initializer_list& values, bool quote); 46 | 47 | private: 48 | enum class Type { 49 | Bool, 50 | Int, 51 | Uint, 52 | String 53 | } m_type; 54 | 55 | union { 56 | uintmax_t m_uint; 57 | intmax_t m_int; 58 | const char* m_string; 59 | }; 60 | }; 61 | 62 | 63 | template 64 | std::string to_string(const T& v) 65 | { 66 | return Printable(v).str(); 67 | } 68 | 69 | } // namespace util 70 | } // namespace realm 71 | 72 | #endif // REALM_UTIL_TO_STRING_HPP 73 | -------------------------------------------------------------------------------- /Pods/Realm/include/core/realm/version.hpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * 3 | * REALM CONFIDENTIAL 4 | * __________________ 5 | * 6 | * [2011] - [2015] Realm Inc 7 | * All Rights Reserved. 8 | * 9 | * NOTICE: All information contained herein is, and remains 10 | * the property of Realm Incorporated and its suppliers, 11 | * if any. The intellectual and technical concepts contained 12 | * herein are proprietary to Realm Incorporated 13 | * and its suppliers and may be covered by U.S. and Foreign Patents, 14 | * patents in process, and are protected by trade secret or copyright law. 15 | * Dissemination of this information or reproduction of this material 16 | * is strictly forbidden unless prior written permission is obtained 17 | * from Realm Incorporated. 18 | * 19 | **************************************************************************/ 20 | #ifndef REALM_VERSION_HPP 21 | #define REALM_VERSION_HPP 22 | 23 | #include 24 | 25 | #include 26 | 27 | #define REALM_VER_MAJOR 1 28 | #define REALM_VER_MINOR 3 29 | #define REALM_VER_PATCH 1 30 | #define REALM_PRODUCT_NAME "realm-core" 31 | 32 | #define REALM_VER_STRING REALM_QUOTE(REALM_VER_MAJOR) "." REALM_QUOTE(REALM_VER_MINOR) "." REALM_QUOTE(REALM_VER_PATCH) 33 | #define REALM_VER_CHUNK "[" REALM_PRODUCT_NAME "-" REALM_VER_STRING "]" 34 | 35 | namespace realm { 36 | 37 | enum Feature { 38 | feature_Debug, 39 | feature_Replication 40 | }; 41 | 42 | class Version { 43 | public: 44 | static int get_major() { return REALM_VER_MAJOR; } 45 | static int get_minor() { return REALM_VER_MINOR; } 46 | static int get_patch() { return REALM_VER_PATCH; } 47 | static std::string get_version(); 48 | static bool is_at_least(int major, int minor, int patch); 49 | static bool has_feature(Feature feature); 50 | }; 51 | 52 | 53 | } // namespace realm 54 | 55 | #endif // REALM_VERSION_HPP 56 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/apple/external_commit_helper.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #include 20 | 21 | namespace realm { 22 | class Realm; 23 | 24 | namespace _impl { 25 | class RealmCoordinator; 26 | 27 | class ExternalCommitHelper { 28 | public: 29 | ExternalCommitHelper(RealmCoordinator& parent); 30 | ~ExternalCommitHelper(); 31 | 32 | void notify_others(); 33 | 34 | private: 35 | // A RAII holder for a file descriptor which automatically closes the wrapped 36 | // fd when it's deallocated 37 | class FdHolder { 38 | public: 39 | FdHolder() = default; 40 | ~FdHolder() { close(); } 41 | operator int() const { return m_fd; } 42 | 43 | FdHolder& operator=(int newFd) { 44 | close(); 45 | m_fd = newFd; 46 | return *this; 47 | } 48 | 49 | private: 50 | int m_fd = -1; 51 | void close(); 52 | 53 | FdHolder& operator=(FdHolder const&) = delete; 54 | FdHolder(FdHolder const&) = delete; 55 | }; 56 | 57 | void listen(); 58 | 59 | RealmCoordinator& m_parent; 60 | 61 | // The listener thread 62 | std::future m_thread; 63 | 64 | // Pipe which is waited on for changes and written to when there is a new 65 | // commit to notify others of. When using a named pipe m_notify_fd is 66 | // read-write and m_notify_fd_write is unused; when using an anonymous pipe 67 | // (on tvOS) m_notify_fd is read-only and m_notify_fd_write is write-only. 68 | FdHolder m_notify_fd; 69 | FdHolder m_notify_fd_write; 70 | 71 | // File descriptor for the kqueue 72 | FdHolder m_kq; 73 | 74 | // The two ends of an anonymous pipe used to notify the kqueue() thread that 75 | // it should be shut down. 76 | FdHolder m_shutdown_read_fd; 77 | FdHolder m_shutdown_write_fd; 78 | }; 79 | } // namespace _impl 80 | } // namespace realm 81 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/apple/weak_realm_notifier.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #include "impl/weak_realm_notifier_base.hpp" 20 | 21 | #include 22 | 23 | namespace realm { 24 | class Realm; 25 | 26 | namespace _impl { 27 | 28 | class WeakRealmNotifier : public WeakRealmNotifierBase { 29 | public: 30 | WeakRealmNotifier(const std::shared_ptr& realm, bool cache); 31 | ~WeakRealmNotifier(); 32 | 33 | WeakRealmNotifier(WeakRealmNotifier&&); 34 | WeakRealmNotifier& operator=(WeakRealmNotifier&&); 35 | 36 | WeakRealmNotifier(const WeakRealmNotifier&) = delete; 37 | WeakRealmNotifier& operator=(const WeakRealmNotifier&) = delete; 38 | 39 | // Asynchronously call notify() on the Realm on the appropriate thread 40 | void notify(); 41 | 42 | private: 43 | void invalidate(); 44 | 45 | CFRunLoopRef m_runloop; 46 | CFRunLoopSourceRef m_signal; 47 | }; 48 | 49 | } // namespace _impl 50 | } // namespace realm 51 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/collection_change_builder.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_COLLECTION_CHANGE_BUILDER_HPP 20 | #define REALM_COLLECTION_CHANGE_BUILDER_HPP 21 | 22 | #include "collection_notifications.hpp" 23 | 24 | #include 25 | 26 | namespace realm { 27 | namespace _impl { 28 | class CollectionChangeBuilder : public CollectionChangeSet { 29 | public: 30 | CollectionChangeBuilder(CollectionChangeBuilder const&) = default; 31 | CollectionChangeBuilder(CollectionChangeBuilder&&) = default; 32 | CollectionChangeBuilder& operator=(CollectionChangeBuilder const&) = default; 33 | CollectionChangeBuilder& operator=(CollectionChangeBuilder&&) = default; 34 | 35 | CollectionChangeBuilder(IndexSet deletions = {}, 36 | IndexSet insertions = {}, 37 | IndexSet modification = {}, 38 | std::vector moves = {}); 39 | 40 | // Calculate where rows need to be inserted or deleted from old_rows to turn 41 | // it into new_rows, and check all matching rows for modifications 42 | static CollectionChangeBuilder calculate(std::vector const& old_rows, 43 | std::vector const& new_rows, 44 | std::function row_did_change, 45 | bool sort); 46 | 47 | void merge(CollectionChangeBuilder&&); 48 | void clean_up_stale_moves(); 49 | 50 | void insert(size_t ndx, size_t count=1, bool track_moves=true); 51 | void modify(size_t ndx); 52 | void erase(size_t ndx); 53 | void move_over(size_t ndx, size_t last_ndx, bool track_moves=true); 54 | void clear(size_t old_size); 55 | void move(size_t from, size_t to); 56 | 57 | void parse_complete(); 58 | 59 | private: 60 | std::unordered_map m_move_mapping; 61 | 62 | void verify(); 63 | }; 64 | } // namespace _impl 65 | } // namespace realm 66 | 67 | #endif // REALM_COLLECTION_CHANGE_BUILDER_HPP 68 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/external_commit_helper.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_EXTERNAL_COMMIT_HELPER_HPP 20 | #define REALM_EXTERNAL_COMMIT_HELPER_HPP 21 | 22 | #include 23 | 24 | #if REALM_PLATFORM_APPLE 25 | #include "impl/apple/external_commit_helper.hpp" 26 | #elif REALM_ANDROID 27 | #include "impl/android/external_commit_helper.hpp" 28 | #else 29 | #include "impl/generic/external_commit_helper.hpp" 30 | #endif 31 | 32 | #endif // REALM_EXTERNAL_COMMIT_HELPER_HPP 33 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/list_notifier.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_LIST_NOTIFIER_HPP 20 | #define REALM_LIST_NOTIFIER_HPP 21 | 22 | #include "impl/collection_notifier.hpp" 23 | 24 | #include 25 | 26 | namespace realm { 27 | namespace _impl { 28 | class ListNotifier : public CollectionNotifier { 29 | public: 30 | ListNotifier(LinkViewRef lv, std::shared_ptr realm); 31 | 32 | private: 33 | // The linkview, in handover form if this has not been attached to the main 34 | // SharedGroup yet 35 | LinkViewRef m_lv; 36 | std::unique_ptr> m_lv_handover; 37 | 38 | // The last-seen size of the LinkView so that we can report row deletions 39 | // when the LinkView itself is deleted 40 | size_t m_prev_size; 41 | 42 | // The column index of the LinkView 43 | size_t m_col_ndx; 44 | 45 | // The actual change, calculated in run() and delivered in prepare_handover() 46 | CollectionChangeBuilder m_change; 47 | TransactionChangeInfo* m_info; 48 | 49 | void run() override; 50 | 51 | void do_prepare_handover(SharedGroup&) override; 52 | 53 | void do_attach_to(SharedGroup& sg) override; 54 | void do_detach_from(SharedGroup& sg) override; 55 | 56 | void release_data() noexcept override; 57 | bool do_add_required_change_info(TransactionChangeInfo& info) override; 58 | }; 59 | } 60 | } 61 | 62 | #endif // REALM_LIST_NOTIFIER_HPP 63 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/results_notifier.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_RESULTS_NOTIFIER_HPP 20 | #define REALM_RESULTS_NOTIFIER_HPP 21 | 22 | #include "collection_notifier.hpp" 23 | #include "results.hpp" 24 | 25 | #include 26 | 27 | namespace realm { 28 | namespace _impl { 29 | class ResultsNotifier : public CollectionNotifier { 30 | public: 31 | ResultsNotifier(Results& target); 32 | 33 | void target_results_moved(Results& old_target, Results& new_target); 34 | 35 | private: 36 | // Target Results to update 37 | // Can only be used with lock_target() held 38 | Results* m_target_results; 39 | 40 | const SortOrder m_sort; 41 | bool m_target_is_in_table_order; 42 | 43 | // The source Query, in handover form iff m_sg is null 44 | std::unique_ptr> m_query_handover; 45 | std::unique_ptr m_query; 46 | 47 | // The TableView resulting from running the query. Will be detached unless 48 | // the query was (re)run since the last time the handover object was created 49 | TableView m_tv; 50 | std::unique_ptr> m_tv_handover; 51 | 52 | // The table version from the last time the query was run. Used to avoid 53 | // rerunning the query when there's no chance of it changing. 54 | uint_fast64_t m_last_seen_version = -1; 55 | 56 | // The rows from the previous run of the query, for calculating diffs 57 | std::vector m_previous_rows; 58 | 59 | // The changeset calculated during run() and delivered in do_prepare_handover() 60 | CollectionChangeBuilder m_changes; 61 | TransactionChangeInfo* m_info = nullptr; 62 | 63 | // Flag for whether or not the query has been run at all, as goofy timing 64 | // can lead to deliver() being called before that 65 | bool m_initial_run_complete = false; 66 | 67 | bool need_to_run(); 68 | void calculate_changes(); 69 | 70 | void run() override; 71 | void do_prepare_handover(SharedGroup&) override; 72 | bool do_deliver(SharedGroup& sg) override; 73 | bool do_add_required_change_info(TransactionChangeInfo& info) override; 74 | 75 | void release_data() noexcept override; 76 | void do_attach_to(SharedGroup& sg) override; 77 | void do_detach_from(SharedGroup& sg) override; 78 | }; 79 | 80 | } // namespace _impl 81 | } // namespace realm 82 | 83 | #endif /* REALM_RESULTS_NOTIFIER_HPP */ 84 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/transact_log_handler.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_TRANSACT_LOG_HANDLER_HPP 20 | #define REALM_TRANSACT_LOG_HANDLER_HPP 21 | 22 | #include 23 | 24 | namespace realm { 25 | class BindingContext; 26 | 27 | namespace _impl { 28 | struct TransactionChangeInfo; 29 | 30 | namespace transaction { 31 | // Advance the read transaction version, with change notifications sent to delegate 32 | // Must not be called from within a write transaction. 33 | void advance(SharedGroup& sg, BindingContext* binding_context, 34 | SharedGroup::VersionID version=SharedGroup::VersionID{}); 35 | 36 | // Begin a write transaction 37 | // If the read transaction version is not up to date, will first advance to the 38 | // most recent read transaction and sent notifications to delegate 39 | void begin(SharedGroup& sg, BindingContext* binding_context, 40 | bool validate_schema_changes=true); 41 | 42 | // Commit a write transaction 43 | void commit(SharedGroup& sg, BindingContext* binding_context); 44 | 45 | // Cancel a write transaction and roll back all changes, with change notifications 46 | // for reverting to the old values sent to delegate 47 | void cancel(SharedGroup& sg, BindingContext* binding_context); 48 | 49 | // Advance the read transaction version, with change information gathered in info 50 | void advance(SharedGroup& sg, 51 | TransactionChangeInfo& info, 52 | SharedGroup::VersionID version=SharedGroup::VersionID{}); 53 | } // namespace transaction 54 | } // namespace _impl 55 | } // namespace realm 56 | 57 | #endif /* REALM_TRANSACT_LOG_HANDLER_HPP */ 58 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/weak_realm_notifier.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_WEAK_REALM_NOTIFIER_HPP 20 | #define REALM_WEAK_REALM_NOTIFIER_HPP 21 | 22 | #include 23 | 24 | #if REALM_PLATFORM_NODE 25 | #include "impl/node/weak_realm_notifier.hpp" 26 | #elif REALM_PLATFORM_APPLE 27 | #include "impl/apple/weak_realm_notifier.hpp" 28 | #elif REALM_ANDROID 29 | #include "impl/android/weak_realm_notifier.hpp" 30 | #else 31 | #include "impl/generic/weak_realm_notifier.hpp" 32 | #endif 33 | 34 | #endif // REALM_WEAK_REALM_NOTIFIER_HPP 35 | -------------------------------------------------------------------------------- /Pods/Realm/include/impl/weak_realm_notifier_base.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_WEAK_REALM_NOTIFIER_BASE_HPP 20 | #define REALM_WEAK_REALM_NOTIFIER_BASE_HPP 21 | 22 | #include 23 | #include 24 | 25 | namespace realm { 26 | class Realm; 27 | 28 | namespace _impl { 29 | 30 | // WeakRealmNotifierBase stores a weak reference to a Realm instance, along with all of 31 | // the information about a Realm that needs to be accessed from other threads. 32 | // This is needed to avoid forming strong references to the Realm instances on 33 | // other threads, which can produce deadlocks when the last strong reference to 34 | // a Realm instance is released from within a function holding the cache lock. 35 | class WeakRealmNotifierBase { 36 | public: 37 | WeakRealmNotifierBase(const std::shared_ptr& realm, bool cache); 38 | 39 | // Get a strong reference to the cached realm 40 | std::shared_ptr realm() const { return m_realm.lock(); } 41 | 42 | // Does this WeakRealmNotifierBase store a Realm instance that should be used on the current thread? 43 | bool is_cached_for_current_thread() const { return m_cache && is_for_current_thread(); } 44 | 45 | // Has the Realm instance been destroyed? 46 | bool expired() const { return m_realm.expired(); } 47 | 48 | // Is this a WeakRealmNotifierBase for the given Realm instance? 49 | bool is_for_realm(Realm* realm) const { return realm == m_realm_key; } 50 | 51 | bool is_for_current_thread() const { return m_thread_id == std::this_thread::get_id(); } 52 | 53 | private: 54 | std::weak_ptr m_realm; 55 | std::thread::id m_thread_id = std::this_thread::get_id(); 56 | void* m_realm_key; 57 | bool m_cache = false; 58 | }; 59 | 60 | inline WeakRealmNotifierBase::WeakRealmNotifierBase(const std::shared_ptr& realm, bool cache) 61 | : m_realm(realm) 62 | , m_realm_key(realm.get()) 63 | , m_cache(cache) 64 | { 65 | } 66 | 67 | } // namespace _impl 68 | } // namespace realm 69 | 70 | #endif // REALM_WEAK_REALM_NOTIFIER_BASE_HPP 71 | -------------------------------------------------------------------------------- /Pods/Realm/include/object_schema.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_OBJECT_SCHEMA_HPP 20 | #define REALM_OBJECT_SCHEMA_HPP 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace realm { 28 | class Group; 29 | struct Property; 30 | 31 | class ObjectSchema { 32 | public: 33 | ObjectSchema(); 34 | ObjectSchema(std::string name, std::string primary_key, std::initializer_list persisted_properties); 35 | ~ObjectSchema(); 36 | 37 | // create object schema from existing table 38 | // if no table is provided it is looked up in the group 39 | ObjectSchema(const Group *group, const std::string &name); 40 | 41 | std::string name; 42 | std::vector persisted_properties; 43 | std::vector computed_properties; 44 | std::string primary_key; 45 | 46 | Property *property_for_name(StringData name); 47 | const Property *property_for_name(StringData name) const; 48 | Property *primary_key_property() { 49 | return property_for_name(primary_key); 50 | } 51 | const Property *primary_key_property() const { 52 | return property_for_name(primary_key); 53 | } 54 | 55 | private: 56 | void set_primary_key_property(); 57 | }; 58 | } 59 | 60 | #endif /* defined(REALM_OBJECT_SCHEMA_HPP) */ 61 | -------------------------------------------------------------------------------- /Pods/Realm/include/schema.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_SCHEMA_HPP 20 | #define REALM_SCHEMA_HPP 21 | 22 | #include 23 | #include 24 | 25 | namespace realm { 26 | class ObjectSchema; 27 | 28 | class Schema : private std::vector { 29 | private: 30 | using base = std::vector; 31 | public: 32 | // Create a schema from a vector of ObjectSchema 33 | Schema(base types); 34 | Schema(std::initializer_list types); 35 | 36 | // find an ObjectSchema by name 37 | iterator find(std::string const& name); 38 | const_iterator find(std::string const& name) const; 39 | 40 | // find an ObjectSchema with the same name as the passed in one 41 | iterator find(ObjectSchema const& object) noexcept; 42 | const_iterator find(ObjectSchema const& object) const noexcept; 43 | 44 | // Verify that this schema is internally consistent (i.e. all properties are 45 | // valid, links link to types that actually exist, etc.) 46 | void validate() const; 47 | 48 | using base::iterator; 49 | using base::const_iterator; 50 | using base::begin; 51 | using base::end; 52 | using base::empty; 53 | using base::size; 54 | }; 55 | } 56 | 57 | #endif /* defined(REALM_SCHEMA_HPP) */ 58 | -------------------------------------------------------------------------------- /Pods/Realm/include/util/format.hpp: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2016 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | #ifndef REALM_UTIL_FORMAT_HPP 20 | #define REALM_UTIL_FORMAT_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace realm { 28 | class StringData; 29 | 30 | namespace _impl { 31 | class Printable { 32 | public: 33 | Printable(bool value) : m_type(Type::Bool), m_uint(value) { } 34 | Printable(unsigned char value) : m_type(Type::Uint), m_uint(value) { } 35 | Printable(unsigned int value) : m_type(Type::Uint), m_uint(value) { } 36 | Printable(unsigned long value) : m_type(Type::Uint), m_uint(value) { } 37 | Printable(unsigned long long value) : m_type(Type::Uint), m_uint(value) { } 38 | Printable(char value) : m_type(Type::Int), m_int(value) { } 39 | Printable(int value) : m_type(Type::Int), m_int(value) { } 40 | Printable(long value) : m_type(Type::Int), m_int(value) { } 41 | Printable(long long value) : m_type(Type::Int), m_int(value) { } 42 | Printable(const char* value) : m_type(Type::String), m_string(value) { } 43 | Printable(std::string const& value) : m_type(Type::String), m_string(value.c_str()) { } 44 | Printable(StringData value); 45 | 46 | void print(std::ostream& out) const; 47 | 48 | private: 49 | enum class Type { 50 | Bool, 51 | Int, 52 | Uint, 53 | String 54 | } m_type; 55 | 56 | union { 57 | uintmax_t m_uint; 58 | intmax_t m_int; 59 | const char* m_string; 60 | }; 61 | }; 62 | std::string format(const char* fmt, std::initializer_list); 63 | } // namespace _impl 64 | 65 | namespace util { 66 | template 67 | std::string format(const char* fmt, Args&&... args) 68 | { 69 | return _impl::format(fmt, {_impl::Printable(args)...}); 70 | } 71 | 72 | } // namespace util 73 | } // namespace realm 74 | 75 | #endif // REALM_UTIL_FORMAT_HPP 76 | -------------------------------------------------------------------------------- /Pods/RealmSwift/RealmSwift/Aliases.swift: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2014 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | import Foundation 20 | import Realm 21 | 22 | // These types don't change when wrapping in Swift 23 | // so we just typealias them to remove the 'RLM' prefix 24 | 25 | // MARK: Aliases 26 | 27 | /** 28 | `PropertyType` is an enum describing all property types supported in Realm models. 29 | 30 | For more information, see [Realm Models](https://realm.io/docs/swift/latest/#models). 31 | 32 | ### Primitive types 33 | 34 | * `Int` 35 | * `Bool` 36 | * `Float` 37 | * `Double` 38 | 39 | ### Object types 40 | 41 | * `String` 42 | * `Data` 43 | * `Date` 44 | 45 | ### Relationships: Array (in Swift, `List`) and `Object` types 46 | 47 | * `Object` 48 | * `Array` 49 | */ 50 | public typealias PropertyType = RLMPropertyType 51 | 52 | /** 53 | An opaque token which is returned from methods which subscribe to changes to a Realm. 54 | 55 | - see: `addNotificationBlock(_:)` 56 | */ 57 | public typealias NotificationToken = RLMNotificationToken 58 | -------------------------------------------------------------------------------- /Pods/RealmSwift/RealmSwift/SwiftVersion.swift: -------------------------------------------------------------------------------- 1 | let swiftLanguageVersion = "2.2" 2 | -------------------------------------------------------------------------------- /Pods/RealmSwift/RealmSwift/Util.swift: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2015 Realm Inc. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //////////////////////////////////////////////////////////////////////////// 18 | 19 | import Foundation 20 | import Realm 21 | 22 | // MARK: Internal Helpers 23 | 24 | internal func notFoundToNil(index: UInt) -> Int? { 25 | if index == UInt(NSNotFound) { 26 | return nil 27 | } 28 | return Int(index) 29 | } 30 | 31 | #if swift(>=3.0) 32 | 33 | internal func throwRealmException(_ message: String, userInfo: [String:AnyObject] = [:]) { 34 | NSException(name: NSExceptionName(rawValue: RLMExceptionName), reason: message, userInfo: userInfo).raise() 35 | } 36 | 37 | internal func throwForNegativeIndex(_ int: Int, parameterName: String = "index") { 38 | if int < 0 { 39 | throwRealmException("Cannot pass a negative value for '\(parameterName)'.") 40 | } 41 | } 42 | 43 | internal func gsub(pattern: String, template: String, string: String, error: NSErrorPointer = nil) -> String? { 44 | let regex = try? RegularExpression(pattern: pattern, options: []) 45 | return regex?.stringByReplacingMatches(in: string, options: [], 46 | range: NSRange(location: 0, length: string.utf16.count), 47 | withTemplate: template) 48 | } 49 | 50 | #else 51 | 52 | internal func throwRealmException(message: String, userInfo: [String:AnyObject] = [:]) { 53 | NSException(name: RLMExceptionName, reason: message, userInfo: userInfo).raise() 54 | } 55 | 56 | internal func throwForNegativeIndex(int: Int, parameterName: String = "index") { 57 | if int < 0 { 58 | throwRealmException("Cannot pass a negative value for '\(parameterName)'.") 59 | } 60 | } 61 | 62 | internal func gsub(pattern: String, template: String, string: String, error: NSErrorPointer = nil) -> String? { 63 | let regex = try? NSRegularExpression(pattern: pattern, options: []) 64 | return regex?.stringByReplacingMatchesInString(string, options: [], 65 | range: NSRange(location: 0, length: string.utf16.count), 66 | withTemplate: template) 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DatabasePersistencePattern/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DatabasePersistencePattern/Pods-DatabasePersistencePattern-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_DatabasePersistencePattern : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_DatabasePersistencePattern 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DatabasePersistencePattern/Pods-DatabasePersistencePattern-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_DatabasePersistencePatternVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_DatabasePersistencePatternVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DatabasePersistencePattern/Pods-DatabasePersistencePattern.debug.xcconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm" "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Realm/Realm.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift/RealmSwift.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -ObjC -framework "Realm" -framework "RealmSwift" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DatabasePersistencePattern/Pods-DatabasePersistencePattern.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_DatabasePersistencePattern { 2 | umbrella header "Pods-DatabasePersistencePattern-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-DatabasePersistencePattern/Pods-DatabasePersistencePattern.release.xcconfig: -------------------------------------------------------------------------------- 1 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm" "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Realm/Realm.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RealmSwift/RealmSwift.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -ObjC -framework "Realm" -framework "RealmSwift" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT}/Pods 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Realm/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Realm/Realm-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Realm : NSObject 3 | @end 4 | @implementation PodsDummy_Realm 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Realm/Realm-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Realm/Realm.modulemap: -------------------------------------------------------------------------------- 1 | framework module Realm { 2 | umbrella header "Realm.h" 3 | 4 | export * 5 | module * { export * } 6 | 7 | explicit module Private { 8 | header "RLMAccessor.h" 9 | header "RLMArray_Private.h" 10 | header "RLMListBase.h" 11 | header "RLMMigration_Private.h" 12 | header "RLMObjectSchema_Private.h" 13 | header "RLMObjectStore.h" 14 | header "RLMObject_Private.h" 15 | header "RLMOptionalBase.h" 16 | header "RLMProperty_Private.h" 17 | header "RLMRealmConfiguration_Private.h" 18 | header "RLMRealm_Private.h" 19 | header "RLMResults_Private.h" 20 | header "RLMSchema_Private.h" 21 | } 22 | 23 | explicit module Dynamic { 24 | header "RLMRealm_Dynamic.h" 25 | header "RLMObjectBase_Dynamic.h" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Realm/Realm.xcconfig: -------------------------------------------------------------------------------- 1 | APPLICATION_EXTENSION_API_ONLY = YES 2 | CLANG_CXX_LANGUAGE_STANDARD = compiler-default 3 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Realm 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Realm/include/core" 6 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Realm/core" 7 | OTHER_CPLUSPLUSFLAGS = -std=c++1y $(inherited) 8 | OTHER_LDFLAGS = -l"c++" -l"realm-ios" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT} 12 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 13 | SKIP_INSTALL = YES 14 | USER_HEADER_SEARCH_PATHS = "${PODS_ROOT}/Realm/include" "${PODS_ROOT}/Realm/include/Realm" 15 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RealmSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RealmSwift/RealmSwift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RealmSwift : NSObject 3 | @end 4 | @implementation PodsDummy_RealmSwift 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RealmSwift/RealmSwift-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RealmSwift/RealmSwift-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double RealmSwiftVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char RealmSwiftVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RealmSwift/RealmSwift.modulemap: -------------------------------------------------------------------------------- 1 | framework module RealmSwift { 2 | umbrella header "RealmSwift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RealmSwift/RealmSwift.xcconfig: -------------------------------------------------------------------------------- 1 | APPLICATION_EXTENSION_API_ONLY = YES 2 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/RealmSwift 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Realm" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 7 | PODS_BUILD_DIR = $BUILD_DIR 8 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 9 | PODS_ROOT = ${SRCROOT} 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | SWIFT_WHOLE_MODULE_OPTIMIZATION = YES 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DatabasePersistencePattern 2 | [ING]RealmとCoreDataでのデータロジック比較の食べ物写真投稿サンプルアプリ(iOS Sample Study: Swift) 3 | 4 | こちらは、食べ物やおみやげの写真を登録しておみやげの写真に紐づくコメントを登録するサンプルアプリになります。 5 | また食べ物の写真とコメントの関係は「食べ物写真:コメント = 1 : n」の関係で1つの任意の食べ物の写真に対して複数件のコメントが紐付き、またコメント登録時に食べ物の写真の評価平均を算出する仕様になっています。(テーブル間のアソシエーションは未使用) 6 | 7 | ![今回のサンプルの画面一覧](https://qiita-image-store.s3.amazonaws.com/0/17400/c51fdad8-e758-f8f5-c03a-b27ef5d02dbf.png) 8 | 9 | 本サンプルの特徴としましては、RealmとCoreDataの2種類のデータ永続化を共存させて、ともに全く同じ処理を書いています。 10 | 11 | ※ ブランチ名:develop/realmにはRealmのみで作成したサンプルもご用意しました。まずはRealmでの実装方法をご覧になりたい方はこちらのブランチをダウンロードないしはcloneしてみて下さい。 12 | 13 | 詳細な解説&実装のポイントになる部分はこちらに掲載しておりますので、是非とも実機などがおありの場合はインストールをして挙動や振る舞いをご確認いただければと思います。 14 | 15 | (Qiita) http://qiita.com/fumiyasac@github/items/cbdf4d36cc14e213aaa7 16 | --------------------------------------------------------------------------------