forked from SVGKit/SVGKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVGKSourceString.m
More file actions
40 lines (30 loc) · 1.08 KB
/
Copy pathSVGKSourceString.m
File metadata and controls
40 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#import "SVGKSourceString.h"
@implementation SVGKSourceString
-(NSString *)keyForAppleDictionaries
{
return self.rawString;
}
+ (SVGKSource*)sourceFromContentsOfString:(NSString*)rawString {
NSInputStream* stream = [NSInputStream inputStreamWithData:[rawString dataUsingEncoding:NSUTF8StringEncoding]];
//DO NOT DO THIS: let the parser do it at last possible moment (Apple has threading problems otherwise!) [stream open];
SVGKSource* s = [[[SVGKSourceString alloc] initWithInputSteam:stream] autorelease];
s.approximateLengthInBytesOr0 = [rawString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
return s;
}
-(id)copyWithZone:(NSZone *)zone
{
id copy = [super copyWithZone:zone];
if( copy )
{
/** clone bits */
[copy setRawString:[[self.rawString copy] autorelease]];
/** Finally, manually intialize the input stream, as required by super class */
[copy setStream:[NSInputStream inputStreamWithData:[((SVGKSourceString*)copy).rawString dataUsingEncoding:NSUTF8StringEncoding]]];
}
return copy;
}
- (void)dealloc {
self.rawString = nil;
[super dealloc];
}
@end