Mercurial > projects > dstep
comparison dstep/foundation/NSURLResponse.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSURLResponse; | |
8 | |
9 import dstep.AvailabilityMacros; | |
10 import dstep.foundation.NSDictionary; | |
11 import dstep.foundation.NSHTTPURLResponseInternal; | |
12 import dstep.foundation.NSObject; | |
13 import dstep.foundation.NSString; | |
14 import dstep.foundation.NSURL; | |
15 import dstep.foundation.NSURLRequest; | |
16 import dstep.foundation.NSURLResponseInternal; | |
17 import dstep.objc.bridge.Bridge; | |
18 import dstep.objc.objc : id; | |
19 | |
20 class NSHTTPURLResponse : NSURLResponse | |
21 { | |
22 mixin ObjcWrap; | |
23 | |
24 NSInteger statusCode () | |
25 { | |
26 return invokeObjcSelf!(NSInteger, "statusCode"); | |
27 } | |
28 | |
29 NSDictionary allHeaderFields () | |
30 { | |
31 return invokeObjcSelf!(NSDictionary, "allHeaderFields"); | |
32 } | |
33 | |
34 static NSString localizedStringForStatusCode (NSInteger statusCode) | |
35 { | |
36 return invokeObjcSelfClass!(NSString, "localizedStringForStatusCode:", NSInteger)(statusCode); | |
37 } | |
38 } | |
39 | |
40 class NSURLResponse : NSObject, INSCoding, INSCopying | |
41 { | |
42 mixin ObjcWrap; | |
43 | |
44 Object initWithURL (NSURL URL, NSString MIMEType, NSInteger length, NSString name) | |
45 { | |
46 return invokeObjcSelf!(Object, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(URL, MIMEType, length, name); | |
47 } | |
48 | |
49 this (NSURL URL, NSString MIMEType, NSInteger length, NSString name) | |
50 { | |
51 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
52 id result = Bridge.invokeObjcMethod!(id, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(objcObject, URL, MIMEType, length, name); | |
53 | |
54 if (result) | |
55 objcObject = ret; | |
56 | |
57 dObject = this; | |
58 } | |
59 | |
60 NSURL URL () | |
61 { | |
62 return invokeObjcSelf!(NSURL, "URL"); | |
63 } | |
64 | |
65 NSString MIMEType () | |
66 { | |
67 return invokeObjcSelf!(NSString, "MIMEType"); | |
68 } | |
69 | |
70 long expectedContentLength () | |
71 { | |
72 return invokeObjcSelf!(long, "expectedContentLength"); | |
73 } | |
74 | |
75 NSString textEncodingName () | |
76 { | |
77 return invokeObjcSelf!(NSString, "textEncodingName"); | |
78 } | |
79 | |
80 NSString suggestedFilename () | |
81 { | |
82 return invokeObjcSelf!(NSString, "suggestedFilename"); | |
83 } | |
84 | |
85 void encodeWithCoder (NSCoder aCoder) | |
86 { | |
87 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
88 } | |
89 | |
90 Object initWithCoder (NSCoder aDecoder) | |
91 { | |
92 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
93 } | |
94 | |
95 this (NSCoder aDecoder) | |
96 { | |
97 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
98 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
99 | |
100 if (result) | |
101 objcObject = ret; | |
102 | |
103 dObject = this; | |
104 } | |
105 | |
106 Object copyWithZone (NSZone* zone) | |
107 { | |
108 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
109 } | |
110 } | |
111 |