diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2013-09-10 00:17:28 -0700 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2013-09-10 00:17:28 -0700 |
commit | 0dfa9a6b27b868e273b2ad6e8e9c5b5c7374b3e8 (patch) | |
tree | f99c24b7b45bd1577ffce87d4dfdfa354d1e9ccd | |
parent | 0480c8997054a8b3ea5537419b8a4f3812bc44f5 (diff) |
Added conversion between NSIndexSet and MCOIndexSet (fixed #370)
-rwxr-xr-x | build-mac/mailcore2.xcodeproj/project.pbxproj | 12 | ||||
-rw-r--r-- | src/cmake/objc.cmake | 1 | ||||
-rw-r--r-- | src/cmake/public-headers.cmake | 1 | ||||
-rw-r--r-- | src/objc/utils/MCOIndexSet.h | 3 | ||||
-rw-r--r-- | src/objc/utils/MCOIndexSet.mm | 10 | ||||
-rw-r--r-- | src/objc/utils/MCOUtils.h | 1 | ||||
-rw-r--r-- | src/objc/utils/NSIndexSet+MCO.h | 18 | ||||
-rw-r--r-- | src/objc/utils/NSIndexSet+MCO.m | 25 |
8 files changed, 71 insertions, 0 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 01e8175d..c34b47a1 100755 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -262,6 +262,10 @@ C68B2AEF1778A869005E61EF /* MCConnectionLogger.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C68B2AEB1778A589005E61EF /* MCConnectionLogger.h */; }; C68B2AF717797389005E61EF /* MCConnectionLoggerUtils.cc in Sources */ = {isa = PBXBuildFile; fileRef = C68B2AF517797389005E61EF /* MCConnectionLoggerUtils.cc */; }; C68B2AF817797389005E61EF /* MCConnectionLoggerUtils.cc in Sources */ = {isa = PBXBuildFile; fileRef = C68B2AF517797389005E61EF /* MCConnectionLoggerUtils.cc */; }; + C69BA85B17DEFCCB00D601B7 /* NSIndexSet+MCO.m in Sources */ = {isa = PBXBuildFile; fileRef = C69BA85A17DEFCCB00D601B7 /* NSIndexSet+MCO.m */; }; + C69BA85C17DEFCCB00D601B7 /* NSIndexSet+MCO.m in Sources */ = {isa = PBXBuildFile; fileRef = C69BA85A17DEFCCB00D601B7 /* NSIndexSet+MCO.m */; }; + C69BA85D17DEFD9A00D601B7 /* NSIndexSet+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C69BA85917DEFCCB00D601B7 /* NSIndexSet+MCO.h */; }; + C69BA85E17DEFD9F00D601B7 /* NSIndexSet+MCO.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = C69BA85917DEFCCB00D601B7 /* NSIndexSet+MCO.h */; }; C6A81B931706840C00882C15 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6A81B921706840C00882C15 /* UIKit.framework */; }; C6A81B941706840C00882C15 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C64EA78F169F259200778456 /* Foundation.framework */; }; C6A81B961706840C00882C15 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C6A81B951706840C00882C15 /* CoreGraphics.framework */; }; @@ -756,6 +760,7 @@ 943F1AA017D9736100F0C798 /* MCIMAPConnectOperation.h in CopyFiles */, 4BE4029217B548D900ECC5E4 /* MCIMAPQuotaOperation.h in CopyFiles */, 4BE4029117B548B900ECC5E4 /* MCOIMAPQuotaOperation.h in CopyFiles */, + C69BA85E17DEFD9F00D601B7 /* NSIndexSet+MCO.h in CopyFiles */, C6E665001790963E0063F2CF /* MCIMAPMessageRenderingOperation.h in CopyFiles */, DAE42E89178F7E1800E0DB8F /* MCOIMAPMessageRenderingOperation.h in CopyFiles */, C63D316617C997B400A4D993 /* MCOIMAPIdentity.h in CopyFiles */, @@ -991,6 +996,7 @@ C6BA2B141705F4E6003F0E9E /* MCOMessagePart.h in CopyFiles */, C6D6F95C171E5D65006F5B28 /* MCJSON.h in CopyFiles */, C6BA2B151705F4E6003F0E9E /* MCOIMAPFolderInfoOperation.h in CopyFiles */, + C69BA85D17DEFD9A00D601B7 /* NSIndexSet+MCO.h in CopyFiles */, C6BA2B161705F4E6003F0E9E /* MCOIMAPFetchMessagesOperation.h in CopyFiles */, C6BA2B171705F4E6003F0E9E /* MCOIMAPCopyMessagesOperation.h in CopyFiles */, C6D6F95D171E5D67006F5B28 /* MCMD5.h in CopyFiles */, @@ -1395,6 +1401,8 @@ C68B2AEB1778A589005E61EF /* MCConnectionLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCConnectionLogger.h; sourceTree = "<group>"; }; C68B2AF517797389005E61EF /* MCConnectionLoggerUtils.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MCConnectionLoggerUtils.cc; sourceTree = "<group>"; }; C68B2AF617797389005E61EF /* MCConnectionLoggerUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MCConnectionLoggerUtils.h; sourceTree = "<group>"; }; + C69BA85917DEFCCB00D601B7 /* NSIndexSet+MCO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSIndexSet+MCO.h"; sourceTree = "<group>"; }; + C69BA85A17DEFCCB00D601B7 /* NSIndexSet+MCO.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSIndexSet+MCO.m"; sourceTree = "<group>"; }; C6A81B911706840C00882C15 /* test-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "test-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; }; C6A81B921706840C00882C15 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; C6A81B951706840C00882C15 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; @@ -2129,6 +2137,8 @@ C6F5B9F316FEAC6C00D9DABD /* MCOIndexSet.mm */, C6CCC5C616FFE5190077A5FC /* MCORange.mm */, C6CCC5C816FFE54F0077A5FC /* MCORange.h */, + C69BA85917DEFCCB00D601B7 /* NSIndexSet+MCO.h */, + C69BA85A17DEFCCB00D601B7 /* NSIndexSet+MCO.m */, ); path = utils; sourceTree = "<group>"; @@ -2531,6 +2541,7 @@ C64EA81116A299ED00778456 /* MCIMAPAppendMessageOperation.cc in Sources */, C64EA81416A29A2300778456 /* MCIMAPCopyMessagesOperation.cc in Sources */, C64EA81716A29A8700778456 /* MCIMAPExpungeOperation.cc in Sources */, + C69BA85B17DEFCCB00D601B7 /* NSIndexSet+MCO.m in Sources */, C64EA81A16A29AF200778456 /* MCIMAPFetchMessagesOperation.cc in Sources */, C64EA81D16A29DC500778456 /* MCIMAPFetchContentOperation.cc in Sources */, C64EA82016A29E4100778456 /* MCIMAPStoreFlagsOperation.cc in Sources */, @@ -2727,6 +2738,7 @@ C6BA2BCA1705F4E6003F0E9E /* MCIMAPAppendMessageOperation.cc in Sources */, C6BA2BCB1705F4E6003F0E9E /* MCIMAPCopyMessagesOperation.cc in Sources */, C6BA2BCC1705F4E6003F0E9E /* MCIMAPExpungeOperation.cc in Sources */, + C69BA85C17DEFCCB00D601B7 /* NSIndexSet+MCO.m in Sources */, C6BA2BCD1705F4E6003F0E9E /* MCIMAPFetchMessagesOperation.cc in Sources */, C6BA2BCE1705F4E6003F0E9E /* MCIMAPFetchContentOperation.cc in Sources */, C6BA2BCF1705F4E6003F0E9E /* MCIMAPStoreFlagsOperation.cc in Sources */, diff --git a/src/cmake/objc.cmake b/src/cmake/objc.cmake index e3e461c9..35dfb221 100644 --- a/src/cmake/objc.cmake +++ b/src/cmake/objc.cmake @@ -82,6 +82,7 @@ set(objc_utils_files objc/utils/NSObject+MCO.mm objc/utils/NSString+MCO.mm objc/utils/NSValue+MCO.mm + objc/utils/NSIndexSet+MCO.m ) IF(APPLE) diff --git a/src/cmake/public-headers.cmake b/src/cmake/public-headers.cmake index 8395072a..0aad67f6 100644 --- a/src/cmake/public-headers.cmake +++ b/src/cmake/public-headers.cmake @@ -113,6 +113,7 @@ objc/utils/MCOOperation.h objc/abstract/MCOConstants.h objc/utils/MCOIndexSet.h objc/utils/MCORange.h +objc/utils/NSIndexSet+MCO.h objc/abstract/MCOAbstract.h objc/abstract/MCOAbstractMessage.h objc/abstract/MCOAbstractMessagePart.h diff --git a/src/objc/utils/MCOIndexSet.h b/src/objc/utils/MCOIndexSet.h index d80aa322..2bb2684e 100644 --- a/src/objc/utils/MCOIndexSet.h +++ b/src/objc/utils/MCOIndexSet.h @@ -57,6 +57,9 @@ /** Enumerates all the indexes of the index set.*/ - (void) enumerateIndexes:(void (^)(uint64_t idx))block; +/** Returns an NSIndexSet from a MCOIndexSet */ +- (NSIndexSet *) nsIndexSet; + @end #endif diff --git a/src/objc/utils/MCOIndexSet.mm b/src/objc/utils/MCOIndexSet.mm index 628ae23f..156be13e 100644 --- a/src/objc/utils/MCOIndexSet.mm +++ b/src/objc/utils/MCOIndexSet.mm @@ -147,4 +147,14 @@ MCO_SYNTHESIZE_NSCODING } } +- (NSIndexSet *) nsIndexSet +{ + NSMutableIndexSet * result = [NSMutableIndexSet indexSet]; + MCORange * allRanges = [self allRanges]; + for(unsigned int i = 0 ; i < [self rangesCount] ; i ++) { + [result addIndexesInRange:NSMakeRange(allRanges[i].location, allRanges[i].length)]; + } + return result; +} + @end diff --git a/src/objc/utils/MCOUtils.h b/src/objc/utils/MCOUtils.h index 3a2c8d82..e2f2e69c 100644 --- a/src/objc/utils/MCOUtils.h +++ b/src/objc/utils/MCOUtils.h @@ -23,5 +23,6 @@ #import <MailCore/MCOConstants.h> #import <MailCore/MCOIndexSet.h> #import <MailCore/MCORange.h> +#import <MailCore/NSIndexSet+MCO.h> #endif diff --git a/src/objc/utils/NSIndexSet+MCO.h b/src/objc/utils/NSIndexSet+MCO.h new file mode 100644 index 00000000..66aa5229 --- /dev/null +++ b/src/objc/utils/NSIndexSet+MCO.h @@ -0,0 +1,18 @@ +// +// NSIndexSet+MCO.h +// mailcore2 +// +// Created by Hoa V. DINH on 9/10/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@class MCOIndexSet; + +@interface NSIndexSet (MCO) + +/** Returns a MCOIndexSet from an NSIndexSet */ +- (MCOIndexSet *) mcoIndexSet; + +@end diff --git a/src/objc/utils/NSIndexSet+MCO.m b/src/objc/utils/NSIndexSet+MCO.m new file mode 100644 index 00000000..dd2b83d0 --- /dev/null +++ b/src/objc/utils/NSIndexSet+MCO.m @@ -0,0 +1,25 @@ +// +// NSIndexSet+MCO.m +// mailcore2 +// +// Created by Hoa V. DINH on 9/10/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "NSIndexSet+MCO.h" +#import "MCOIndexSet.h" + +@implementation NSIndexSet (MCO) + +- (MCOIndexSet *) mcoIndexSet +{ + MCOIndexSet * result = [MCOIndexSet indexSet];; + + [self enumerateRangesUsingBlock:^(NSRange range, BOOL * stop) { + [result addRange:MCORangeMake(range.location, range.length)]; + }]; + + return result; +} + +@end |