-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create CBLQueryResultArray to serve allObjects value
* Changed CBLQueryResultsArray to CBLQueryRowsArray. This is currently used by the PredicateQuery. * Implemented the same for the regular Query and named it CBLQueryResultArray. The reason to implement a new one instead of trying to use the same one is to clearly separate PredicateQuery and Query for now.
- Loading branch information
Showing
7 changed files
with
109 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// CBLQueryResultArray.h | ||
// CouchbaseLite | ||
// | ||
// Created by Pasin Suriyentrakorn on 8/7/17. | ||
// Copyright © 2017 Couchbase. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
@class CBLQueryResultSet; | ||
|
||
@interface CBLQueryResultArray : NSArray | ||
|
||
- (instancetype) initWithResultSet: (CBLQueryResultSet*)resultSet count: (NSUInteger)count; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// CBLQueryResultArray.m | ||
// CouchbaseLite | ||
// | ||
// Created by Pasin Suriyentrakorn on 8/7/17. | ||
// Copyright © 2017 Couchbase. All rights reserved. | ||
// | ||
|
||
#import "CBLQueryResultArray.h" | ||
#import "CBLQueryResultSet+Internal.h" | ||
|
||
@implementation CBLQueryResultArray | ||
{ | ||
CBLQueryResultSet* _rs; | ||
NSUInteger _count; | ||
} | ||
|
||
- (instancetype) initWithResultSet: (CBLQueryResultSet*)resultSet count: (NSUInteger)count { | ||
self = [super init]; | ||
if (self) { | ||
_rs = resultSet; | ||
_count = count; | ||
} | ||
return self; | ||
} | ||
|
||
|
||
- (NSUInteger) count { | ||
return _count; | ||
} | ||
|
||
|
||
- (id) objectAtIndex: (NSUInteger)index { | ||
return [_rs objectAtIndex: index]; | ||
} | ||
|
||
|
||
- (id) copyWithZone:(NSZone *)zone { | ||
return self; | ||
} | ||
|
||
|
||
- (NSMutableArray*) mutableCopy { | ||
NSMutableArray* m = [[NSMutableArray alloc] initWithCapacity: _count]; | ||
for (NSUInteger i = 0; i < _count; ++i) | ||
[m addObject: [self objectAtIndex: i]]; | ||
return m; | ||
} | ||
|
||
|
||
// This is what the %@ substitution calls. | ||
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level { | ||
return [NSString stringWithFormat: @"%@[%lu rows]", [self class], (unsigned long)_count]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
Objective-C/Internal/CBLQueryResultsArray.mm → Objective-C/Internal/CBLQueryRowsArray.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters