Mercurial > projects > dstep
view dstep/coredata/NSPersistentStoreCoordinator.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Sep 25, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.coredata.NSPersistentStoreCoordinator; import dstep.coredata.CoreDataDefines; import dstep.coredata.NSManagedObjectID; import dstep.coredata.NSManagedObjectModel; import dstep.coredata.NSPersistentStore; import dstep.foundation.NSArray; import dstep.foundation.NSDictionary; import dstep.foundation.NSError; import dstep.foundation.NSLock; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSURL; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.coredata.NSPersistentStoreCoordinator_bindings; private { NSString NSSQLiteStoreType_; NSString NSXMLStoreType_; NSString NSBinaryStoreType_; NSString NSInMemoryStoreType_; NSString NSStoreTypeKey_; NSString NSStoreUUIDKey_; NSString NSPersistentStoreCoordinatorStoresDidChangeNotification_; NSString NSAddedPersistentStoresKey_; NSString NSRemovedPersistentStoresKey_; NSString NSUUIDChangedPersistentStoresKey_; NSString NSReadOnlyPersistentStoreOption_; NSString NSValidateXMLStoreOption_; NSString NSPersistentStoreTimeoutOption_; NSString NSSQLitePragmasOption_; NSString NSIgnorePersistentStoreVersioningOption_; NSString NSMigratePersistentStoresAutomaticallyOption_; NSString NSStoreModelVersionHashesKey_; NSString NSStoreModelVersionIdentifiersKey_; NSString NSPersistentStoreOSCompatibility_; } NSString NSSQLiteStoreType () { if (NSSQLiteStoreType_) return NSSQLiteStoreType_; return NSSQLiteStoreType_ = new NSString(bindings.NSSQLiteStoreType); } NSString NSXMLStoreType () { if (NSXMLStoreType_) return NSXMLStoreType_; return NSXMLStoreType_ = new NSString(bindings.NSXMLStoreType); } NSString NSBinaryStoreType () { if (NSBinaryStoreType_) return NSBinaryStoreType_; return NSBinaryStoreType_ = new NSString(bindings.NSBinaryStoreType); } NSString NSInMemoryStoreType () { if (NSInMemoryStoreType_) return NSInMemoryStoreType_; return NSInMemoryStoreType_ = new NSString(bindings.NSInMemoryStoreType); } NSString NSStoreTypeKey () { if (NSStoreTypeKey_) return NSStoreTypeKey_; return NSStoreTypeKey_ = new NSString(bindings.NSStoreTypeKey); } NSString NSStoreUUIDKey () { if (NSStoreUUIDKey_) return NSStoreUUIDKey_; return NSStoreUUIDKey_ = new NSString(bindings.NSStoreUUIDKey); } NSString NSPersistentStoreCoordinatorStoresDidChangeNotification () { if (NSPersistentStoreCoordinatorStoresDidChangeNotification_) return NSPersistentStoreCoordinatorStoresDidChangeNotification_; return NSPersistentStoreCoordinatorStoresDidChangeNotification_ = new NSString(bindings.NSPersistentStoreCoordinatorStoresDidChangeNotification); } NSString NSAddedPersistentStoresKey () { if (NSAddedPersistentStoresKey_) return NSAddedPersistentStoresKey_; return NSAddedPersistentStoresKey_ = new NSString(bindings.NSAddedPersistentStoresKey); } NSString NSRemovedPersistentStoresKey () { if (NSRemovedPersistentStoresKey_) return NSRemovedPersistentStoresKey_; return NSRemovedPersistentStoresKey_ = new NSString(bindings.NSRemovedPersistentStoresKey); } NSString NSUUIDChangedPersistentStoresKey () { if (NSUUIDChangedPersistentStoresKey_) return NSUUIDChangedPersistentStoresKey_; return NSUUIDChangedPersistentStoresKey_ = new NSString(bindings.NSUUIDChangedPersistentStoresKey); } NSString NSReadOnlyPersistentStoreOption () { if (NSReadOnlyPersistentStoreOption_) return NSReadOnlyPersistentStoreOption_; return NSReadOnlyPersistentStoreOption_ = new NSString(bindings.NSReadOnlyPersistentStoreOption); } NSString NSValidateXMLStoreOption () { if (NSValidateXMLStoreOption_) return NSValidateXMLStoreOption_; return NSValidateXMLStoreOption_ = new NSString(bindings.NSValidateXMLStoreOption); } NSString NSPersistentStoreTimeoutOption () { if (NSPersistentStoreTimeoutOption_) return NSPersistentStoreTimeoutOption_; return NSPersistentStoreTimeoutOption_ = new NSString(bindings.NSPersistentStoreTimeoutOption); } NSString NSSQLitePragmasOption () { if (NSSQLitePragmasOption_) return NSSQLitePragmasOption_; return NSSQLitePragmasOption_ = new NSString(bindings.NSSQLitePragmasOption); } NSString NSIgnorePersistentStoreVersioningOption () { if (NSIgnorePersistentStoreVersioningOption_) return NSIgnorePersistentStoreVersioningOption_; return NSIgnorePersistentStoreVersioningOption_ = new NSString(bindings.NSIgnorePersistentStoreVersioningOption); } NSString NSMigratePersistentStoresAutomaticallyOption () { if (NSMigratePersistentStoresAutomaticallyOption_) return NSMigratePersistentStoresAutomaticallyOption_; return NSMigratePersistentStoresAutomaticallyOption_ = new NSString(bindings.NSMigratePersistentStoresAutomaticallyOption); } NSString NSStoreModelVersionHashesKey () { if (NSStoreModelVersionHashesKey_) return NSStoreModelVersionHashesKey_; return NSStoreModelVersionHashesKey_ = new NSString(bindings.NSStoreModelVersionHashesKey); } NSString NSStoreModelVersionIdentifiersKey () { if (NSStoreModelVersionIdentifiersKey_) return NSStoreModelVersionIdentifiersKey_; return NSStoreModelVersionIdentifiersKey_ = new NSString(bindings.NSStoreModelVersionIdentifiersKey); } NSString NSPersistentStoreOSCompatibility () { if (NSPersistentStoreOSCompatibility_) return NSPersistentStoreOSCompatibility_; return NSPersistentStoreOSCompatibility_ = new NSString(bindings.NSPersistentStoreOSCompatibility); } class NSPersistentStoreCoordinator : NSObject, INSLocking { mixin (ObjcWrap); static NSDictionary registeredStoreTypes () { return invokeObjcSelfClass!(NSDictionary, "registeredStoreTypes"); } static void registerStoreClass (Class storeClass, NSString storeType) { return invokeObjcSelfClass!(void, "registerStoreClass:forStoreType:", Class, NSString)(storeClass, storeType); } static NSDictionary metadataForPersistentStoreOfType (NSString storeType, NSURL url, ref NSError error) { id __arg2; if (error) __arg2 = error.objcObject; NSDictionary result = invokeObjcSelfClass!(NSDictionary, "metadataForPersistentStoreOfType:URL:error:", NSString, NSURL, id*)(storeType, url, &__arg2); if (__arg2) error = new NSError(__arg2); return result; } static bool setMetadata (NSDictionary metadata, NSString storeType, NSURL url, ref NSError error) { id __arg3; if (error) __arg3 = error.objcObject; bool result = invokeObjcSelfClass!(bool, "setMetadata:forPersistentStoreOfType:URL:error:", NSDictionary, NSString, NSURL, id*)(metadata, storeType, url, &__arg3); if (__arg3) error = new NSError(__arg3); return result; } void setMetadata (NSDictionary metadata, NSPersistentStore store) { return invokeObjcSelf!(void, "setMetadata:forPersistentStore:", NSDictionary, NSPersistentStore)(metadata, store); } NSDictionary metadataForPersistentStore (NSPersistentStore store) { return invokeObjcSelf!(NSDictionary, "metadataForPersistentStore:", NSPersistentStore)(store); } NSPersistentStoreCoordinator initWithManagedObjectModel (NSManagedObjectModel model) { id result = invokeObjcSelf!(id, "initWithManagedObjectModel:", NSManagedObjectModel)(model); return result is this.objcObject ? this : (result !is null ? new NSPersistentStoreCoordinator(result) : null); } this (NSManagedObjectModel model) { super(NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel(model).objcObject); } NSManagedObjectModel managedObjectModel () { return invokeObjcSelf!(NSManagedObjectModel, "managedObjectModel"); } NSArray persistentStores () { return invokeObjcSelf!(NSArray, "persistentStores"); } NSPersistentStore persistentStoreForURL (NSURL URL) { return invokeObjcSelf!(NSPersistentStore, "persistentStoreForURL:", NSURL)(URL); } NSURL URLForPersistentStore (NSPersistentStore store) { return invokeObjcSelf!(NSURL, "URLForPersistentStore:", NSPersistentStore)(store); } bool setURL (NSURL url, NSPersistentStore store) { return invokeObjcSelf!(bool, "setURL:forPersistentStore:", NSURL, NSPersistentStore)(url, store); } NSPersistentStore addPersistentStoreWithType (NSString storeType, NSString configuration, NSURL storeURL, NSDictionary options, ref NSError error) { id __arg4; if (error) __arg4 = error.objcObject; NSPersistentStore result = invokeObjcSelf!(NSPersistentStore, "addPersistentStoreWithType:configuration:URL:options:error:", NSString, NSString, NSURL, NSDictionary, id*)(storeType, configuration, storeURL, options, &__arg4); if (__arg4) error = new NSError(__arg4); return result; } bool removePersistentStore (NSPersistentStore store, ref NSError error) { id __arg1; if (error) __arg1 = error.objcObject; bool result = invokeObjcSelf!(bool, "removePersistentStore:error:", NSPersistentStore, id*)(store, &__arg1); if (__arg1) error = new NSError(__arg1); return result; } NSPersistentStore migratePersistentStore (NSPersistentStore store, NSURL URL, NSDictionary options, NSString storeType, ref NSError error) { id __arg4; if (error) __arg4 = error.objcObject; NSPersistentStore result = invokeObjcSelf!(NSPersistentStore, "migratePersistentStore:toURL:options:withType:error:", NSPersistentStore, NSURL, NSDictionary, NSString, id*)(store, URL, options, storeType, &__arg4); if (__arg4) error = new NSError(__arg4); return result; } NSManagedObjectID managedObjectIDForURIRepresentation (NSURL url) { return invokeObjcSelf!(NSManagedObjectID, "managedObjectIDForURIRepresentation:", NSURL)(url); } void lock () { return invokeObjcSelf!(void, "lock"); } void unlock () { return invokeObjcSelf!(void, "unlock"); } bool tryLock () { return invokeObjcSelf!(bool, "tryLock"); } static NSDictionary metadataForPersistentStoreWithURL (NSURL url, ref NSError error) { id __arg1; if (error) __arg1 = error.objcObject; NSDictionary result = invokeObjcSelfClass!(NSDictionary, "metadataForPersistentStoreWithURL:error:", NSURL, id*)(url, &__arg1); if (__arg1) error = new NSError(__arg1); return result; } }