]> git.saurik.com Git - apple/security.git/blob - OSX/utilities/SecNSAdditions.h
Security-59306.11.20.tar.gz
[apple/security.git] / OSX / utilities / SecNSAdditions.h
1 //
2 // SecNSAdditions.h
3 // Security
4 //
5
6 #ifndef _SECNSADDITIONS_H_
7 #define _SECNSADDITIONS_H_
8
9 #import <Foundation/Foundation.h>
10
11 static inline BOOL NSIsEqualSafe(NSObject* obj1, NSObject* obj2) {
12 return obj1 == nil ? (obj2 == nil) : [obj1 isEqual:obj2];
13 }
14
15
16 // MARK: NSArray
17
18 @interface NSArray (compactDescription)
19 - (NSMutableString*) concatenateWithSeparator: (NSString*) separator;
20 @end
21
22 @interface NSDictionary (SOSDictionaryFormat)
23 - (NSString*) compactDescription;
24 @end
25
26 @interface NSMutableDictionary (FindAndRemove)
27 -(NSObject*)extractObjectForKey:(NSString*)key;
28 @end
29
30 // MARK: NSSet
31
32 @interface NSSet (Emptiness)
33 - (bool) isEmpty;
34 @end
35
36 @interface NSSet (HasElements)
37 - (bool) containsElementsNotIn: (NSSet*) other;
38 @end
39
40 @interface NSSet (compactDescription)
41 - (NSString*) shortDescription;
42 @end
43
44 @interface NSSet (Stringizing)
45 - (NSString*) sortedElementsJoinedByString: (NSString*) separator;
46 - (NSString*) sortedElementsTruncated: (NSUInteger) length JoinedByString: (NSString*) separator;
47 @end
48
49
50
51 // MARK: NSString
52
53 static inline NSString* asNSString(NSObject* object) {
54 return [object isKindOfClass:[NSString class]] ? (NSString*) object : nil;
55 }
56
57 @interface NSString (FileOutput)
58 - (void) writeTo: (FILE*) file;
59 - (void) writeToStdOut;
60 - (void) writeToStdErr;
61 @end
62
63 // MARK: NSData
64
65 @interface NSData (Hexinization)
66 - (NSString*) asHexString;
67 @end
68
69 @interface NSMutableData (filledAndClipped)
70 + (instancetype) dataWithSpace: (NSUInteger) initialSize DEREncode: (uint8_t*(^)(size_t size, uint8_t *buffer)) initialization;
71 @end
72
73 #endif /* SecNSAdditions_h */