Oolite 1.91.0.7645-241119-222d325
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]
 
- Instance Methods inherited from <OldSchoolPropertyListWriting>

Detailed Description

Definition at line 49 of file OldSchoolPropertyListWriting.h.

Method Documentation

◆ oldSchoolPListFormatWithIndentation:errorDescription:

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

Reimplemented from <OldSchoolPropertyListWriting>.

Definition at line 325 of file OldSchoolPropertyListWriting.m.

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

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