nano-store 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.gitmodules +0 -3
- data/Gemfile +1 -1
- data/Gemfile.lock +24 -0
- data/README.md +5 -0
- data/Rakefile +21 -1
- data/lib/nano_store.rb +2 -0
- data/lib/nano_store/finder.rb +76 -0
- data/lib/nano_store/model.rb +1 -32
- data/lib/nano_store/version.rb +1 -1
- data/nano-store.gemspec +1 -0
- data/spec/finder_spec.rb +67 -0
- data/spec/model_spec.rb +0 -30
- data/vendor/Podfile.lock +5 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoBag.h +306 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoBag_Private.h +37 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoEngine.h +542 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoEngine_Private.h +69 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoExpression.h +125 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoExpression_Private.h +35 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals.h +323 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals_Private.h +99 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoObject.h +298 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoObjectProtocol.h +119 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoObject_Private.h +35 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoPredicate.h +123 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoPredicate_Private.h +35 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoResult.h +137 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoResult_Private.h +43 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoSearch.h +381 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoSearch_Private.h +48 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoSortDescriptor.h +124 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoStore.h +475 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoStore_Private.h +57 -0
- data/vendor/Pods/Headers/NanoStore/NanoStore.h +463 -0
- data/vendor/Pods/Headers/NanoStore/NanoStore_Private.h +37 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.h +542 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.m +1781 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.h +137 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.m +265 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoBag_Private.h +37 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoEngine_Private.h +69 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoExpression_Private.h +35 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoGlobals_Private.h +99 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoObject_Private.h +35 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoPredicate_Private.h +35 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoResult_Private.h +43 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoSearch_Private.h +48 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoStore_Private.h +57 -0
- data/vendor/Pods/NanoStore/Classes/Private/NanoStore_Private.h +37 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.h +306 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.m +485 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.h +125 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.m +103 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.h +323 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.m +145 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.h +298 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m +187 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObjectProtocol.h +119 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.h +123 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.m +130 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.h +381 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.m +859 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.h +124 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.m +79 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.h +475 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.m +1375 -0
- data/vendor/Pods/NanoStore/Classes/Public/NanoStore.h +463 -0
- data/vendor/Pods/NanoStore/LICENSE +25 -0
- data/vendor/Pods/NanoStore/README.md +411 -0
- data/vendor/Pods/Pods-prefix.pch +3 -0
- data/vendor/Pods/Pods-resources.sh +15 -0
- data/vendor/Pods/Pods.bridgesupport +1215 -0
- data/vendor/Pods/Pods.xcconfig +4 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +974 -0
- metadata +89 -6
@@ -0,0 +1,137 @@
|
|
1
|
+
/*
|
2
|
+
NSFNanoResult.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 NSFNanoResult.h
|
28
|
+
@brief A unit that describes the result of a search.
|
29
|
+
*/
|
30
|
+
|
31
|
+
/** @class NSFNanoResult
|
32
|
+
* A unit that describes the result of a search.
|
33
|
+
*
|
34
|
+
* @note
|
35
|
+
* The NanoResult is the object representation of a SQL result set. From it, you can obtain the number of rows, the column names and their
|
36
|
+
* associated values.
|
37
|
+
*
|
38
|
+
* @par
|
39
|
+
* After obtaining a NanoResult, it's always a good idea to check whether the <i>error</i> property is nil. If so, the result can be assumed to be
|
40
|
+
* correct. Otherwise, <i>error</i> will point to the main cause of failure.
|
41
|
+
*
|
42
|
+
* @details <b>Example:</b>
|
43
|
+
@code
|
44
|
+
// Instantiate a NanoStore and open it
|
45
|
+
NSFNanoStore *nanoStore = [NSFNanoStore createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];
|
46
|
+
|
47
|
+
// Add some data to the document store
|
48
|
+
NSDictionary *info = ...;
|
49
|
+
NSFNanoBag *bag = [NSFNanoBag bag];
|
50
|
+
NSFNanoObject *obj1 = [NSFNanoObject nanoObjectWithDictionary:info];
|
51
|
+
NSFNanoObject *obj2 = [NSFNanoObject nanoObjectWithDictionary:info];
|
52
|
+
[nanoStore addObjectsFromArray:[NSArray arrayWithObjects:obj1, obj2, nil] error:nil];
|
53
|
+
|
54
|
+
// Instantiate a search and execute the SQL statement
|
55
|
+
NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];
|
56
|
+
NSFNanoResult *result = [search executeSQL:@"SELECT COUNT(*) FROM NSFKEYS"];
|
57
|
+
|
58
|
+
// Obtain the result (given as an NSString)
|
59
|
+
NSString *value = [result firstValue];
|
60
|
+
|
61
|
+
// Close the document store
|
62
|
+
[nanoStore closeWithError:nil];
|
63
|
+
@endcode
|
64
|
+
*/
|
65
|
+
|
66
|
+
#import <Foundation/Foundation.h>
|
67
|
+
|
68
|
+
@class NSFNanoStore;
|
69
|
+
|
70
|
+
@interface NSFNanoResult : NSObject
|
71
|
+
|
72
|
+
/** * Number of rows contained in the result set. */
|
73
|
+
@property (nonatomic, assign, readonly) NSUInteger numberOfRows;
|
74
|
+
/** * A reference to the error encountered while processing the request, otherwise nil if the request was successful. */
|
75
|
+
@property (nonatomic, strong, readonly) NSError *error;
|
76
|
+
|
77
|
+
/** @name Accessors
|
78
|
+
*/
|
79
|
+
|
80
|
+
//@{
|
81
|
+
|
82
|
+
/** * Returns a new array containing the columns.
|
83
|
+
* @returns An array with the columns retrieved from the result set.
|
84
|
+
*/
|
85
|
+
|
86
|
+
- (NSArray *)columns;
|
87
|
+
|
88
|
+
/** * Returns a new array containing the values for a given column.
|
89
|
+
* @param theIndex is the index of the value in the result set.
|
90
|
+
* @param theColumn is the name of the column in the result set.
|
91
|
+
* @returns An array with the values associated with a given column.
|
92
|
+
* @throws NSRangeException is thrown if the index is out of bounds.
|
93
|
+
*/
|
94
|
+
|
95
|
+
- (NSString *)valueAtIndex:(NSUInteger)theIndex forColumn:(NSString *)theColumn;
|
96
|
+
|
97
|
+
/** * Returns a new array containing the values for a given column.
|
98
|
+
* @param theColumn is the name of the column in the result set.
|
99
|
+
* @returns An array with the values associated with a given column.
|
100
|
+
*/
|
101
|
+
|
102
|
+
- (NSArray *)valuesForColumn:(NSString *)theColumn;
|
103
|
+
|
104
|
+
/** * Returns the first value.
|
105
|
+
* @returns The value of the first element from the result set.
|
106
|
+
*/
|
107
|
+
|
108
|
+
- (NSString *)firstValue;
|
109
|
+
|
110
|
+
//@}
|
111
|
+
|
112
|
+
/** @name Exporting the Results to a File
|
113
|
+
*/
|
114
|
+
|
115
|
+
//@{
|
116
|
+
|
117
|
+
/** * Saves the result to a file.
|
118
|
+
* @param thePath is the location where the result will be saved to a file.
|
119
|
+
*/
|
120
|
+
|
121
|
+
- (void)writeToFile:(NSString *)thePath;
|
122
|
+
|
123
|
+
//@}
|
124
|
+
|
125
|
+
/** @name Miscellaneous
|
126
|
+
*/
|
127
|
+
|
128
|
+
//@{
|
129
|
+
|
130
|
+
/** * Returns a string representation of the result.
|
131
|
+
*/
|
132
|
+
|
133
|
+
- (NSString *)description;
|
134
|
+
|
135
|
+
//@}
|
136
|
+
|
137
|
+
@end
|
@@ -0,0 +1,265 @@
|
|
1
|
+
/*
|
2
|
+
NSFNanoResult.m
|
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 "NSFNanoResult.h"
|
28
|
+
#import "NanoStore_Private.h"
|
29
|
+
|
30
|
+
@implementation NSFNanoResult
|
31
|
+
{
|
32
|
+
@protected
|
33
|
+
/** \cond */
|
34
|
+
NSDictionary *results;
|
35
|
+
/** \endcond */
|
36
|
+
}
|
37
|
+
|
38
|
+
@synthesize numberOfRows;
|
39
|
+
@synthesize error;
|
40
|
+
|
41
|
+
/** \cond */
|
42
|
+
|
43
|
+
- (id)init
|
44
|
+
{
|
45
|
+
if ((self = [super init])) {
|
46
|
+
[self _reset];
|
47
|
+
}
|
48
|
+
|
49
|
+
return self;
|
50
|
+
}
|
51
|
+
|
52
|
+
- (void)dealloc
|
53
|
+
{
|
54
|
+
[self _reset];
|
55
|
+
}
|
56
|
+
/** \endcond */
|
57
|
+
|
58
|
+
- (NSString *)description
|
59
|
+
{
|
60
|
+
NSUInteger numberOfColumns = [[results allKeys]count];
|
61
|
+
|
62
|
+
NSMutableString *description = [NSMutableString string];
|
63
|
+
[description appendString:@"\n"];
|
64
|
+
[description appendString:[NSString stringWithFormat:@"Result address : 0x%x\n", self]];
|
65
|
+
[description appendString:[NSString stringWithFormat:@"Number of columns : %ld\n", numberOfColumns]];
|
66
|
+
if (nil == error)
|
67
|
+
if ([[self columns]count] > 0)
|
68
|
+
[description appendString:[NSString stringWithFormat:@"Columns : %@\n", [[self columns]componentsJoinedByString:@", "]]];
|
69
|
+
else
|
70
|
+
[description appendString:[NSString stringWithFormat:@"Columns : %@\n", @"()"]];
|
71
|
+
else
|
72
|
+
[description appendString:[NSString stringWithFormat:@"Columns : %@\n", @"<column info not available>"]];
|
73
|
+
[description appendString:[NSString stringWithFormat:@"Number of rows : %ld\n", numberOfRows]];
|
74
|
+
if (nil == error)
|
75
|
+
[description appendString:[NSString stringWithFormat:@"Error : %@\n", @"<no error>"]];
|
76
|
+
else
|
77
|
+
[description appendString:[NSString stringWithFormat:@"Error : %@\n", [error localizedDescription]]];
|
78
|
+
|
79
|
+
// Print up to the first ten rows to help visualize the cursor
|
80
|
+
if (0 != numberOfColumns) {
|
81
|
+
[description appendString:@"Preview of contents:\n "];
|
82
|
+
NSUInteger i;
|
83
|
+
NSArray *columns = [self columns];
|
84
|
+
|
85
|
+
// Print the names of the columns
|
86
|
+
[description appendString:[NSString stringWithFormat:@"%-15@ | ", @"Row # "]];
|
87
|
+
for (i = 0; i < numberOfColumns; i++) {
|
88
|
+
const char *value = [[columns objectAtIndex:i]UTF8String];
|
89
|
+
if (numberOfColumns - 1 > i) {
|
90
|
+
[description appendString:[NSString stringWithFormat:@"%-15s | ", value]];
|
91
|
+
} else {
|
92
|
+
[description appendString:[NSString stringWithFormat:@"%-15s\n ", value]];
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
// Print the underline
|
97
|
+
const char *value = "===============";
|
98
|
+
[description appendString:[NSString stringWithFormat:@"%-15s | ", value]];
|
99
|
+
for (i = 0; i < numberOfColumns; i++) {
|
100
|
+
if (numberOfColumns - 1 > i) {
|
101
|
+
[description appendString:[NSString stringWithFormat:@"%-15s | ", value]];
|
102
|
+
} else {
|
103
|
+
[description appendString:[NSString stringWithFormat:@"%-15s\n ", value]];
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
// Print the preview of the contents
|
108
|
+
if (numberOfRows > 0) {
|
109
|
+
NSInteger numberOfRowsToPrint = numberOfRows;
|
110
|
+
NSUInteger j;
|
111
|
+
|
112
|
+
if (numberOfRows > 100) {
|
113
|
+
numberOfRowsToPrint = 100;
|
114
|
+
}
|
115
|
+
|
116
|
+
for (i = 0; i < numberOfRowsToPrint; i++) {
|
117
|
+
[description appendString:[NSString stringWithFormat:@"%-15ld | ", i]];
|
118
|
+
for (j = 0; j < numberOfColumns; j++) {
|
119
|
+
NSString *columnName = [columns objectAtIndex:j];
|
120
|
+
const char *value = "<plist data> ";
|
121
|
+
if (NO == [columnName hasSuffix:@"NSFPlist"]) {
|
122
|
+
value = [[self valueAtIndex:i forColumn:columnName]UTF8String];
|
123
|
+
}
|
124
|
+
|
125
|
+
if (numberOfColumns - 1 > j) {
|
126
|
+
[description appendString:[NSString stringWithFormat:@"%-15s | ", value]];
|
127
|
+
} else {
|
128
|
+
[description appendString:[NSString stringWithFormat:@"%-15s", value]];
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
[description appendString:@"\n "];
|
133
|
+
}
|
134
|
+
} else {
|
135
|
+
[description appendString:@"<no data available>"];
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
return description;
|
140
|
+
}
|
141
|
+
|
142
|
+
#pragma mark -
|
143
|
+
|
144
|
+
- (NSArray *)columns
|
145
|
+
{
|
146
|
+
return [results allKeys];
|
147
|
+
}
|
148
|
+
|
149
|
+
- (NSString *)valueAtIndex:(NSUInteger)index forColumn:(NSString *)column
|
150
|
+
{
|
151
|
+
return [[results objectForKey:column]objectAtIndex:index];
|
152
|
+
}
|
153
|
+
|
154
|
+
- (NSArray *)valuesForColumn:(NSString *)column
|
155
|
+
{
|
156
|
+
NSArray *values = [results objectForKey:column];
|
157
|
+
|
158
|
+
if (nil == values)
|
159
|
+
values = [NSArray array];
|
160
|
+
|
161
|
+
return values;
|
162
|
+
}
|
163
|
+
|
164
|
+
- (NSString *)firstValue
|
165
|
+
{
|
166
|
+
NSArray *columns = [results allKeys];
|
167
|
+
if (([columns count] > 0) && (numberOfRows > 0)) {
|
168
|
+
return [[results objectForKey:[columns objectAtIndex:0]]objectAtIndex:0];
|
169
|
+
}
|
170
|
+
|
171
|
+
return nil;
|
172
|
+
}
|
173
|
+
|
174
|
+
- (NSError *)error
|
175
|
+
{
|
176
|
+
return [error copy];
|
177
|
+
}
|
178
|
+
|
179
|
+
- (void)writeToFile:(NSString *)path;
|
180
|
+
{
|
181
|
+
[results writeToFile:[path stringByExpandingTildeInPath] atomically:YES];
|
182
|
+
}
|
183
|
+
|
184
|
+
#pragma mark - Private Methods
|
185
|
+
#pragma mark -
|
186
|
+
|
187
|
+
/** \cond */
|
188
|
+
+ (NSFNanoResult *)_resultWithDictionary:(NSDictionary *)theResults
|
189
|
+
{
|
190
|
+
return [[self alloc]_initWithDictionary:theResults];
|
191
|
+
}
|
192
|
+
|
193
|
+
+ (NSFNanoResult *)_resultWithError:(NSError *)theError
|
194
|
+
{
|
195
|
+
return [[self alloc]_initWithError:theError];
|
196
|
+
}
|
197
|
+
|
198
|
+
- (id)_initWithDictionary:(NSDictionary *)theResults
|
199
|
+
{
|
200
|
+
if (nil == theResults)
|
201
|
+
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
202
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %s]: theResults is nil.", [self class], _cmd]
|
203
|
+
userInfo:nil]raise];
|
204
|
+
|
205
|
+
if ([theResults respondsToSelector:@selector(objectForKey:)] == NO)
|
206
|
+
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
207
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %s]: theResults is not of type NSDictionary.", [self class], _cmd]
|
208
|
+
userInfo:nil]raise];
|
209
|
+
|
210
|
+
if ((self = [self init])) {
|
211
|
+
results = theResults;
|
212
|
+
[self _calculateNumberOfRows];
|
213
|
+
}
|
214
|
+
|
215
|
+
return self;
|
216
|
+
}
|
217
|
+
|
218
|
+
- (id)_initWithError:(NSError *)theError
|
219
|
+
{
|
220
|
+
if (nil == theError)
|
221
|
+
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
222
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %s]: theError is nil.", [self class], _cmd]
|
223
|
+
userInfo:nil]raise];
|
224
|
+
|
225
|
+
if ([theError respondsToSelector:@selector(localizedDescription)] == NO)
|
226
|
+
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
227
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %s]: theError is not of type NSError.", [self class], _cmd]
|
228
|
+
userInfo:nil]raise];
|
229
|
+
|
230
|
+
if ((self = [self init])) {
|
231
|
+
error = theError;
|
232
|
+
[self _calculateNumberOfRows];
|
233
|
+
}
|
234
|
+
|
235
|
+
return self;
|
236
|
+
}
|
237
|
+
|
238
|
+
- (void)_setError:(NSError *)theError
|
239
|
+
{
|
240
|
+
if (error != theError) {
|
241
|
+
error = theError;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
- (void)_reset
|
246
|
+
{
|
247
|
+
numberOfRows = -1;
|
248
|
+
results = nil;
|
249
|
+
error = nil;
|
250
|
+
}
|
251
|
+
|
252
|
+
- (void)_calculateNumberOfRows
|
253
|
+
{
|
254
|
+
// We cache the value once, for performance reasons
|
255
|
+
if (-1 == numberOfRows) {
|
256
|
+
NSArray *allKeys = [results allKeys];
|
257
|
+
if ([allKeys count] == 0)
|
258
|
+
numberOfRows = 0;
|
259
|
+
else
|
260
|
+
numberOfRows = [[results objectForKey:[allKeys lastObject]]count];
|
261
|
+
}
|
262
|
+
}
|
263
|
+
/** \endcond */
|
264
|
+
|
265
|
+
@end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/*
|
2
|
+
NSFNanoBag_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 "NSFNanoBag.h"
|
28
|
+
|
29
|
+
/** \cond */
|
30
|
+
|
31
|
+
@interface NSFNanoBag (Private)
|
32
|
+
- (void)_setStore:(NSFNanoStore *)aStore;
|
33
|
+
- (BOOL)_saveInStore:(NSFNanoStore *)someStore error:(out NSError **)outError;
|
34
|
+
- (void)_inflateObjectsWithKeys:(NSArray *)someKeys;
|
35
|
+
@end
|
36
|
+
|
37
|
+
/** \endcond */
|
@@ -0,0 +1,69 @@
|
|
1
|
+
/*
|
2
|
+
* NSFNanoEngine_Private.h
|
3
|
+
* A lightweight Cocoa wrapper for SQLite
|
4
|
+
*
|
5
|
+
* Written by Tito Ciuro (21-Jan-2003)
|
6
|
+
|
7
|
+
Copyright (c) 2004, Tito Ciuro
|
8
|
+
All rights reserved.
|
9
|
+
|
10
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted
|
11
|
+
provided that the following conditions are met:
|
12
|
+
|
13
|
+
• Redistributions of source code must retain the above copyright notice, this list of conditions
|
14
|
+
and the following disclaimer.
|
15
|
+
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
16
|
+
and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
17
|
+
• Neither the name of Tito Ciuro nor the names of its contributors may be used to endorse or promote
|
18
|
+
products derived from this software without specific prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
21
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
22
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
26
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27
|
+
SUCH DAMAGE.
|
28
|
+
*/
|
29
|
+
|
30
|
+
#import "NSFNanoEngine.h"
|
31
|
+
#import "NSFNanoGlobals_Private.h"
|
32
|
+
#import "NSFNanoResult.h"
|
33
|
+
|
34
|
+
/** \cond */
|
35
|
+
|
36
|
+
@interface NSFNanoEngine (Private)
|
37
|
+
+ (NSArray *)NSFP_sharedROWIDKeywords;
|
38
|
+
- (NSString *)NSFP_cacheMethodToString;
|
39
|
+
- (NSString*)NSFP_nestedDescriptionWithPrefixedSpace:(NSString *)prefixedSpace;
|
40
|
+
+ (NSDictionary *)_plistToDictionary:(NSString *)aPlist;
|
41
|
+
- (NSFNanoDatatype)NSFP_datatypeForTable:(NSString *)table column:(NSString *)column;
|
42
|
+
+ (void)NSFP_decodeQuantum:(unsigned char *)dest andSource:(const char *)src;
|
43
|
+
- (void)NSFP_setFullColumnNamesEnabled;
|
44
|
+
- (NSArray *)NSFP_flattenAllTables;
|
45
|
+
- (NSInteger)NSFP_prepareSQLite3Statement:(sqlite3_stmt **)aStatement theSQLStatement:(NSString *)aSQLQuery;
|
46
|
+
- (NSFNanoDatatype)NSFP_datatypeForColumn:(NSString *)tableAndColumn;
|
47
|
+
+ (int)NSFP_stripBitsFromExtendedResultCode:(int)extendedResult;
|
48
|
+
|
49
|
+
- (BOOL)NSFP_beginTransactionMode:(NSString *)theSQLStatement;
|
50
|
+
- (BOOL)NSFP_createTable:(NSString *)table withColumns:(NSArray *)tableColumns datatypes:(NSArray *)tableDatatypes isTemporary:(BOOL)isTemporaryFlag;
|
51
|
+
- (BOOL)NSFP_removeColumn:(NSString *)column fromTable:(NSString *)table;
|
52
|
+
- (void)NSFP_rebuildDatatypeCache;
|
53
|
+
- (BOOL)NSFP_insertStringValues:(NSArray *)values forColumns:(NSArray *)columns table:(NSString *)table;
|
54
|
+
|
55
|
+
- (void)NSFP_sqlString:(NSMutableString*)theSQLStatement appendingTags:(NSArray *)tags quoteTags:(BOOL)flag;
|
56
|
+
- (void)NSFP_sqlString:(NSMutableString*)theSQLStatement appendingTags:(NSArray *)columns;
|
57
|
+
- (BOOL)NSFP_sqlString:(NSMutableString*)theSQLStatement forTable:(NSString *)table withColumns:(NSArray *)columns datatypes:(NSArray *)datatypes;
|
58
|
+
|
59
|
+
- (NSInteger)NSFP_ROWIDPresenceLocation:(NSArray *)tableColumns datatypes:(NSArray *)datatypes;
|
60
|
+
- (BOOL)NSFP_isColumnROWIDAlias:(NSString *)column forTable:(NSString *)table;
|
61
|
+
|
62
|
+
- (NSString *)NSFP_prefixWithDotDelimiter:(NSString *)tableAndColumn;
|
63
|
+
- (NSString *)NSFP_suffixWithDotDelimiter:(NSString *)tableAndColumn;
|
64
|
+
|
65
|
+
- (void)NSFP_installCommitCallback;
|
66
|
+
- (void)NSFP_uninstallCommitCallback;
|
67
|
+
@end
|
68
|
+
|
69
|
+
/** \endcond */
|