comparison dwt/internal/cocoa/NSUserDefaults.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.NSUserDefaults;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSArray;
18 import dwt.internal.cocoa.NSData;
19 import dwt.internal.cocoa.NSDictionary;
20 import dwt.internal.cocoa.NSInteger;
21 import dwt.internal.cocoa.NSObject;
22 import dwt.internal.cocoa.NSString;
23 import dwt.internal.cocoa.OS;
24 import objc = dwt.internal.objc.runtime;
25
26 public class NSUserDefaults : NSObject
27 {
28
29 public this ()
30 {
31 super();
32 }
33
34 public this (objc.id id)
35 {
36 super(id);
37 }
38
39 public void addSuiteNamed (NSString suiteName)
40 {
41 OS.objc_msgSend(this.id, OS.sel_addSuiteNamed_1, suiteName !is null ? suiteName.id : null);
42 }
43
44 public NSArray arrayForKey (NSString defaultName)
45 {
46 objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayForKey_1, defaultName !is null ? defaultName.id : null);
47 return result !is null ? new NSArray(result) : null;
48 }
49
50 public bool boolForKey (NSString defaultName)
51 {
52 return OS.objc_msgSend(this.id, OS.sel_boolForKey_1, defaultName !is null ? defaultName.id : null) !is null;
53 }
54
55 public NSData dataForKey (NSString defaultName)
56 {
57 objc.id result = OS.objc_msgSend(this.id, OS.sel_dataForKey_1, defaultName !is null ? defaultName.id : null);
58 return result !is null ? new NSData(result) : null;
59 }
60
61 public NSDictionary dictionaryForKey (NSString defaultName)
62 {
63 objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionaryForKey_1, defaultName !is null ? defaultName.id : null);
64 return result !is null ? new NSDictionary(result) : null;
65 }
66
67 public NSDictionary dictionaryRepresentation ()
68 {
69 objc.id result = OS.objc_msgSend(this.id, OS.sel_dictionaryRepresentation);
70 return result !is null ? new NSDictionary(result) : null;
71 }
72
73 public double doubleForKey (NSString defaultName)
74 {
75 return cast(double) OS.objc_msgSend_fpret(this.id, OS.sel_doubleForKey_1, defaultName !is null ? defaultName.id : null);
76 }
77
78 public float floatForKey (NSString defaultName)
79 {
80 return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatForKey_1, defaultName !is null ? defaultName.id : null);
81 }
82
83 public id initWithUser (NSString username)
84 {
85 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUser_1, username !is null ? username.id : null);
86 return result !is null ? new id(result) : null;
87 }
88
89 public NSInteger integerForKey (NSString defaultName)
90 {
91 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_integerForKey_1, defaultName !is null ? defaultName.id : null);
92 }
93
94 public id objectForKey (NSString defaultName)
95 {
96 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_1, defaultName !is null ? defaultName.id : null);
97 return result !is null ? new id(result) : null;
98 }
99
100 public bool objectIsForcedForKey_ (NSString key)
101 {
102 return OS.objc_msgSend(this.id, OS.sel_objectIsForcedForKey_1, key !is null ? key.id : null) !is null;
103 }
104
105 public bool objectIsForcedForKey_inDomain_ (NSString key, NSString domain)
106 {
107 return OS.objc_msgSend(this.id, OS.sel_objectIsForcedForKey_1inDomain_1, key !is null ? key.id : null, domain !is null ? domain.id : null) !is null;
108 }
109
110 public NSDictionary persistentDomainForName (NSString domainName)
111 {
112 objc.id result = OS.objc_msgSend(this.id, OS.sel_persistentDomainForName_1, domainName !is null ? domainName.id : null);
113 return result !is null ? new NSDictionary(result) : null;
114 }
115
116 public NSArray persistentDomainNames ()
117 {
118 objc.id result = OS.objc_msgSend(this.id, OS.sel_persistentDomainNames);
119 return result !is null ? new NSArray(result) : null;
120 }
121
122 public void registerDefaults (NSDictionary registrationDictionary)
123 {
124 OS.objc_msgSend(this.id, OS.sel_registerDefaults_1, registrationDictionary !is null ? registrationDictionary.id : null);
125 }
126
127 public void removeObjectForKey (NSString defaultName)
128 {
129 OS.objc_msgSend(this.id, OS.sel_removeObjectForKey_1, defaultName !is null ? defaultName.id : null);
130 }
131
132 public void removePersistentDomainForName (NSString domainName)
133 {
134 OS.objc_msgSend(this.id, OS.sel_removePersistentDomainForName_1, domainName !is null ? domainName.id : null);
135 }
136
137 public void removeSuiteNamed (NSString suiteName)
138 {
139 OS.objc_msgSend(this.id, OS.sel_removeSuiteNamed_1, suiteName !is null ? suiteName.id : null);
140 }
141
142 public void removeVolatileDomainForName (NSString domainName)
143 {
144 OS.objc_msgSend(this.id, OS.sel_removeVolatileDomainForName_1, domainName !is null ? domainName.id : null);
145 }
146
147 public static void resetStandardUserDefaults ()
148 {
149 OS.objc_msgSend(OS.class_NSUserDefaults, OS.sel_resetStandardUserDefaults);
150 }
151
152 public void setBool (bool value, NSString defaultName)
153 {
154 OS.objc_msgSend(this.id, OS.sel_setBool_1forKey_1, value, defaultName !is null ? defaultName.id : null);
155 }
156
157 public void setDouble (double value, NSString defaultName)
158 {
159 OS.objc_msgSend(this.id, OS.sel_setDouble_1forKey_1, value, defaultName !is null ? defaultName.id : null);
160 }
161
162 public void setFloat (float value, NSString defaultName)
163 {
164 OS.objc_msgSend(this.id, OS.sel_setFloat_1forKey_1, value, defaultName !is null ? defaultName.id : null);
165 }
166
167 public void setInteger (NSInteger value, NSString defaultName)
168 {
169 OS.objc_msgSend(this.id, OS.sel_setInteger_1forKey_1, value, defaultName !is null ? defaultName.id : null);
170 }
171
172 public void setObject (id value, NSString defaultName)
173 {
174 OS.objc_msgSend(this.id, OS.sel_setObject_1forKey_1, value !is null ? value.id : null, defaultName !is null ? defaultName.id : null);
175 }
176
177 public void setPersistentDomain (NSDictionary domain, NSString domainName)
178 {
179 OS.objc_msgSend(this.id, OS.sel_setPersistentDomain_1forName_1, domain !is null ? domain.id : null,
180 domainName !is null ? domainName.id : null);
181 }
182
183 public void setVolatileDomain (NSDictionary domain, NSString domainName)
184 {
185 OS.objc_msgSend(this.id, OS.sel_setVolatileDomain_1forName_1, domain !is null ? domain.id : null, domainName !is null ? domainName.id : null);
186 }
187
188 public static NSUserDefaults standardUserDefaults ()
189 {
190 objc.id result = OS.objc_msgSend(OS.class_NSUserDefaults, OS.sel_standardUserDefaults);
191 return result !is null ? new NSUserDefaults(result) : null;
192 }
193
194 public NSArray stringArrayForKey (NSString defaultName)
195 {
196 objc.id result = OS.objc_msgSend(this.id, OS.sel_stringArrayForKey_1, defaultName !is null ? defaultName.id : null);
197 return result !is null ? new NSArray(result) : null;
198 }
199
200 public NSString stringForKey (NSString defaultName)
201 {
202 objc.id result = OS.objc_msgSend(this.id, OS.sel_stringForKey_1, defaultName !is null ? defaultName.id : null);
203 return result !is null ? new NSString(result) : null;
204 }
205
206 public bool synchronize ()
207 {
208 return OS.objc_msgSend(this.id, OS.sel_synchronize) !is null;
209 }
210
211 public NSDictionary volatileDomainForName (NSString domainName)
212 {
213 objc.id result = OS.objc_msgSend(this.id, OS.sel_volatileDomainForName_1, domainName !is null ? domainName.id : null);
214 return result !is null ? new NSDictionary(result) : null;
215 }
216
217 public NSArray volatileDomainNames ()
218 {
219 objc.id result = OS.objc_msgSend(this.id, OS.sel_volatileDomainNames);
220 return result !is null ? new NSArray(result) : null;
221 }
222
223 }