Skip to content

Commit

Permalink
Native NSData -> binary block handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
th-in-gs committed May 9, 2009
1 parent 8ca4fb3 commit cf2593d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ext/cocoa/src/YAMLCategories.h
Expand Up @@ -50,3 +50,8 @@
- (void)performSelector:(SEL)sel withEachObjectInArray:(NSArray *)array;
- (void)performSelector:(SEL)sel withEachObjectInSet:(NSSet *)set;
@end

@interface NSData (YAMLAdditions)
-(id) yamlDescriptionWithIndent:(int)indent;
-(id) toYAML;
@end
15 changes: 15 additions & 0 deletions ext/cocoa/src/YAMLCategories.m
Expand Up @@ -7,6 +7,7 @@
//

#import "YAMLCategories.h"
#import "GSNSDataExtensions.h"

BOOL yamlClass(id object)
{
Expand All @@ -18,6 +19,8 @@ BOOL yamlClass(id object)
return YES;
if([object isKindOfClass:[NSNumber class]])
return YES;
if([object isKindOfClass:[NSData class]])
return YES;
return NO;
}

Expand Down Expand Up @@ -435,4 +438,16 @@ -(id) toYAML
return [self description];
}

@end

@implementation NSData (YAMLAdditions)
-(id) yamlDescriptionWithIndent:(int)indent
{
return [[@"!binary |\n" stringByAppendingString:[self base64EncodingWithLineLength:72]] indented:indent];
}

-(id) toYAML
{
return self;
}
@end
4 changes: 3 additions & 1 deletion ext/cocoa/src/YAMLCocoaCategories.h
Expand Up @@ -44,7 +44,9 @@
- (id)toYAML;
@end

#if 0
@interface NSData (YAMLCocoaAdditions)
+ (id)objectWithYAML:(id)data;
- (id)toYAML;
@end
@end
#endif
4 changes: 3 additions & 1 deletion ext/cocoa/src/YAMLCocoaCategories.m
Expand Up @@ -253,6 +253,7 @@ -(id) toYAML

@end

#if 0
@implementation NSData (YAMLCocoaAdditions)

+(id) objectWithYAML:(id)data
Expand Down Expand Up @@ -283,4 +284,5 @@ -(id) toYAML
return [self description];
}

@end
@end
#endif

0 comments on commit cf2593d

Please sign in to comment.