diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSURLResponse.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,111 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSURLResponse;
+
+import dstep.AvailabilityMacros;
+import dstep.foundation.NSDictionary;
+import dstep.foundation.NSHTTPURLResponseInternal;
+import dstep.foundation.NSObject;
+import dstep.foundation.NSString;
+import dstep.foundation.NSURL;
+import dstep.foundation.NSURLRequest;
+import dstep.foundation.NSURLResponseInternal;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+class NSHTTPURLResponse : NSURLResponse
+{
+	mixin ObjcWrap;
+
+	NSInteger statusCode ()
+	{
+		return invokeObjcSelf!(NSInteger, "statusCode");
+	}
+
+	NSDictionary allHeaderFields ()
+	{
+		return invokeObjcSelf!(NSDictionary, "allHeaderFields");
+	}
+
+	static NSString localizedStringForStatusCode (NSInteger statusCode)
+	{
+		return invokeObjcSelfClass!(NSString, "localizedStringForStatusCode:", NSInteger)(statusCode);
+	}
+}
+
+class NSURLResponse : NSObject, INSCoding, INSCopying
+{
+	mixin ObjcWrap;
+
+	Object initWithURL (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
+	{
+		return invokeObjcSelf!(Object, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(URL, MIMEType, length, name);
+	}
+
+	this (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(objcObject, URL, MIMEType, length, name);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	NSURL URL ()
+	{
+		return invokeObjcSelf!(NSURL, "URL");
+	}
+
+	NSString MIMEType ()
+	{
+		return invokeObjcSelf!(NSString, "MIMEType");
+	}
+
+	long expectedContentLength ()
+	{
+		return invokeObjcSelf!(long, "expectedContentLength");
+	}
+
+	NSString textEncodingName ()
+	{
+		return invokeObjcSelf!(NSString, "textEncodingName");
+	}
+
+	NSString suggestedFilename ()
+	{
+		return invokeObjcSelf!(NSString, "suggestedFilename");
+	}
+
+	void encodeWithCoder (NSCoder aCoder)
+	{
+		return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
+	}
+
+	Object initWithCoder (NSCoder aDecoder)
+	{
+		return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
+	}
+
+	this (NSCoder aDecoder)
+	{
+		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
+		id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
+
+		if (result)
+			objcObject = ret;
+
+		dObject = this;
+	}
+
+	Object copyWithZone (NSZone* zone)
+	{
+		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
+	}
+}
+