nano-store 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.gitignore +3 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +25 -0
  6. data/README.md +193 -0
  7. data/Rakefile +1 -0
  8. data/app/app_delegate.rb +5 -0
  9. data/lib/nano-store.rb +1 -0
  10. data/lib/nano_store/bag.rb +98 -0
  11. data/lib/nano_store/model.rb +142 -0
  12. data/lib/nano_store/nano_store.rb +36 -0
  13. data/lib/nano_store/store_extension.rb +150 -0
  14. data/lib/nano_store/version.rb +3 -0
  15. data/lib/nano_store.rb +14 -0
  16. data/nano-store.gemspec +17 -0
  17. data/resources/.gitignore +0 -0
  18. data/spec/bag_spec.rb +66 -0
  19. data/spec/model_spec.rb +130 -0
  20. data/spec/nano_store_spec.rb +48 -0
  21. data/spec/store_extension_spec.rb +110 -0
  22. data/vendor/NanoStore/Classes/Advanced/NSFNanoEngine.h +542 -0
  23. data/vendor/NanoStore/Classes/Advanced/NSFNanoEngine.m +1781 -0
  24. data/vendor/NanoStore/Classes/Advanced/NSFNanoResult.h +137 -0
  25. data/vendor/NanoStore/Classes/Advanced/NSFNanoResult.m +265 -0
  26. data/vendor/NanoStore/Classes/Private/NSFNanoBag_Private.h +37 -0
  27. data/vendor/NanoStore/Classes/Private/NSFNanoEngine_Private.h +69 -0
  28. data/vendor/NanoStore/Classes/Private/NSFNanoExpression_Private.h +35 -0
  29. data/vendor/NanoStore/Classes/Private/NSFNanoGlobals_Private.h +99 -0
  30. data/vendor/NanoStore/Classes/Private/NSFNanoObject_Private.h +35 -0
  31. data/vendor/NanoStore/Classes/Private/NSFNanoPredicate_Private.h +35 -0
  32. data/vendor/NanoStore/Classes/Private/NSFNanoResult_Private.h +43 -0
  33. data/vendor/NanoStore/Classes/Private/NSFNanoSearch_Private.h +48 -0
  34. data/vendor/NanoStore/Classes/Private/NSFNanoStore_Private.h +57 -0
  35. data/vendor/NanoStore/Classes/Private/NanoStore_Private.h +37 -0
  36. data/vendor/NanoStore/Classes/Public/NSFNanoBag.h +306 -0
  37. data/vendor/NanoStore/Classes/Public/NSFNanoBag.m +485 -0
  38. data/vendor/NanoStore/Classes/Public/NSFNanoExpression.h +125 -0
  39. data/vendor/NanoStore/Classes/Public/NSFNanoExpression.m +103 -0
  40. data/vendor/NanoStore/Classes/Public/NSFNanoGlobals.h +323 -0
  41. data/vendor/NanoStore/Classes/Public/NSFNanoGlobals.m +145 -0
  42. data/vendor/NanoStore/Classes/Public/NSFNanoObject.h +298 -0
  43. data/vendor/NanoStore/Classes/Public/NSFNanoObject.m +187 -0
  44. data/vendor/NanoStore/Classes/Public/NSFNanoObjectProtocol.h +119 -0
  45. data/vendor/NanoStore/Classes/Public/NSFNanoPredicate.h +123 -0
  46. data/vendor/NanoStore/Classes/Public/NSFNanoPredicate.m +130 -0
  47. data/vendor/NanoStore/Classes/Public/NSFNanoSearch.h +381 -0
  48. data/vendor/NanoStore/Classes/Public/NSFNanoSearch.m +835 -0
  49. data/vendor/NanoStore/Classes/Public/NSFNanoSortDescriptor.h +124 -0
  50. data/vendor/NanoStore/Classes/Public/NSFNanoSortDescriptor.m +79 -0
  51. data/vendor/NanoStore/Classes/Public/NSFNanoStore.h +475 -0
  52. data/vendor/NanoStore/Classes/Public/NSFNanoStore.m +1375 -0
  53. data/vendor/NanoStore/Classes/Public/NanoStore.h +463 -0
  54. data/vendor/NanoStore/LICENSE +25 -0
  55. data/vendor/NanoStore/NanoStore.bridgesupport +1215 -0
  56. data/vendor/NanoStore/README.md +411 -0
  57. metadata +118 -0
@@ -0,0 +1,542 @@
1
+ /*
2
+ NSFNanoBag.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 NSFNanoEngine.h
28
+ @brief A wrapper around SQLite, it provides convenience methods as well as "raw" access to the database.
29
+ */
30
+
31
+ /** @class NSFNanoEngine
32
+ * A wrapper around SQLite, it provides convenience methods as well as "raw" access to the database.
33
+ */
34
+
35
+ #import "sqlite3.h"
36
+
37
+ #import "NSFNanoGlobals.h"
38
+ #import "NSFNanoGlobals.h"
39
+
40
+ @class NSFNanoResult;
41
+
42
+ @interface NSFNanoEngine : NSObject
43
+
44
+ /** * A reference to the SQLite database. */
45
+ @property (nonatomic, assign, readonly) sqlite3 *sqlite;
46
+ /** * The file path where the database is located. */
47
+ @property (nonatomic, copy, readonly) NSString *path;
48
+ /** * The cache mechanism being used. */
49
+ @property (nonatomic, assign, readwrite) NSFCacheMethod cacheMethod;
50
+
51
+ /** @name Creating and Initializing NanoEngine
52
+ */
53
+
54
+ //@{
55
+
56
+ /** Creates and returns an engine object at a given file path.
57
+ * @param thePath the file path where the document store will be created. Must not be nil.
58
+ * @return An engine object upon success, nil otherwise.
59
+ * @note To manipulate the document store, you must first open it.
60
+ * @see - (id)initWithPath:(NSString *)thePath;
61
+ * @see - (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)useFastMode;
62
+ */
63
+
64
+ + (id)databaseWithPath:(NSString *)thePath;
65
+
66
+ /** Initializes a newly allocated document store at a given file path.
67
+ * @param thePath the file path where the document store will be created. Must not be nil.
68
+ * @return An engine object upon success, nil otherwise.
69
+ * @note To manipulate the document store, you must first open it.
70
+ * @see + (id)databaseWithPath:(NSString *)thePath;
71
+ * @see - (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)useFastMode;
72
+ */
73
+
74
+ - (id)initWithPath:(NSString *)thePath;
75
+
76
+ //@}
77
+
78
+ /** @name Opening and Closing
79
+ */
80
+
81
+ //@{
82
+
83
+ /** Opens the engine, making it ready for manipulation.
84
+ * @param theCacheMethod allows to specify hwo the data will be read from the database:. This setting incurs a tradeoff between speed and memory usage.
85
+ * @param useFastMode if set to YES, the document store is opened with all performance turned on (more risky in case of failure). Setting it to NO is slower, but safer. See the note below for more information.
86
+ * @return YES upon success, NO otherwise.
87
+ * @note
88
+ * When FastMode is activated NanoStore continues without pausing as soon as it has handed data off to the operating system.
89
+ * If the application running NanoStore crashes, the data will be safe, but the database might become corrupted if the operating system crashes
90
+ * or the computer loses power before that data has been written to the disk surface.
91
+ * On the other hand, some operations are as much as 50 or more times faster with FastMode activated.
92
+ *
93
+ * @par
94
+ * If FastMode is deactivated, NanoStore will pause at critical moments to make sure that data has actually been written to the disk surface
95
+ * before continuing. This ensures that if the operating system crashes or if there is a power failure, the database will be uncorrupted after rebooting.
96
+ * Deactivating FastMode is very safe, but it is also slower.
97
+ */
98
+
99
+ - (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)useFastMode;
100
+
101
+ /** Closes the database.
102
+ * @return YES upon success, NO otherwise.
103
+ */
104
+
105
+ - (BOOL)close;
106
+
107
+ //@}
108
+
109
+ /** @name Accessors
110
+ */
111
+
112
+ //@{
113
+
114
+ /** Checks whether the document store is open or closed.
115
+ * @see - (void)close;
116
+ */
117
+
118
+ - (BOOL)isDatabaseOpen;
119
+
120
+ /** Checks whether a transaction is currently active.
121
+ * @return YES if a transaction is currently active, NO otherwise.
122
+ */
123
+
124
+ - (BOOL)isTransactionActive;
125
+
126
+ /** Sets the busy timeout.
127
+ * @param theTimeout is number of milliseconds that SQLite will wait to retry a busy operation.
128
+ * @note The acceptable range is between 100 and 5000 milliseconds. If the value is out of range, the 250 millisecond default timeout will be set instead.
129
+ * @see - (unsigned int)busyTimeout;
130
+ */
131
+
132
+ - (void)setBusyTimeout:(unsigned int)theTimeout;
133
+
134
+ /** Returns the current busy timeout.
135
+ * @see - (void)setBusyTimeout:(unsigned int)theTimeout;
136
+ */
137
+
138
+ - (unsigned int)busyTimeout;
139
+
140
+ /** Returns the recommended cache size based on the system resources available.
141
+ * @return The recommended cache size in number of pages.
142
+ */
143
+
144
+ + (NSUInteger)recommendedCacheSize;
145
+
146
+ /** Sets the cache size.
147
+ * @param numberOfPages is the number of pages.
148
+ * @return YES upon success, NO otherwise.
149
+ * @see + (NSUInteger)recommendedCacheSize;
150
+ * @see - (NSUInteger)cacheSize;
151
+ */
152
+
153
+ - (BOOL)setCacheSize:(NSUInteger)numberOfPages;
154
+
155
+ /** Returns the cache size.
156
+ * @return The current cache size.
157
+ * @see + (NSUInteger)recommendedCacheSize;
158
+ * @see - (BOOL)setCacheSize:(NSUInteger)numberOfPages;
159
+ */
160
+
161
+ - (NSUInteger)cacheSize;
162
+
163
+ /** Returns the system's page size
164
+ */
165
+
166
+ + (NSInteger)systemPageSize;
167
+
168
+ /** Sets the page size.
169
+ * @param numberOfBytes is the size of the page.
170
+ * @return YES upon success, NO otherwise.
171
+ * @see + (NSInteger)systemPageSize;
172
+ * @see - (NSUInteger)pageSize;
173
+ */
174
+
175
+ - (BOOL)setPageSize:(NSUInteger)numberOfBytes;
176
+
177
+ /** Returns the page size.
178
+ * @return The current page size.
179
+ * @see + (NSInteger)systemPageSize;
180
+ * @see - (BOOL)setPageSize:(NSUInteger)numberOfBytes;
181
+ */
182
+
183
+ - (NSUInteger)pageSize;
184
+
185
+ /** Sets the text encoding type.
186
+ * @param theEncodingType is the encoding type. Can be NSFEncodingUTF8 or NSFEncodingUTF16.
187
+ * @return YES upon success, NO otherwise.
188
+ * @see - (NSFEncodingType)encoding;
189
+ */
190
+
191
+ - (BOOL)setEncodingType:(NSFEncodingType)theEncodingType;
192
+
193
+ /** Returns the encoding type.
194
+ * @return The current encoding type.
195
+ * @see - (BOOL)setEncodingType:(NSFEncodingType)theEncodingType;
196
+ */
197
+
198
+ - (NSFEncodingType)encoding;
199
+
200
+ /** Returns the encoding type from its string equivalent.
201
+ * @return The encoding type if successful, NSFEncodingUnknown otherwise.
202
+ * @see + (NSString *)NSFEncodingTypeToNSString:(NSFEncodingType)value;
203
+ */
204
+
205
+ + (NSFEncodingType)NSStringToNSFEncodingType:(NSString *)value;
206
+
207
+ /** Returns the string equivalent of an encoding type.
208
+ * @return The string equivalent if successful, nil otherwise.
209
+ * @see + (NSFEncodingType)NSStringToNSFEncodingType:(NSString *)value;
210
+ */
211
+
212
+ + (NSString *)NSFEncodingTypeToNSString:(NSFEncodingType)value;
213
+
214
+ /** Sets the synchronous mode.
215
+ * @param theSynchronousMode is the synchronous mode. Can be SynchronousModeOff, SynchronousModeNormal or SynchronousModeFull.
216
+ * @see - (NSFSynchronousMode)synchronousMode;
217
+ */
218
+
219
+ - (void)setSynchronousMode:(NSFSynchronousMode)theSynchronousMode;
220
+
221
+ /** Returns the synchronous mode.
222
+ * @return The current synchronous mode.
223
+ * @see - (void)setSynchronousMode:(NSFSynchronousMode)theSynchronousMode;
224
+ */
225
+
226
+ - (NSFSynchronousMode)synchronousMode;
227
+
228
+ /** Sets the temporary storage mode.
229
+ * @param theTempStoreMode is the temporary storage mode. Can be TempStoreModeDefault, TempStoreModeFile or TempStoreModeMemory.
230
+ * @see - (NSFTempStoreMode)tempStoreMode;
231
+ */
232
+
233
+ - (void)setTempStoreMode:(NSFTempStoreMode)theTempStoreMode;
234
+
235
+ /** Returns the temporary storage mode.
236
+ * @return The current temporary storage mode.
237
+ * @see - (void)setTempStoreMode:(NSFTempStoreMode)theTempStoreMode;
238
+ */
239
+
240
+ - (NSFTempStoreMode)tempStoreMode;
241
+
242
+ /** * Journal mode.
243
+ * These values represent the options used by SQLite to the the journal mode for databases associated with the current database connection.
244
+
245
+ @par
246
+ The <b>DELETE</b> journaling mode is the normal behavior. In the <b>DELETE</b> mode, the rollback journal is deleted at the conclusion
247
+ of each transaction. Indeed, the delete operation is the action that causes the transaction to commit. (See the document titled
248
+ Atomic Commit In SQLite for additional detail.)
249
+
250
+ @par
251
+ The <b>TRUNCATE</b> journaling mode commits transactions by truncating the rollback journal to zero-length instead of deleting it.
252
+ On many systems, truncating a file is much faster than deleting the file since the containing directory does not need to be changed.
253
+
254
+ @par
255
+ The <b>PERSIST</b> journaling mode prevents the rollback journal from being deleted at the end of each transaction. Instead, the header
256
+ of the journal is overwritten with zeros. This will prevent other database connections from rolling the journal back. The <b>PERSIST</b>
257
+ journaling mode is useful as an optimization on platforms where deleting or truncating a file is much more expensive than overwriting
258
+ the first block of a file with zeros.
259
+
260
+ @par
261
+ The <b>MEMORY</b> journaling mode stores the rollback journal in volatile RAM. This saves disk I/O but at the expense of database safety
262
+ and integrity. If the application using SQLite crashes in the middle of a transaction when the <b>MEMORY</b> journaling mode is set, then
263
+ the database file will very likely go corrupt.
264
+
265
+ @par
266
+ The <b>WAL</b> journaling mode uses a write-ahead log instead of a rollback journal to implement transactions. The <b>WAL</b> journaling mode is
267
+ persistent; after being set it stays in effect across multiple database connections and after closing and reopening the database. A database
268
+ in <b>WAL</b> journaling mode can only be accessed by SQLite version 3.7.0 or later.
269
+
270
+ @par
271
+ The <b>OFF</b> journaling mode disables the rollback journal completely. No rollback journal is ever created and hence there is never a
272
+ rollback journal to delete. The <b>OFF</b> journaling mode disables the atomic commit and rollback capabilities of SQLite. The <b>ROLLBACK</b> command
273
+ no longer works; it behaves in an undefined way. Applications must avoid using the <b>ROLLBACK</b> command when the journal mode is <b>OFF</b>.
274
+ If the application crashes in the middle of a transaction when the <b>OFF</b> journaling mode is set, then the database file will very likely go corrupt.
275
+
276
+ @note
277
+ The journal_mode for an in-memory database is either <b>MEMORY</b> or <b>OFF</b> and can not be changed to a different value. An attempt to change
278
+ the journal_mode of an in-memory database to any setting other than <b>MEMORY</b> or <b>OFF</b> is ignored. Note also that the journal_mode cannot be changed
279
+ while a transaction is active.
280
+
281
+ @see NSFNanoEngine
282
+ */
283
+
284
+ - (NSFJournalModeMode)journalModeAndReturnError:(out NSError **)outError;
285
+
286
+ /** Returns the journal mode.
287
+ * @return The current journal mode.
288
+ * @see - (NSFJournalModeMode)journalModeAndReturnError:(out NSError **)outError;
289
+ */
290
+ - (BOOL)setJournalMode:(NSFJournalModeMode)theMode;
291
+
292
+ /** Returns a new array containing the datatypes recognized by NanoStore.
293
+ * @return A new array containing the datatypes recognized by NanoStore.
294
+ */
295
+
296
+ + (NSSet *)sharedNanoStoreEngineDatatypes;
297
+
298
+ /** Returns the NanoStore engine version.
299
+ * @return The NanoStore engine version.
300
+ */
301
+
302
+ + (NSString *)nanoStoreEngineVersion;
303
+
304
+ /** Returns the SQLite version.
305
+ * @return The SQLite version.
306
+ */
307
+
308
+ + (NSString *)sqliteVersion;
309
+
310
+ //@}
311
+
312
+ /** @name Transactions
313
+ */
314
+
315
+ //@{
316
+
317
+ /** Starts a transaction.
318
+ * @return YES upon success, NO otherwise.
319
+ * @see - (BOOL)beginTransaction;
320
+ * @see - (BOOL)beginDeferredTransaction;
321
+ * @see - (BOOL)commitTransaction;
322
+ * @see - (BOOL)rollbackTransaction;
323
+ * @see - (BOOL)isTransactionActive;
324
+ */
325
+
326
+ - (BOOL)beginTransaction;
327
+
328
+ /** Starts a deferred transaction.
329
+ * @return YES upon success, NO otherwise.
330
+ * @see - (BOOL)beginTransaction;
331
+ * @see - (BOOL)commitTransaction;
332
+ * @see - (BOOL)rollbackTransaction;
333
+ * @see - (BOOL)isTransactionActive;
334
+ */
335
+
336
+ - (BOOL)beginDeferredTransaction;
337
+
338
+ /** Commits a transaction.
339
+ * @return YES upon success, NO otherwise.
340
+ * @see - (BOOL)beginTransaction;
341
+ * @see - (BOOL)beginDeferredTransaction;
342
+ * @see - (BOOL)rollbackTransaction;
343
+ * @see - (BOOL)isTransactionActive;
344
+ */
345
+
346
+ - (BOOL)commitTransaction;
347
+
348
+ /** Rolls back a transaction.
349
+ * @return YES upon success, NO otherwise.
350
+ * @see - (BOOL)beginTransaction;
351
+ * @see - (BOOL)beginDeferredTransaction;
352
+ * @see - (BOOL)commitTransaction;
353
+ * @see - (BOOL)isTransactionActive;
354
+ */
355
+
356
+ - (BOOL)rollbackTransaction;
357
+
358
+ //@}
359
+
360
+ /** @name Everything About Tables
361
+ */
362
+
363
+ //@{
364
+
365
+ /** Creates a table.
366
+ * @param theTable the name of the table. Must not be nil.
367
+ * @param theColumns the names of the columns. Must not be nil.
368
+ * @param theDatatypes the datatypes of the columns. Must not be nil.
369
+ * @see - (BOOL)dropTable:(NSString *)theTable;
370
+ * @return YES upon success, NO otherwise.
371
+ * @note
372
+ * Allowed datatypes: NSFNanoTypeRowUID, NSFNanoTypeString, NSFNanoTypeData, NSFNanoTypeDate and NSFNanoTypeNumber.
373
+ * @throws NSFUnexpectedParameterException is thrown if any of the parameters are nil.
374
+ * @throws NSFUnexpectedParameterException is thrown if the number of columns and datatypes are not equal.
375
+ */
376
+
377
+ - (BOOL)createTable:(NSString *)theTable withColumns:(NSArray *)theColumns datatypes:(NSArray *)theDatatypes;
378
+
379
+ /** Returns a new array containing the tables found in the main document store.
380
+ * @return A new array containing the tables in the main document store, or an empty array if none is found.
381
+ * @see - (NSDictionary *)allTables;
382
+ * @see - (NSArray *)temporaryTables;
383
+ */
384
+
385
+ - (NSArray *)tables;
386
+
387
+ /** Returns a new array containing the tables found in the main and attached document stores.
388
+ * @return A new array containing the tables in the main and attached document stores, or an empty array if none is found.
389
+ * @note
390
+ * The dictionary key is the document store name and its value, an array of the tables associated with that document store.
391
+ * @see - (NSArray *)tables;
392
+ * @see - (NSArray *)temporaryTables;
393
+ */
394
+
395
+ - (NSDictionary *)allTables;
396
+
397
+ /** Returns a new array containing the columns for a given table.
398
+ * @param theTable is the name of the table.
399
+ * @return A new array containing the columns for a given table, or an empty array if none is found.
400
+ */
401
+
402
+ - (NSArray *)columnsForTable:(NSString *)theTable;
403
+
404
+ /** Returns a new array containing the temporary tables found in the main document store.
405
+ * @return A new array containing the temporary tables in the main document store, or an empty array if none is found.
406
+ * @see - (NSArray *)tables;
407
+ * @see - (NSDictionary *)allTables;
408
+ */
409
+
410
+ - (NSArray *)temporaryTables;
411
+
412
+ /** Returns a new array containing the datatypes for a given table.
413
+ * @param theTable is the name of the table.
414
+ * @return A new array containing the datatypes for a given table, or an empty array if none is found.
415
+ */
416
+
417
+ - (NSArray *)datatypesForTable:(NSString *)theTable;
418
+
419
+ /** Removes the table from the document store.
420
+ * @param theTable is the name of the table.
421
+ * @return YES upon success, NO otherwise.
422
+ * @see - (BOOL)createTable:(NSString *)theTable withColumns:(NSArray *)theColumns datatypes:(NSArray *)theDatatypes;
423
+ */
424
+
425
+ - (BOOL)dropTable:(NSString *)theTable;
426
+
427
+ //@}
428
+
429
+ /** @name Everything about Indexes
430
+ */
431
+
432
+ //@{
433
+
434
+ /** Creates an index.
435
+ * @param theColumn is the name of the column.
436
+ * @param theTable is the name of the table.
437
+ * @param isUnique whether the index should be unique or allow duplicates.
438
+ * @return YES upon success, NO otherwise.
439
+ * @see - (void)dropIndex:(NSString *)indexName;
440
+ */
441
+
442
+ - (BOOL)createIndexForColumn:(NSString *)theColumn table:(NSString *)theTable isUnique:(BOOL)isUnique;
443
+
444
+ /** Returns a new array containing the indexes found in the main document store.
445
+ * @return A new array containing the indexes in the main document store, or an empty array if none is found.
446
+ */
447
+
448
+ - (NSArray *)indexes;
449
+
450
+ /** Returns a new array containing the indexes found for a given table.
451
+ * @return A new array containing the indexes for a given table, or an empty array if none is found.
452
+ */
453
+
454
+ - (NSArray *)indexedColumnsForTable:(NSString *)theTable;
455
+
456
+ /** Removes an index.
457
+ * @param theIndex is the name of the index to be removed.
458
+ * @see - (BOOL)createIndexForColumn:(NSString *)theColumn table:(NSString *)theTable isUnique:(BOOL)isUnique;
459
+ */
460
+
461
+ - (void)dropIndex:(NSString *)theIndex;
462
+
463
+ //@}
464
+
465
+ /** @name Database Maintenance
466
+ */
467
+
468
+ //@{
469
+
470
+ /** Compacts the database, attempting to reclaim unused space.
471
+ * @return YES upon success, NO otherwise.
472
+ * @note If a transaction is open, the operation will not proceed and NO will be returned instead.
473
+ */
474
+
475
+ - (BOOL)compact;
476
+
477
+ /** Performs an integrity check on the database.
478
+ * @return YES upon success, NO otherwise.
479
+ * @note If a transaction is open, the operation will not proceed and NO will be returned instead.
480
+ */
481
+
482
+ - (BOOL)integrityCheck;
483
+
484
+ //@}
485
+
486
+ /** @name Searching and Retrieving
487
+ */
488
+
489
+ //@{
490
+
491
+ /** Executes a SQL statement.
492
+ * @param theSQLStatement is the SQL statement to be executed. Must not be nil or an empty string.
493
+ * @return Returns a NSFNanoResult.
494
+ * @throws NSFUnexpectedParameterException is thrown if the statement is nil or an empty string.
495
+ * @attention Check NSFNanoResult's error property to find out if there was a problem executing the statement.
496
+ * @note The result set will always contain string values. If you need to obtain NanoObjects instead, use the NSFNanoSearch class.
497
+ * @see NSFNanoSearch
498
+ */
499
+
500
+ - (NSFNanoResult *)executeSQL:(NSString *)theSQLStatement;
501
+
502
+ /** Returns the largest ROWUID for a given table.
503
+ * @param theTable is the table from which to obtain the largest ROWUID. Must not be nil.
504
+ * @return The largest ROWUID in use.
505
+ * @throws NSFUnexpectedParameterException is thrown if the table is nil.
506
+ */
507
+
508
+ - (long long)maxRowUIDForTable:(NSString *)theTable;
509
+
510
+ //@}
511
+
512
+ /** @name Miscellaneous
513
+ */
514
+
515
+ //@{
516
+
517
+ /** Returns a string containing the base 64 representation of a data element.
518
+ * @return A string encoded in base 64 format.
519
+ */
520
+
521
+ + (NSString *)encodeDataToBase64:(NSData *)theData;
522
+
523
+ /** Returns a data element containing from a base 64 formatted string.
524
+ * @return A data element.
525
+ */
526
+
527
+ + (NSData *)decodeDataFromBase64:(NSString *)theEncodedData;
528
+
529
+ /** Returns a UUID string
530
+ * @return A string containing a representation of a UUID.
531
+ */
532
+
533
+ + (NSString *)stringWithUUID;
534
+
535
+ /** Returns a string representation of the engine.
536
+ */
537
+
538
+ - (NSString *)description;
539
+
540
+ //@}
541
+
542
+ @end