-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
691 additions
and
561 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,33 @@ | ||
// | ||
// BRSimpleSortDescriptor.h | ||
// BRFullTextSearch | ||
// | ||
// Created by Matt on 25/02/16. | ||
// Copyright © 2016 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0. | ||
// | ||
|
||
#import "BRSortDescriptor.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
A basic implementation of the \c BRSortDescriptor API. | ||
*/ | ||
@interface BRSimpleSortDescriptor : NSObject <BRSortDescriptor> | ||
|
||
/** | ||
Initialize with settings. | ||
@param fieldName The field name to sort by. | ||
@param type The type of sort to apply. | ||
@param ascending YES for ascending, NO for descending order. | ||
@return The initialized instance. | ||
*/ | ||
- (instancetype)initWithFieldName:(NSString *)fieldName | ||
type:(BRSearchSortType)type | ||
ascending:(BOOL)ascending NS_DESIGNATED_INITIALIZER; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_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,36 @@ | ||
// | ||
// BRSimpleSortDescriptor.m | ||
// BRFullTextSearch | ||
// | ||
// Created by Matt on 25/02/16. | ||
// Copyright © 2016 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0. | ||
// | ||
|
||
#import "BRSimpleSortDescriptor.h" | ||
|
||
#import "BRSearchFields.h" | ||
|
||
@implementation BRSimpleSortDescriptor { | ||
NSString *sortFieldName; | ||
BRSearchSortType sortType; | ||
BOOL ascending; | ||
} | ||
|
||
@synthesize sortFieldName; | ||
@synthesize sortType; | ||
@synthesize ascending; | ||
|
||
- (instancetype)init { | ||
return [self initWithFieldName:kBRSearchFieldNameTimestamp type:BRSearchSortTypeString ascending:NO]; | ||
} | ||
|
||
- (instancetype)initWithFieldName:(NSString *)fieldName type:(BRSearchSortType)type ascending:(BOOL)asc { | ||
if ( (self = [super init]) ) { | ||
sortFieldName = fieldName; | ||
sortType = type; | ||
ascending = asc; | ||
} | ||
return self; | ||
} | ||
|
||
@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,54 @@ | ||
// | ||
// BRSortDescriptor.h | ||
// BRFullTextSearch | ||
// | ||
// Created by Matt on 25/02/16. | ||
// Copyright © 2016 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* A search result field value sort type. | ||
* | ||
* When sorting search results by a particular field, all field values are assumed to | ||
* have the same data type, as specified by these constants. | ||
*/ | ||
typedef NS_ENUM (unsigned int, BRSearchSortType) { | ||
/** Sort based on lexicographical order of field values. */ | ||
BRSearchSortTypeString = 0, | ||
|
||
/** Sort based on integer order of field values. */ | ||
BRSearchSortTypeInteger, | ||
|
||
/** Sort based on floating point order of field values. */ | ||
BRSearchSortTypeFloat, | ||
}; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
/** | ||
API for a description of sort characteristics. | ||
*/ | ||
@protocol BRSortDescriptor <NSObject> | ||
|
||
/** The name of the search document field to order the matches by. */ | ||
@property (nonatomic, readonly) NSString *sortFieldName; | ||
|
||
/** The type of sort to use. */ | ||
@property (nonatomic, readonly) BRSearchSortType sortType; | ||
|
||
/** YES to sort in ascending order, NO for descending. */ | ||
@property (nonatomic, readonly, getter=isAscending) BOOL ascending; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.