Couchbase Lite
Objective-C API for iOS and Mac OS
CBLManager.h
Go to the documentation of this file.
1 //
2 // CBLManager.h
3 // CouchbaseLite
4 //
5 // Created by Jens Alfke on 6/19/12.
6 // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved.
7 //
8 
9 #import "CBLBase.h"
10 @class CBLDatabase;
11 
14 typedef struct CBLManagerOptions {
15  bool readOnly;
16  NSDataWritingOptions fileProtection;
18 
19 
20 
21 
23 @interface CBLDatabaseOptions : NSObject
24 @property (nonatomic) BOOL create;
25 @property (nonatomic) BOOL readOnly;
33 @property (nonatomic, copy, nullable) NSString* storageType;
34 
46 @property (nonatomic, strong, nullable) id encryptionKey;
47 @end
48 
49 
50 
51 
56 @interface CBLManager : NSObject <NSCopying>
57 
59 + (instancetype) sharedInstance;
60 
63 + (BOOL) isValidDatabaseName: (NSString*)name;
64 
66 + (NSString*) defaultDirectory;
67 
69 - (instancetype) init;
70 
75 - (nullable instancetype) initWithDirectory: (NSString*)directory
76  options: (const CBLManagerOptions* __nullable)options
77  error: (NSError**)outError;
78 
80 - (instancetype) copy;
81 
83 - (void) close;
84 
87 @property (copy, nonatomic) NSString* storageType;
88 
90 @property (readonly) NSString* directory;
91 
94 @property BOOL excludedFromBackup;
95 
96 #pragma mark - DATABASES:
97 
103 - (nullable CBLDatabase*) databaseNamed: (NSString*)name
104  error: (NSError**)outError;
105 
110 - (nullable CBLDatabase*) existingDatabaseNamed: (NSString*)name
111  error: (NSError**)outError;
112 
121 - (nullable CBLDatabase*) openDatabaseNamed: (NSString*)name
122  withOptions: (nullable CBLDatabaseOptions*)options
123  error: (NSError**)outError;
124 
126 - (BOOL) databaseExistsNamed: (NSString*)name;
127 
129 - (nullable CBLDatabase*) objectForKeyedSubscript: (NSString*)key;
130 
132 @property (readonly) CBLArrayOf(NSString*)* allDatabaseNames;
133 
134 
135 #ifdef CBL_DEPRECATED
136 
147 - (BOOL) replaceDatabaseNamed: (NSString*)databaseName
148  withDatabaseFile: (NSString*)databasePath
149  withAttachments: (nullable NSString*)attachmentsPath
150  error: (NSError**)outError;
151 #endif
152 
162 - (BOOL) replaceDatabaseNamed: (NSString*)databaseName
163  withDatabaseDir: (NSString*)databaseDir
164  error: (NSError**)outError;
165 
166 #pragma mark - CONCURRENCY:
167 
173 @property (strong, nullable) dispatch_queue_t dispatchQueue;
174 
178 - (void) doAsync: (void (^)())block;
179 
185 - (void) backgroundTellDatabaseNamed: (NSString*)dbName to: (void (^)(CBLDatabase*))block;
186 
187 #pragma mark - OTHER API:
188 
193 @property (readonly) NSURL* internalURL;
194 
200 + (void) enableLogging: (nullable NSString*)type;
201 
204 + (void) redirectLogging: (nullable void (^)(NSString* type, NSString* message))callback;
205 
206 
207 @property (readonly, nonatomic, nullable) NSMutableDictionary* customHTTPHeaders;
208 
209 
211 - (BOOL) registerEncryptionKey: (nullable id)keyOrPassword
212  forDatabaseNamed: (NSString*)name;
213 
214 @end
215 
216 
218 extern NSString* CBLVersion( void );
219 
222 extern NSString* const CBLHTTPErrorDomain;
223 
225 extern NSString* const kCBLSQLiteStorage;
226 
228 extern NSString* const kCBLForestDBStorage;
229 
instancetype copy()
Creates a copy of this CBLManager, which can be used on a different thread.
Options for opening a database.
Definition: CBLManager.h:23
#define NS_ASSUME_NONNULL_BEGIN
Definition: CBLBase.h:20
id encryptionKey
A key to encrypt the database with.
Definition: CBLManager.h:46
NSString *const kCBLSQLiteStorage
SQLite storage type used for setting CBLDatabaseOptions.storageType.
A CouchbaseLite database.
Definition: CBLDatabase.h:38
dispatch_queue_t dispatchQueue
The dispatch queue used to serialize access to the database manager (and its child objects...
Definition: CBLManager.h:173
#define __nullable
Definition: CBLBase.h:23
NSDataWritingOptions fileProtection
File protection/encryption options (iOS only)
Definition: CBLManager.h:16
BOOL readOnly
Open database read-only?
Definition: CBLManager.h:25
BOOL excludedFromBackup
Should the databases and attachments be excluded from iCloud or Time Machine backup? Defaults to NO.
Definition: CBLManager.h:94
#define nullable
Definition: CBLBase.h:22
BOOL create
Create database if it doesn&#39;t exist?
Definition: CBLManager.h:24
NSString * storageType
The underlying storage engine to use.
Definition: CBLManager.h:33
instancetype init()
Default initializer.
NSURL * internalURL
The base URL of the database manager&#39;s REST API.
Definition: CBLManager.h:193
#define NS_ASSUME_NONNULL_END
Definition: CBLBase.h:21
NSString * defaultDirectory()
The default directory to use for a CBLManager.
void close()
Releases all resources used by the CBLManager instance and closes all its databases.
Top-level Couchbase Lite object; manages a collection of databases.
Definition: CBLManager.h:56
bool readOnly
No modifications to databases are allowed.
Definition: CBLManager.h:15
Option flags for CBLManager initialization.
Definition: CBLManager.h:14
NSString *const CBLHTTPErrorDomain
NSError domain used for HTTP status codes returned by a lot of Couchbase Lite APIs – for example cod...
CBLArrayOf(NSNumber *) *CBLGeoPointToCoordPair(CBLGeoPoint pt)
Converts a point to a JSON-compatible array of two coordinates.
NSString * directory
The root directory of this manager (as specified at initialization time.)
Definition: CBLManager.h:90
NS_ASSUME_NONNULL_BEGIN struct CBLManagerOptions CBLManagerOptions
Option flags for CBLManager initialization.
NSMutableDictionary * customHTTPHeaders
Definition: CBLManager.h:207
NSString * CBLVersion(void)
Returns the version of Couchbase Lite.
instancetype sharedInstance()
A shared per-process instance.
NSString *const kCBLForestDBStorage
ForestDB storage type used for setting CBLDatabaseOptions.storageType.