Oolite
Loading...
Searching...
No Matches
NSData(OldSchoolPropertyListWriting) Category Reference

#include <OldSchoolPropertyListWriting.h>

Inheritance diagram for NSData(OldSchoolPropertyListWriting):
Collaboration diagram for NSData(OldSchoolPropertyListWriting):

Instance Methods

(NSString *) - oldSchoolPListFormatWithIndentation:errorDescription: [implementation]

Detailed Description

Definition at line 45 of file OldSchoolPropertyListWriting.h.

Method Documentation

◆ oldSchoolPListFormatWithIndentation:errorDescription:

- (NSString *) oldSchoolPListFormatWithIndentation: (unsigned) inIndentation
errorDescription: (NSString**) outErrorDescription 
implementation

Reimplemented from <OldSchoolPropertyListWriting>.

Definition at line 121 of file OldSchoolPropertyListWriting.m.

121 :(unsigned)inIndentation errorDescription:(NSString**)outErrorDescription
122{
123 const uint8_t* srcBytes;
124 uint8_t *dstBytes, *curr;
125 NSUInteger i, j, srcLength, dstLength;
126 const char hexTable[] = "0123456789ABCDEF";
127 NSString* result;
128
129 srcBytes = [self bytes];
130 srcLength = [self length];
131
132 dstLength = 2 * srcLength + srcLength / 8 + 2 + (srcLength / 64 * (1 + inIndentation));
133
134 dstBytes = malloc(dstLength);
135 if (dstBytes == NULL) {
136 if (NULL != outErrorDescription) {
137 *outErrorDescription = [NSString stringWithFormat:@"failed to allocate space (%zu bytes) for conversion of NSData to old-school property list representation", dstLength];
138 }
139 return nil;
140 }
141
142 curr = dstBytes;
143 *curr++ = '<';
144 for (i = 0; i != srcLength; ++i) {
145 if (0 != i && 0 == (i & 3)) {
146 if (0 == (i & 31)) {
147 *curr++ = '\n';
148 j = inIndentation;
149 while (--j)
150 *curr++ = '\t';
151 }
152 *curr++ = ' ';
153 }
154 *curr++ = hexTable[srcBytes[i] >> 4];
155 *curr++ = hexTable[srcBytes[i] & 0xF];
156 }
157 *curr = '>';
158
159 assert((size_t)(curr - dstBytes) <= dstLength);
160
161 result = [[NSString alloc] initWithBytesNoCopy:dstBytes length:dstLength encoding:NSASCIIStringEncoding freeWhenDone:YES];
162 return [result autorelease];
163}
return nil

References nil.


The documentation for this category was generated from the following files: