diff options
Diffstat (limited to 'src/objc/utils/MCORange.h')
-rw-r--r-- | src/objc/utils/MCORange.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/objc/utils/MCORange.h b/src/objc/utils/MCORange.h index a42e0928..4fdb9233 100644 --- a/src/objc/utils/MCORange.h +++ b/src/objc/utils/MCORange.h @@ -6,8 +6,9 @@ // Copyright (c) 2013 MailCore. All rights reserved. // -#ifndef mailcore2_MCORange_h -#define mailcore2_MCORange_h +#ifndef __MAILCORE_MCORANGE_H_ + +#define __MAILCORE_MCORANGE_H_ #import <Foundation/Foundation.h> @@ -22,22 +23,45 @@ extern "C" { @class MCOIndexSet; typedef struct { + // first integer of the range. uint64_t location; + + // length of the range. uint64_t length; } MCORange; -extern MCORange RangeEmpty; +// Constants for an emtpy range. +extern MCORange MCORangeEmpty; +// Returns a new range given a location and length. MCORange MCORangeMake(uint64_t location, uint64_t length); + +// Returns an index set that is the result of sustracting a range from a range. MCOIndexSet * MCORangeRemoveRange(MCORange range1, MCORange range2); + +// Returns an index set that is the result of the union a range from a range. MCOIndexSet * MCORangeUnion(MCORange range1, MCORange range2); + #ifdef __cplusplus + +// Returns a C++ range from an Objective-C range. mailcore::Range MCORangeToMCRange(MCORange range); + +// Returns an Objective-C range from a C++ range. MCORange MCORangeWithMCRange(mailcore::Range range); + #endif + +// Returns the intersection of two ranges. MCORange MCORangeIntersection(MCORange range1, MCORange range2); + +// Returns YES if two given ranges have an intersection. BOOL MCORangeHasIntersection(MCORange range1, MCORange range2); + +// Returns left bound of a range. uint64_t MCORangeLeftBound(MCORange range); + +// Returns right bound of a range. uint64_t MCORangeRightBound(MCORange range); #ifdef __cplusplus |