comparison dstep/foundation/NSRange.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.NSRange;
8
9 import dstep.foundation.NSObjCRuntime;
10 import dstep.foundation.NSString;
11 import dstep.foundation.NSValue;
12 import dstep.objc.bridge.Bridge;
13 import dstep.objc.objc : id;
14
15 alias NSRange* NSRangePointer;
16
17 struct NSRange
18 {
19 NSUInteger location;
20 NSUInteger length;
21 }
22
23 template TNSValueRangeExtensions ()
24 {
25 static NSValue valueWithRange (NSRange range)
26 {
27 return invokeObjcSelfClass!(NSValue, "valueWithRange:", NSRange)(range);
28 }
29
30 NSRange rangeValue ()
31 {
32 return invokeObjcSelf!(NSRange, "rangeValue");
33 }
34 }
35
36 NSString NSStringFromRange (NSRange range)
37 {
38 return Bridge.invokeObjcFunction!(NSString, bindings.NSStringFromRange, NSRange)(range);
39 }
40
41 NSRange NSRangeFromString (NSString aString)
42 {
43 return Bridge.invokeObjcFunction!(NSRange, bindings.NSRangeFromString, NSString)(aString);
44 }
45
46 extern (C)
47 {
48 NSRange NSUnionRange (NSRange range1, NSRange range2);
49 NSRange NSIntersectionRange (NSRange range1, NSRange range2);
50 }