Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSMutableString.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSMutableString; | 14 module dwt.internal.cocoa.NSMutableString; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSInteger; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSRange; | |
19 import dwt.internal.cocoa.NSString; | 18 import dwt.internal.cocoa.NSString; |
20 import dwt.internal.cocoa.OS; | 19 import dwt.internal.cocoa.OS; |
20 import dwt.internal.objc.cocoa.Cocoa; | |
21 import objc = dwt.internal.objc.runtime; | 21 import objc = dwt.internal.objc.runtime; |
22 | 22 |
23 public class NSMutableString : NSString | 23 public class NSMutableString : NSString { |
24 { | |
25 | 24 |
26 public this () | 25 public this() { |
27 { | 26 super(); |
28 super(); | 27 } |
29 } | |
30 | 28 |
31 public this (objc.id id) | 29 public this(objc.id id) { |
32 { | 30 super(id); |
33 super(id); | 31 } |
34 } | |
35 | 32 |
36 public void appendFormat (NSString appendFormat) | 33 public this(cocoa.id id) { |
37 { | 34 super(id); |
38 OS.objc_msgSend(this.id_, OS.sel_appendFormat_1, appendFormat !is null ? appendFormat.id_ : null); | 35 } |
39 } | |
40 | 36 |
41 public void appendString (NSString aString) | 37 public void appendString(NSString aString) { |
42 { | 38 OS.objc_msgSend(this.id, OS.sel_appendString_, aString !is null ? aString.id : null); |
43 OS.objc_msgSend(this.id_, OS.sel_appendString_1, aString !is null ? aString.id_ : null); | 39 } |
44 } | |
45 | 40 |
46 public void deleteCharactersInRange (NSRange range) | 41 public static NSString stringWithCharacters(/*const*/wchar* characters, NSUInteger length) { |
47 { | 42 objc.id result = OS.objc_msgSend(OS.class_NSMutableString, OS.sel_stringWithCharacters_length_, characters, length); |
48 OS.objc_msgSend(this.id_, OS.sel_deleteCharactersInRange_1, range); | 43 return result !is null ? new NSMutableString(result) : null; |
49 } | 44 } |
50 | 45 |
51 public NSMutableString initWithCapacity (NSUInteger capacity) | 46 public static NSString stringWithUTF8String(/*const*/char* nullTerminatedCString) { |
52 { | 47 objc.id result = OS.objc_msgSend(OS.class_NSMutableString, OS.sel_stringWithUTF8String_, nullTerminatedCString); |
53 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCapacity_1, capacity); | 48 return result !is null ? new NSString(result) : null; |
54 return result !is null ? this : null; | 49 } |
55 } | |
56 | |
57 public void insertString (NSString aString, NSUInteger loc) | |
58 { | |
59 OS.objc_msgSend(this.id_, OS.sel_insertString_1atIndex_1, aString !is null ? aString.id_ : null, loc); | |
60 } | |
61 | |
62 public void replaceCharactersInRange (NSRange range, NSString aString) | |
63 { | |
64 OS.objc_msgSend(this.id_, OS.sel_replaceCharactersInRange_1withString_1, range, aString !is null ? aString.id_ : null); | |
65 } | |
66 | |
67 public NSUInteger replaceOccurrencesOfString (NSString target, NSString replacement, NSStringCompareOptions options, NSRange searchRange) | |
68 { | |
69 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_replaceOccurrencesOfString_1withString_1options_1range_1, target !is null ? target.id_ : null, | |
70 replacement !is null ? replacement.id_ : null, options, searchRange); | |
71 } | |
72 | |
73 public void setString (NSString aString) | |
74 { | |
75 OS.objc_msgSend(this.id_, OS.sel_setString_1, aString !is null ? aString.id_ : null); | |
76 } | |
77 | |
78 public static id stringWithCapacity (NSUInteger capacity) | |
79 { | |
80 objc.id result = OS.objc_msgSend(OS.class_NSMutableString, OS.sel_stringWithCapacity_1, capacity); | |
81 return result !is null ? new id(result) : null; | |
82 } | |
83 | 50 |
84 } | 51 } |