nano-store 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.rvmrc +1 -1
  2. data/Rakefile +1 -1
  3. data/lib/nano_store.rb +1 -1
  4. data/lib/nano_store/finder.rb +26 -9
  5. data/lib/nano_store/version.rb +1 -1
  6. data/nano-store.gemspec +2 -2
  7. data/spec/finder_spec.rb +29 -12
  8. data/vendor/Podfile.lock +8 -2
  9. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoBag.h +312 -0
  10. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoBag_Private.h +37 -0
  11. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoEngine.h +542 -0
  12. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoEngine_Private.h +69 -0
  13. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoExpression.h +125 -0
  14. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoExpression_Private.h +35 -0
  15. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals.h +323 -0
  16. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals_Private.h +99 -0
  17. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoObject.h +323 -0
  18. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoObjectProtocol.h +119 -0
  19. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoObject_Private.h +35 -0
  20. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoPredicate.h +123 -0
  21. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoPredicate_Private.h +35 -0
  22. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoResult.h +137 -0
  23. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoResult_Private.h +43 -0
  24. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSearch.h +383 -0
  25. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSearch_Private.h +48 -0
  26. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSortDescriptor.h +124 -0
  27. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoStore.h +475 -0
  28. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoStore_Private.h +57 -0
  29. data/vendor/Pods/BuildHeaders/NanoStore/NanoStore.h +463 -0
  30. data/vendor/Pods/BuildHeaders/NanoStore/NanoStore_Private.h +37 -0
  31. data/vendor/Pods/Headers/NanoStore/NSFNanoObject.h +25 -0
  32. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.h +25 -0
  33. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m +53 -28
  34. data/vendor/Pods/NanoStore/README.md +5 -1
  35. data/vendor/Pods/Pods.bridgesupport +635 -621
  36. data/vendor/Pods/Pods.xcconfig +4 -1
  37. metadata +36 -8
@@ -0,0 +1,99 @@
1
+ /*
2
+ NSFNanoGlobals_Private.h
3
+ NanoStore
4
+
5
+ Copyright (c) 2010 Webbo, L.L.C. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted
8
+ provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this list of conditions
11
+ and the following disclaimer.
12
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
13
+ and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
+ * Neither the name of Webbo nor the names of its contributors may be used to endorse or promote
15
+ products derived from this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
18
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
20
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ SUCH DAMAGE.
25
+ */
26
+
27
+ #import <Foundation/Foundation.h>
28
+ #import "NSFNanoGlobals.h"
29
+
30
+ /** \cond */
31
+
32
+ /*
33
+ The following types are supported by Property Lists:
34
+
35
+ CFArray
36
+ CFDictionary
37
+ CFData
38
+ CFString
39
+ CFDate
40
+ CFNumber
41
+ CFBoolean
42
+
43
+ Since NanoStore associates an attribute with an atomic value (i.e. non-collection),
44
+ the following data types are recognized:
45
+
46
+ CFData
47
+ CFString
48
+ CFDate
49
+ CFNumber
50
+
51
+ Note: there isn't a dedicated data type homologous to CFBoolean in Cocoa. Therefore,
52
+ NSNumber will be used for that purpose.
53
+
54
+ */
55
+
56
+ extern NSString * NSFStringFromMatchType (NSFMatchType aMatchType);
57
+
58
+ extern void _NSFLog (NSString *format, ...);
59
+
60
+ extern NSString * const NSFVersionKey;
61
+ extern NSString * const NSFDomainKey;
62
+
63
+ extern NSString * const NSFKeys;
64
+ extern NSString * const NSFValues;
65
+ extern NSString * const NSFKey;
66
+ extern NSString * const NSFValue;
67
+ extern NSString * const NSFDatatype;
68
+ extern NSString * const NSFCalendarDate;
69
+ extern NSString * const NSFObjectClass;
70
+ extern NSString * const NSFPlist;
71
+ extern NSString * const NSFAttribute;
72
+
73
+ #pragma mark -
74
+
75
+ extern NSString * const NSF_Private_NSFKeys_NSFKey;
76
+ extern NSString * const NSF_Private_NSFKeys_NSFPlist;
77
+ extern NSString * const NSF_Private_NSFValues_NSFKey;
78
+ extern NSString * const NSF_Private_NSFValues_NSFAttribute;
79
+ extern NSString * const NSF_Private_NSFValues_NSFValue;
80
+ extern NSString * const NSF_Private_NSFNanoBag_Name;
81
+ extern NSString * const NSF_Private_NSFNanoBag_NSFKey;
82
+ extern NSString * const NSF_Private_NSFNanoBag_NSFObjectKeys;
83
+ extern NSString * const NSF_Private_ToDeleteTableKey;
84
+
85
+ extern NSInteger const NSF_Private_InvalidParameterDataCodeKey;
86
+ extern NSInteger const NSF_Private_MacOSXErrorCodeKey;
87
+
88
+ #pragma mark -
89
+
90
+ extern NSString * const NSFP_TableIdentifier;
91
+ extern NSString * const NSFP_ColumnIdentifier;
92
+ extern NSString * const NSFP_DatatypeIdentifier;
93
+ extern NSString * const NSFP_FullDatatypeIdentifier;
94
+
95
+ extern NSString * const NSFRowIDColumnName; // SQLite's standard UID property
96
+
97
+ extern NSString * const NSFP_SchemaTable; // Private, reserved NSF table name to store datatypes
98
+
99
+ /** \endcond */
@@ -0,0 +1,323 @@
1
+ /*
2
+ NSFNanoObject.h
3
+ NanoStore
4
+
5
+ Copyright (c) 2010 Webbo, L.L.C. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted
8
+ provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this list of conditions
11
+ and the following disclaimer.
12
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
13
+ and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
+ * Neither the name of Webbo nor the names of its contributors may be used to endorse or promote
15
+ products derived from this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
18
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
20
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ SUCH DAMAGE.
25
+ */
26
+
27
+ /*! @file NSFNanoObject.h
28
+ @brief A generic class that implements all the basic behavior required of a NanoStore object.
29
+ */
30
+
31
+ /** @class NSFNanoObject
32
+ The basic unit of data in NanoStore is called NanoObject. A NanoObject is any object which conforms to the NSFNanoObjectProtocol protocol.
33
+
34
+ @section notaflatworld_sec It's not a flat World
35
+
36
+ Most database solutions force the developer to think in a two-dimensional space (rows and columns), forcing the developer to plan the schema ahead of
37
+ time. This situation is not ideal because in most cases schema refinements could be required, oftentimes impacting the code as well.
38
+
39
+ NanoStore goes beyond that allowing the developer to store objects in their natural form. These objects must conform to the NSFNanoObjectProtocol
40
+ protocol, providing NanoStore with the NSDictionary that will be stored. By using a dictionary data can be inspected very quickly, and it also allows the
41
+ structure to be defined in a hierarchical fashion as well, due to the fact that it includes support for nested collections (of type NSDictionary and NSArray.)
42
+ Each inner-object is indexed automatically, thus allowing to quickly find objects which contain a specific key and/or value.
43
+
44
+ By default, NanoStore allows objects to be stored without any sense of relationship to other objects. This simple format, while powerful, is limited because
45
+ the developer has to keep track of the relationships among objects. Some applications may need to relate objects, some of them perhaps of different nature or class
46
+ type. This is exactly what NanoBag (represented by the NSFNanoBag class) does: it allows any object conforming to the NSFNanoObjectProtocol protocol to be
47
+ added to the bag. By saving the bag with one single call, the new and/or modified are taken care of seamlessly.
48
+
49
+ The NSFNanoBag API is rich, allowing the developer to add, remove, reload and undo its changes, deflate it (thus saving memory) and inflate it whenever it's
50
+ required. In addition, it provides methods to obtain all bags, specific bags matching some keys, and bags containing a specific object
51
+ (see NSFNanoStore for more information).
52
+
53
+ <b>Structure of a NanoObject object</b>
54
+
55
+ At its core, a NanoObject is nothing more than a wrapper around two properties:
56
+
57
+ - A dictionary which contains the metadata (provided by the developer)
58
+ - A key (UUID) that identifies the object (provided by NanoStore)
59
+
60
+ The dictionary <i>must</i> be serializable, which means that only the following data types are allowed:
61
+
62
+ - NSArray
63
+ - NSDictionary
64
+ - NSString
65
+ - NSData (*)
66
+ - NSDate
67
+ - NSNumber
68
+
69
+ (*) The data type NSData is allowed, but it will be excluded from the indexing process.
70
+
71
+ To save and retrieve objects from the document store, NanoStore moves the data around by encapsulating it in NanoObjects. In order to store the objects in
72
+ NanoStore the developer has three options:
73
+
74
+ - Use the NSFNanoObject class directly
75
+ - Expand your custom classes by inheriting from NSFNanoObject
76
+ - Expand your custom classes by implementing the NSFNanoObjectProtocol protocol
77
+
78
+ Regardless of the route you decide to take, NanoStore will be able to store and retrieve objects from the document store seamlessly. The beauty of this system is that
79
+ NanoStore returns the object as it was stored, that is, instantiating an object of the class that was originally stored.
80
+
81
+ @note
82
+ If the document store is opened by another application that doesn't implement the object that was stored, NanoStore will instantiate a
83
+ NSFNanoObject instead, thus allowing the app to retrieve the data seamlessly. If the object is then updated by this application, the original
84
+ class name will be honored.
85
+
86
+ <b>Example:</b>
87
+
88
+ - App A stores an object of class <i>Car</i>.
89
+ - App B retrieves the object, but since it doesn't know anything about the class <i>Car</i>, NanoStore returns a NSFNanoObject.
90
+ - App B updates the object, perhaps adding a timestamp or additional information. NanoStore saves it as a <i>Car</i>, not as a NSFNanoObject.
91
+ - App A retrieves the updated object as a <i>Car</i> object, in exactly the same format as it was originally stored.
92
+
93
+ @section workingwithnanoobject_sec Working with a NanoObject
94
+
95
+ There are three basic operations that NanoStore can perform with a NanoObject:
96
+
97
+ - Add it to the document store
98
+ - Update an existing object in the document store
99
+ - Remove it from the document store
100
+
101
+ To add an object, instantiate a \link NSFNanoObject::nanoObject NanoObject, \endlink populate it and add it to the document store.
102
+
103
+ @details <b>Example:</b>
104
+ @code
105
+ // Instantiate a NanoStore and open it
106
+ NSFNanoStore *nanoStore = [NSFNanoStore createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];
107
+
108
+ // Generate an empty NanoObject
109
+ NSFNanoObject *object = [NSFNanoObject nanoObject];
110
+
111
+ // Add some data
112
+ [object setObject:@"Doe" forKey:@"kLastName"];
113
+ [object setObject:@"John" forKey:@"kFirstName"];
114
+ [object setObject:[NSArray arrayWithObjects:@"jdoe@foo.com", @"jdoe@bar.com", nil] forKey:@"kEmails"];
115
+
116
+ // Add it to the document store
117
+ [nanoStore addObject:object error:nil];
118
+
119
+ // Close the document store
120
+ [nanoStore closeWithError:nil];
121
+ @endcode
122
+
123
+ Alternatively, you can instantiate a \link NSFNanoObject::nanoObject NanoObject \endlink providing a dictionary via \link NSFNanoObject::nanoObjectWithDictionary: + (NSFNanoObject*)nanoObjectWithDictionary:(NSDictionary *)theDictionary. \endlink
124
+ NanoStore will assign a UUID automatically when the \link NSFNanoObject::nanoObjectWithDictionary: NanoObject \endlink
125
+ is instantiated. This means that requesting the key from the \link NSFNanoObject::nanoObjectWithDictionary: NanoObject \endlink will return a valid UUID.
126
+ The same holds true for objects that inherit from NSFNanoObject. However, classes that implement the NSFNanoObjectProtocol protocol should
127
+ make sure they return a valid key via \link NSFNanoObjectProtocol::nanoObjectKey - (NSString *)nanoObjectKey \endlink
128
+
129
+ @warning
130
+ If an attempt is made to add or remove an object without a valid key, an exception of type \ref NSFGlobals::NSFNanoObjectBehaviorException
131
+ "NSFNanoObjectBehaviorException" will be raised.
132
+
133
+ To update an object, simply modify the object and add it to the document store. NanoStore will replace the existing object with the one being added.
134
+
135
+ @details <b>Example:</b>
136
+ @code
137
+ // Instantiate and open a NanoStore
138
+ NSFNanoStore *nanoStore = [NSFNanoStore createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];
139
+
140
+ // Assuming the dictionary exists, instantiate a NanoObject
141
+ NSDictionary *info = ...;
142
+ NSFNanoObject *object = [NSFNanoObject nanoObjectWithDictionary:info];
143
+
144
+ // Add the NanoObject to the document store
145
+ [nanoStore addObject:object error:nil];
146
+
147
+ // Update the NanoObject with new data
148
+ [object setObject:@"foo" forKey:@"SomeKey"];
149
+
150
+ // Update the NanoObject in the document store
151
+ [nanoStore addObject:object error:nil];
152
+ @endcode
153
+
154
+ To remove an object, there are several options available. The most common methods are found in NSFNanoStore:
155
+
156
+ - \link NSFNanoStore::removeObject:error: - (BOOL)removeObject:(id <NSFNanoObjectProtocol>)theObject error:(out NSError **)outError \endlink
157
+ - \link NSFNanoStore::removeObjectsWithKeysInArray:error: - (BOOL)removeObjectsWithKeysInArray:(NSArray *)theKeys error:(out NSError **)outError \endlink
158
+ - \link NSFNanoStore::removeObjectsInArray:error: - (BOOL)removeObjectsInArray:(NSArray *)theObjects error:(out NSError **)outError \endlink
159
+
160
+ @details <b>Example:</b>
161
+ @code
162
+ // Instantiate and open a NanoStore
163
+ NSFNanoStore *nanoStore = [NSFNanoStore createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];
164
+
165
+ // Assuming the dictionary exists, instantiate a NanoObject
166
+ NSDictionary *info = ...;
167
+ NSFNanoObject *object = [NSFNanoObject nanoObjectWithDictionary:info];
168
+
169
+ // Add the NanoObject to the document store
170
+ [nanoStore addObject:object error:nil];
171
+
172
+ // Remove the object
173
+ [nanoStore removeObject:object error:nil];
174
+
175
+ // ... or you could pass the key instead
176
+ [nanoStore removeObjectsWithKeysInArray:[NSArray arrayWithObjects:[object nanoObjectKey], nil] error:nil];
177
+ @endcode
178
+ */
179
+
180
+ #import "NanoStore.h"
181
+
182
+ @interface NSFNanoObject : NSObject <NSFNanoObjectProtocol, NSCopying>
183
+
184
+ /** * The UUID of the NanoObject. */
185
+ @property (nonatomic, copy, readonly) NSString *key;
186
+ /** * The user-supplied information of the NanoObject. */
187
+ @property (nonatomic, copy, readonly) NSDictionary *info;
188
+ /** * The class name used to store the NanoObject. */
189
+ @property (nonatomic, copy, readonly) NSString *originalClassString;
190
+
191
+ /** @name Creating and Initializing a NanoObject
192
+ */
193
+
194
+ //@{
195
+
196
+ /** * Creates and returns an empty NanoObject.
197
+ * @return An empty NanoObject upon success, nil otherwise.
198
+ */
199
+
200
+ + (NSFNanoObject*)nanoObject;
201
+
202
+ /** * Creates and returns a NanoObject with the given dictionary.
203
+ * @param theDictionary the information associated with the object. Must not be nil.
204
+ * @return An initialized object upon success, nil otherwise.
205
+ * @attention The dictionary must be serializable. For more information, please read the Property List Programming Guide.
206
+ * @see \link initFromDictionaryRepresentation: - (id)initFromDictionaryRepresentation:(NSDictionary *)theDictionary \endlink
207
+ */
208
+
209
+ + (NSFNanoObject*)nanoObjectWithDictionary:(NSDictionary *)theDictionary;
210
+
211
+ /** * Creates and returns a NanoObject with the given dictionary and key.
212
+ * @param theDictionary the information associated with the object. Must not be nil.
213
+ * @param theKey the object key associated with the object. If nil, a new key will be assigned.
214
+ * @return An initialized object upon success, nil otherwise.
215
+ * @attention The dictionary must be serializable. For more information, please read the Property List Programming Guide.
216
+ * @see \link initFromDictionaryRepresentation: - (id)initFromDictionaryRepresentation:(NSDictionary *)theDictionary \endlink
217
+ */
218
+
219
+ + (NSFNanoObject*)nanoObjectWithDictionary:(NSDictionary *)theDictionary key:(NSString *)theKey;
220
+
221
+ /** * Initializes a newly allocated NanoObject with the given dictionary.
222
+ * @param theDictionary the information associated with the object. Must not be nil.
223
+ * @return An initialized object upon success, nil otherwise.
224
+ * @attention The dictionary must be serializable. For more information, please read the Property List Programming Guide.
225
+ * @see \link nanoObjectWithDictionary: + (NSFNanoObject*)nanoObjectWithDictionary:(NSDictionary *)theDictionary \endlink
226
+ */
227
+
228
+ - (id)initFromDictionaryRepresentation:(NSDictionary *)theDictionary;
229
+
230
+ /** * Initializes a newly allocated NanoObject with the given dictionary and key.
231
+ * @param theDictionary the information associated with the object. Must not be nil.
232
+ * @param theKey the object key associated with the object. If nil, a new key will be assigned.
233
+ * @return An initialized object upon success, nil otherwise.
234
+ * @attention The dictionary must be serializable. For more information, please read the Property List Programming Guide.
235
+ */
236
+
237
+ - (id)initFromDictionaryRepresentation:(NSDictionary *)theDictionary key:(NSString *)theKey;
238
+
239
+ //@}
240
+
241
+ /** @name Setting and Removing Contents
242
+ */
243
+
244
+ //@{
245
+
246
+ /** * Adds the entries from a dictionary to the NanoObject.
247
+ * @param otherDictionary The dictionary from which to add entries.
248
+ */
249
+
250
+ - (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary;
251
+
252
+ /** * Adds a given key-value pair to the NanoObject.
253
+ * @param anObject the value for key. Must not be nil.
254
+ * @param aKey the key for value. Must not be nil.
255
+ * @note Raises an NSInvalidArgumentException if <i>aKey</i> or <i>anObject</i> is nil. If you need to represent a nil value in the dictionary, use NSNull.
256
+ * @see \link removeObjectForKey: - (void)removeObjectForKey:(NSString *)aKey \endlink
257
+ */
258
+
259
+ - (void)setObject:(id)anObject forKey:(NSString *)aKey;
260
+
261
+ /** * Returns the value associated with a given key.
262
+ * @param aKey the key for value. Must not be nil.
263
+ * @note Raises an NSInvalidArgumentException if <i>aKey</i> or <i>anObject</i> is nil. If you need to represent a nil value in the dictionary, use NSNull.
264
+ * @see \link setObject:forKey: - (void)setObject:(id)anObject forKey:(NSString *)aKey \endlink
265
+ */
266
+
267
+ - (id)objectForKey:(NSString *)aKey;
268
+
269
+ /** * Removes a given key and its associated value from the NanoObject.
270
+ * @param aKey the key to remove. Must not be nil.
271
+ * @note Does nothing if <i>aKey</i> does not exist.
272
+ * @see \link setObject:forKey: - (void)setObject:(id)anObject forKey:(NSString *)aKey \endlink
273
+ */
274
+
275
+ - (void)removeObjectForKey:(NSString *)aKey;
276
+
277
+ /** * Empties the NanoObject of its entries.
278
+ * @see \link removeObjectForKey: - (void)removeObjectForKey:(NSString *)aKey \endlink
279
+ * @see \link removeObjectsForKeys: - (void)removeObjectsForKeys:(NSArray *)keyArray \endlink
280
+ */
281
+
282
+ - (void)removeAllObjects;
283
+
284
+ /** * Removes from the NanoObject entries specified by elements in a given array.
285
+ * @param keyArray An array of objects specifying the keys to remove.
286
+ * @note If a key in <i>keyArray</i> does not exist, the entry is ignored.
287
+ * @see \link removeAllObjects - (void)removeAllObjects \endlink
288
+ * @see \link removeObjectForKey: - (void)removeObjectForKey:(NSString *)aKey \endlink
289
+ */
290
+
291
+ - (void)removeObjectsForKeys:(NSArray *)keyArray;
292
+
293
+ //@}
294
+
295
+ /** @name Miscellaneous
296
+ */
297
+
298
+ //@{
299
+
300
+ /** * Compares the receiving NanoObject to another NanoObject.
301
+ * @param otherNanoObject is a NanoObject.
302
+ * @return YES if the contents of otherNanoObject are equal to the contents of the receiving NanoObject, otherwise NO.
303
+ */
304
+
305
+ - (BOOL)isEqualToNanoObject:(NSFNanoObject *)otherNanoObject;
306
+
307
+ /** * Returns a dictionary that contains the information stored in the object.
308
+ * @note Check properties info and key to find out the current state of the object.
309
+ * @see \link description - (NSString *)description \endlink
310
+ */
311
+
312
+ - (NSDictionary *)dictionaryRepresentation;
313
+
314
+ /** * Returns a string representation of the bag.
315
+ * @note Check properties info and key to find out the current state of the object.
316
+ * @see \link dictionaryRepresentation - (NSString *)dictionaryRepresentation \endlink
317
+ */
318
+
319
+ - (NSString *)description;
320
+
321
+ //@}
322
+
323
+ @end
@@ -0,0 +1,119 @@
1
+ /*
2
+ NSFNanoObjectProtocol.h
3
+ NanoStore
4
+
5
+ Copyright (c) 2010 Webbo, L.L.C. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted
8
+ provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this list of conditions
11
+ and the following disclaimer.
12
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
13
+ and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
+ * Neither the name of Webbo nor the names of its contributors may be used to endorse or promote
15
+ products derived from this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
18
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
20
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ SUCH DAMAGE.
25
+ */
26
+
27
+ /*! @file NSFNanoObjectProtocol.h
28
+ @brief A protocol declaring the interface that objects interfacing with NanoStore must implement.
29
+ */
30
+
31
+ /** @protocol NSFNanoObjectProtocol
32
+ * A protocol declaring the interface that objects interfacing with NanoStore must implement.
33
+ *
34
+ * @note
35
+ * Check NSFNanoBag or NSFNanoObject to see a concrete example of how NSFNanoObjectProtocol is implemented.
36
+ */
37
+
38
+ @class NSFNanoStore;
39
+
40
+ @protocol NSFNanoObjectProtocol
41
+
42
+ @required
43
+
44
+ /** * Initializes a newly allocated object containing a given key and value associated with a document store.
45
+ * @param theDictionary the information associated with the object.
46
+ * @param aKey the key associated with the information.
47
+ * @param theStore the document store where the object is stored.
48
+ * @return An initialized object upon success, nil otherwise.
49
+ * @details <b>Example:</b>
50
+ @code
51
+ - (id)initNanoObjectFromDictionaryRepresentation:(NSDictionary *)aDictionary forKey:(NSString *)aKey store:(NSFNanoStore *)aStore
52
+ {
53
+ if (self = [self init]) {
54
+ info = [aDictionary retain];
55
+ key = [aKey copy];
56
+ }
57
+
58
+ return self;
59
+ }
60
+ @endcode
61
+ */
62
+
63
+ - (id)initNanoObjectFromDictionaryRepresentation:(NSDictionary *)theDictionary forKey:(NSString *)aKey store:(NSFNanoStore *)theStore;
64
+
65
+ /** * Returns a dictionary that contains the information stored in the object.
66
+ * @see \link nanoObjectKey - (NSString *)nanoObjectKey \endlink
67
+ */
68
+
69
+ - (NSDictionary *)nanoObjectDictionaryRepresentation;
70
+
71
+ /** * Returns the key associated with the object.
72
+ * @note
73
+ * The class NSFNanoEngine contains a convenience method for this purpose: \ref NSFNanoEngine::stringWithUUID "+(NSString*)stringWithUUID"
74
+ *
75
+ * @see \link nanoObjectDictionaryRepresentation - (NSDictionary *)nanoObjectDictionaryRepresentation \endlink
76
+ */
77
+
78
+ - (NSString *)nanoObjectKey;
79
+
80
+ /** * Returns a reference to the object holding the private data or information that will be used for sorting.
81
+ * Most custom objects will return <i>self</i>, as is the case for NSFNanoBag. Since we can sort a bag by <i>name</i>, <i>key</i> or <i>hasUnsavedChanges</i>,
82
+ * NanoStore requires a hint to find the attribute. This hint is the root object, which KVC uses to perform the sort. Taking NSFNanoBag as an example:
83
+ @code
84
+ @interface NSFNanoBag : NSObject <NSFNanoObjectProtocol, NSCopying>
85
+ {
86
+ NSFNanoStore *store;
87
+ NSString *name;
88
+ NSString *key;
89
+ BOOL hasUnsavedChanges;
90
+ }
91
+ @endcode
92
+ * The implementation of <i>rootObject</i> would look like so:
93
+ @code
94
+ - (id)rootObject
95
+ {
96
+ return self;
97
+ }
98
+ @endcode
99
+ * Other objects may point directly to the collection that holds the information. NSFNanoObject stores all its data in the <i>info</i> dictionary, so the
100
+ * implementation looks like this:
101
+ @code
102
+ - (id)rootObject
103
+ {
104
+ return info;
105
+ }
106
+ @endcode
107
+ * Assuming that <i>info</i> contains a key named <i>City</i>, we would specify a NSFNanoSortDescriptor which would sort the cities like so:
108
+ @code
109
+ NSFNanoSortDescriptor *sortedCities = [[NSFNanoSortDescriptor alloc]initWithAttribute:@"City" ascending:YES];
110
+ @endcode
111
+ * If we had returned <i>self</i> as the root object, the sort descriptor would have to be written like so:
112
+ @code
113
+ NSFNanoSortDescriptor *sortedCities = [[NSFNanoSortDescriptor alloc]initWithAttribute:@"info.City" ascending:YES];
114
+ @endcode
115
+ */
116
+
117
+ - (id)rootObject;
118
+
119
+ @end