aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/utils
diff options
context:
space:
mode:
authorGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-04-04 23:23:50 -0700
committerGravatar Hoa V. DINH <dinh.viet.hoa@gmail.com>2013-04-04 23:23:50 -0700
commitd036437a499feafdd79994fcaa38d03b50929fe0 (patch)
treee000395d2eff5532184d8e73c49daa473cf73ecc /src/objc/utils
parent6eba7f202753d79f2de6b8a8c87864e93394343c (diff)
Header documentation. Header clean-up
Diffstat (limited to 'src/objc/utils')
-rw-r--r--src/objc/utils/MCOIndexSet+Private.h5
-rw-r--r--src/objc/utils/MCOIndexSet.h28
-rw-r--r--src/objc/utils/MCOOperation.h7
-rw-r--r--src/objc/utils/MCORange.h30
-rw-r--r--src/objc/utils/MCORange.mm2
-rw-r--r--src/objc/utils/MCOUtils.h5
6 files changed, 66 insertions, 11 deletions
diff --git a/src/objc/utils/MCOIndexSet+Private.h b/src/objc/utils/MCOIndexSet+Private.h
index 78a3554e..ef9111fa 100644
--- a/src/objc/utils/MCOIndexSet+Private.h
+++ b/src/objc/utils/MCOIndexSet+Private.h
@@ -6,8 +6,9 @@
// Copyright (c) 2013 MailCore. All rights reserved.
//
-#ifndef mailcore2_MCOIndexSet_Private_h
-#define mailcore2_MCOIndexSet_Private_h
+#ifndef __MAILCORE_MCOINDEXSET_PRIVATE_H_
+
+#define __MAILCORE_MCOINDEXSET_PRIVATE_H_
#ifdef __cplusplus
@interface MCOIndexSet (Private)
diff --git a/src/objc/utils/MCOIndexSet.h b/src/objc/utils/MCOIndexSet.h
index 83e6f169..5f02935d 100644
--- a/src/objc/utils/MCOIndexSet.h
+++ b/src/objc/utils/MCOIndexSet.h
@@ -6,32 +6,52 @@
// Copyright (c) 2013 MailCore. All rights reserved.
//
-#import <Foundation/Foundation.h>
-
-#import <MailCore/MCORange.h>
-
#ifndef __MAILCORE_MCOINDEXSET_H_
#define __MAILCORE_MCOINDEXSET_H_
+#import <Foundation/Foundation.h>
+
+#import <MailCore/MCORange.h>
+
// similar to NSMutableIndexSet but supports int64_t
@interface MCOIndexSet : NSObject <NSCopying>
+// Creates an empty index set.
+ (MCOIndexSet *) indexSet;
+
+// Creates an index set that contains a range of integers.
+ (MCOIndexSet *) indexSetWithRange:(MCORange)range;
+
+// Creates an index set with a single integer.
+ (MCOIndexSet *) indexSetWithIndex:(uint64_t)idx;
+// Returns the number of integers in that index set.
- (unsigned int) count;
+
+// Adds an integer to the index set.
- (void) addIndex:(uint64_t)idx;
+
+// Removes an integer from the index set.
- (void) removeIndex:(uint64_t)idx;
+
+// Returns YES if the index set contains the given integer.
- (BOOL) containsIndex:(uint64_t)idx;
+// Adds a range of integers to the index set.
- (void) addRange:(MCORange)range;
+
+// Removes a range of integers from the index set.
- (void) removeRange:(MCORange)range;
+
+// Removes all integers that are not in the given range.
- (void) intersectsRange:(MCORange)range;
+// Returns all the ranges of ths index set.
- (MCORange *) allRanges;
+
+// Returns the number of ranges in this index set.
- (unsigned int) rangesCount;
@end
diff --git a/src/objc/utils/MCOOperation.h b/src/objc/utils/MCOOperation.h
index e44ea236..7893f917 100644
--- a/src/objc/utils/MCOOperation.h
+++ b/src/objc/utils/MCOOperation.h
@@ -13,9 +13,16 @@
#import <Foundation/Foundation.h>
@interface MCOOperation : NSObject
+
@property (readonly) BOOL isCancelled;
+// This methods is called on the main thread when the asynchronous operation is finished.
+// Needs to be overriden by subclasses.
+- (void)operationCompleted;
+
+// Cancel the operation.
- (void)cancel;
+
@end
#endif
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
diff --git a/src/objc/utils/MCORange.mm b/src/objc/utils/MCORange.mm
index d1681f14..36c7720c 100644
--- a/src/objc/utils/MCORange.mm
+++ b/src/objc/utils/MCORange.mm
@@ -13,6 +13,8 @@
#include <string.h>
+MCORange MCORangeEmpty = {UINT64_MAX, 0};
+
MCORange MCORangeMake(uint64_t location, uint64_t length)
{
MCORange result;
diff --git a/src/objc/utils/MCOUtils.h b/src/objc/utils/MCOUtils.h
index bc4f716c..3a2c8d82 100644
--- a/src/objc/utils/MCOUtils.h
+++ b/src/objc/utils/MCOUtils.h
@@ -6,8 +6,9 @@
// Copyright (c) 2013 MailCore. All rights reserved.
//
-#ifndef mailcore2_MCOUtils_h
-#define mailcore2_MCOUtils_h
+#ifndef __MAILCORE_MCOUTILS_H_
+
+#define __MAILCORE_MCOUTILS_H_
#import <MailCore/MCOObjectWrapper.h>
#import <MailCore/NSData+MCO.h>