comparison dwt/internal/cocoa/NSData.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSData;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSInteger;
18 import dwt.internal.cocoa.NSObject;
19 import dwt.internal.cocoa.NSRange;
20 import dwt.internal.cocoa.NSString;
21 import dwt.internal.cocoa.NSURL;
22 import dwt.internal.cocoa.OS;
23 import objc = dwt.internal.objc.runtime;
24
25 public class NSData : NSObject
26 {
27
28 public this ()
29 {
30 super();
31 }
32
33 public this (objc.id id)
34 {
35 super(id);
36 }
37
38 public void* bytes ()
39 {
40 return OS.objc_msgSend(this.id, OS.sel_bytes);
41 }
42
43 public static id data ()
44 {
45 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_data);
46 return result !is null ? new id(result) : null;
47 }
48
49 public static id dataWithBytes (/*const*/void* bytes, NSUInteger length)
50 {
51 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytes_1length_1, bytes, length);
52 return result !is null ? new id(result) : null;
53 }
54
55 public static id static_dataWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
56 {
57 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1, bytes, length);
58 return result !is null ? new id(result) : null;
59 }
60
61 public static id static_dataWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
62 {
63 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
64 return result !is null ? new id(result) : null;
65 }
66
67 public static id static_dataWithContentsOfFile_ (NSString path)
68 {
69 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1, path !is null ? path.id : null);
70 return result !is null ? new id(result) : null;
71 }
72
73 public static id static_dataWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
74 {
75 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1options_1error_1, path !is null ? path.id : null,
76 readOptionsMask, errorPtr);
77 return result !is null ? new id(result) : null;
78 }
79
80 public static id dataWithContentsOfMappedFile (NSString path)
81 {
82 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfMappedFile_1, path !is null ? path.id : null);
83 return result !is null ? new id(result) : null;
84 }
85
86 public static id static_dataWithContentsOfURL_ (NSURL url)
87 {
88 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1, url !is null ? url.id : null);
89 return result !is null ? new id(result) : null;
90 }
91
92 public static id static_dataWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
93 {
94 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1options_1error_1, url !is null ? url.id : null,
95 readOptionsMask, errorPtr);
96 return result !is null ? new id(result) : null;
97 }
98
99 public static id dataWithData (NSData data)
100 {
101 objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithData_1, data !is null ? data.id : null);
102 return result !is null ? new id(result) : null;
103 }
104
105 public NSString description ()
106 {
107 objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
108 return result !is null ? new NSString(result) : null;
109 }
110
111 public void getBytes_ (void* buffer)
112 {
113 OS.objc_msgSend(this.id, OS.sel_getBytes_1, buffer);
114 }
115
116 public void getBytes_length_ (void* buffer, NSUInteger length)
117 {
118 OS.objc_msgSend(this.id, OS.sel_getBytes_1length_1, buffer, length);
119 }
120
121 public void getBytes_range_ (void* buffer, NSRange range)
122 {
123 OS.objc_msgSend(this.id, OS.sel_getBytes_1range_1, buffer, range);
124 }
125
126 public NSData initWithBytes (void* bytes, NSUInteger length)
127 {
128 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytes_1length_1, bytes, length);
129 return result !is null ? this : null;
130 }
131
132 public NSData initWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
133 {
134 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytesNoCopy_1length_1, bytes, length);
135 return result !is null ? this : null;
136 }
137
138 public NSData initWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
139 {
140 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
141 return result !is null ? this : null;
142 }
143
144 public NSData initWithContentsOfFile_ (NSString path)
145 {
146 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, path !is null ? path.id : null);
147 return result !is null ? this : null;
148 }
149
150 public NSData initWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
151 {
152 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1options_1error_1, path !is null ? path.id : null, readOptionsMask,
153 errorPtr);
154 return result !is null ? this : null;
155 }
156
157 public NSData initWithContentsOfMappedFile (NSString path)
158 {
159 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfMappedFile_1, path !is null ? path.id : null);
160 return result !is null ? this : null;
161 }
162
163 public NSData initWithContentsOfURL_ (NSURL url)
164 {
165 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
166 return result !is null ? this : null;
167 }
168
169 public NSData initWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
170 {
171 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1options_1error_1, url !is null ? url.id : null, readOptionsMask,
172 errorPtr);
173 return result !is null ? this : null;
174 }
175
176 public NSData initWithData (NSData data)
177 {
178 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null);
179 return result !is null ? this : null;
180 }
181
182 public bool isEqualToData (NSData other)
183 {
184 return OS.objc_msgSend(this.id, OS.sel_isEqualToData_1, other !is null ? other.id : null) !is null;
185 }
186
187 public NSUInteger length ()
188 {
189 return OS.objc_msgSend(this.id, OS.sel_length);
190 }
191
192 public NSData subdataWithRange (NSRange range)
193 {
194 objc.id result = OS.objc_msgSend(this.id, OS.sel_subdataWithRange_1, range);
195 return result is this.id ? this : (result !is null ? new NSData(result) : null);
196 }
197
198 public bool writeToFile_atomically_ (NSString path, bool useAuxiliaryFile)
199 {
200 return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1, path !is null ? path.id : null, useAuxiliaryFile) !is null;
201 }
202
203 public bool writeToFile_options_error_ (NSString path, NSUInteger writeOptionsMask, objc.id** errorPtr)
204 {
205 return OS.objc_msgSend(this.id, OS.sel_writeToFile_1options_1error_1, path !is null ? path.id : null, writeOptionsMask, errorPtr) !is null;
206 }
207
208 public bool writeToURL_atomically_ (NSURL url, bool atomically)
209 {
210 return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1, url !is null ? url.id : null, atomically) !is null;
211 }
212
213 public bool writeToURL_options_error_ (NSURL url, NSUInteger writeOptionsMask, objc.id** errorPtr)
214 {
215 return OS.objc_msgSend(this.id, OS.sel_writeToURL_1options_1error_1, url !is null ? url.id : null, writeOptionsMask, errorPtr) !is null;
216 }
217
218 }