added iOS source code
[wl-app.git] / iOS / Pods / Realm / include / RLMConstants.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 <Foundation/Foundation.h>
20
21 NS_ASSUME_NONNULL_BEGIN
22
23 // For compatibility with Xcode 7, before extensible string enums were introduced,
24 #ifdef NS_EXTENSIBLE_STRING_ENUM
25 #define RLM_EXTENSIBLE_STRING_ENUM NS_EXTENSIBLE_STRING_ENUM
26 #define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(_, extensible_string_enum) NS_SWIFT_NAME(extensible_string_enum)
27 #else
28 #define RLM_EXTENSIBLE_STRING_ENUM
29 #define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(fully_qualified, _) NS_SWIFT_NAME(fully_qualified)
30 #endif
31
32 #if __has_attribute(ns_error_domain) && (!defined(__cplusplus) || !__cplusplus || __cplusplus >= 201103L)
33 #define RLM_ERROR_ENUM(type, name, domain) \
34     _Pragma("clang diagnostic push") \
35     _Pragma("clang diagnostic ignored \"-Wignored-attributes\"") \
36     NS_ENUM(type, __attribute__((ns_error_domain(domain))) name) \
37     _Pragma("clang diagnostic pop")
38 #else
39 #define RLM_ERROR_ENUM(type, name, domain) NS_ENUM(type, name)
40 #endif
41
42
43 #pragma mark - Enums
44
45 /**
46  `RLMPropertyType` is an enumeration describing all property types supported in Realm models.
47
48  For more information, see [Realm Models](https://realm.io/docs/objc/latest/#models).
49  */
50 typedef NS_ENUM(int32_t, RLMPropertyType) {
51
52 #pragma mark - Primitive types
53
54     /** Integers: `NSInteger`, `int`, `long`, `Int` (Swift) */
55     RLMPropertyTypeInt    = 0,
56     /** Booleans: `BOOL`, `bool`, `Bool` (Swift) */
57     RLMPropertyTypeBool   = 1,
58     /** Floating-point numbers: `float`, `Float` (Swift) */
59     RLMPropertyTypeFloat  = 5,
60     /** Double-precision floating-point numbers: `double`, `Double` (Swift) */
61     RLMPropertyTypeDouble = 6,
62
63 #pragma mark - Object types
64
65     /** Strings: `NSString`, `String` (Swift) */
66     RLMPropertyTypeString = 2,
67     /** Binary data: `NSData` */
68     RLMPropertyTypeData   = 3,
69     /**
70      Any object: `id`.
71
72      This property type is no longer supported for new models. However, old files
73      with any-typed properties are still supported for migration purposes.
74      */
75     RLMPropertyTypeAny    = 9,
76     /** Dates: `NSDate` */
77     RLMPropertyTypeDate   = 4,
78
79 #pragma mark - Linked object types
80
81     /** Realm model objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */
82     RLMPropertyTypeObject = 7,
83     /** Realm linking objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */
84     RLMPropertyTypeLinkingObjects = 8,
85 };
86
87 /** An error domain identifying Realm-specific errors. */
88 extern NSString * const RLMErrorDomain;
89
90 /** An error domain identifying non-specific system errors. */
91 extern NSString * const RLMUnknownSystemErrorDomain;
92
93 /**
94  `RLMError` is an enumeration representing all recoverable errors. It is associated with the
95  Realm error domain specified in `RLMErrorDomain`.
96  */
97 typedef RLM_ERROR_ENUM(NSInteger, RLMError, RLMErrorDomain) {
98     /** Denotes a general error that occurred when trying to open a Realm. */
99     RLMErrorFail                  = 1,
100
101     /** Denotes a file I/O error that occurred when trying to open a Realm. */
102     RLMErrorFileAccess            = 2,
103
104     /**
105      Denotes a file permission error that ocurred when trying to open a Realm.
106
107      This error can occur if the user does not have permission to open or create
108      the specified file in the specified access mode when opening a Realm.
109      */
110     RLMErrorFilePermissionDenied  = 3,
111
112     /** Denotes an error where a file was to be written to disk, but another file with the same name already exists. */
113     RLMErrorFileExists            = 4,
114
115     /**
116      Denotes an error that occurs if a file could not be found.
117
118      This error may occur if a Realm file could not be found on disk when trying to open a
119      Realm as read-only, or if the directory part of the specified path was not found when
120      trying to write a copy.
121      */
122     RLMErrorFileNotFound          = 5,
123
124     /**
125      Denotes an error that occurs if a file format upgrade is required to open the file,
126      but upgrades were explicitly disabled.
127      */
128     RLMErrorFileFormatUpgradeRequired = 6,
129
130     /**
131      Denotes an error that occurs if the database file is currently open in another
132      process which cannot share with the current process due to an
133      architecture mismatch.
134
135      This error may occur if trying to share a Realm file between an i386 (32-bit) iOS
136      Simulator and the Realm Browser application. In this case, please use the 64-bit
137      version of the iOS Simulator.
138      */
139     RLMErrorIncompatibleLockFile  = 8,
140
141     /** Denotes an error that occurs when there is insufficient available address space. */
142     RLMErrorAddressSpaceExhausted = 9,
143
144     /** Denotes an error that occurs if there is a schema version mismatch, so that a migration is required. */
145     RLMErrorSchemaMismatch = 10,
146
147     /** Denotes an error that occurs when attempting to open an incompatible synchronized Realm file.
148
149      This error occurs when the Realm file was created with an older version of Realm and an automatic migration
150      to the current version is not possible. When such an error occurs, the original file is moved to a backup
151      location, and future attempts to open the synchronized Realm will result in a new file being created.
152      If you wish to migrate any data from the backup Realm, you can open it using the provided Realm configuration.
153      */
154     RLMErrorIncompatibleSyncedFile = 11,
155 };
156
157 #pragma mark - Constants
158
159 #pragma mark - Notification Constants
160
161 /**
162  A notification indicating that changes were made to a Realm.
163 */
164 typedef NSString * RLMNotification RLM_EXTENSIBLE_STRING_ENUM;
165
166 /**
167  This notification is posted by a Realm when the data in that Realm has changed.
168
169  More specifically, this notification is posted after a Realm has been refreshed to
170  reflect a write transaction. This can happen when an autorefresh occurs, when
171  `-[RLMRealm refresh]` is called, after an implicit refresh from `-[RLMRealm beginWriteTransaction]`,
172  or after a local write transaction is completed.
173  */
174 extern RLMNotification const RLMRealmRefreshRequiredNotification
175 RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmRefreshRequiredNotification, RefreshRequired);
176
177 /**
178  This notification is posted by a Realm when a write transaction has been
179  committed to a Realm on a different thread for the same file.
180
181  It is not posted if `-[RLMRealm autorefresh]` is enabled, or if the Realm is
182  refreshed before the notification has a chance to run.
183
184  Realms with autorefresh disabled should normally install a handler for this
185  notification which calls `-[RLMRealm refresh]` after doing some work. Refreshing
186  the Realm is optional, but not refreshing the Realm may lead to large Realm
187  files. This is because Realm must keep an extra copy of the data for the stale
188  Realm.
189  */
190 extern RLMNotification const RLMRealmDidChangeNotification
191 RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmDidChangeNotification, DidChange);
192
193 #pragma mark - Error keys
194
195 /** Key to identify the associated backup Realm configuration in an error's `userInfo` dictionary */
196 extern NSString * const RLMBackupRealmConfigurationErrorKey;
197
198 #pragma mark - Other Constants
199
200 /** The schema version used for uninitialized Realms */
201 extern const uint64_t RLMNotVersioned;
202
203 /** The corresponding value is the name of an exception thrown by Realm. */
204 extern NSString * const RLMExceptionName;
205
206 /** The corresponding value is a Realm file version. */
207 extern NSString * const RLMRealmVersionKey;
208
209 /** The corresponding key is the version of the underlying database engine. */
210 extern NSString * const RLMRealmCoreVersionKey;
211
212 /** The corresponding key is the Realm invalidated property name. */
213 extern NSString * const RLMInvalidatedKey;
214
215 NS_ASSUME_NONNULL_END