comparison dwt/internal/cocoa/NSPropertyListSerialization.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.NSPropertyListSerialization;
15
16 import dwt.internal.cocoa.CFPropertyList;
17 import dwt.internal.cocoa.NSData;
18 import dwt.internal.cocoa.NSObject;
19 import dwt.internal.cocoa.OS;
20 import objc = dwt.internal.objc.runtime;
21
22 enum NSPropertyListFormat
23 {
24 NSPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat,
25 NSPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0,
26 NSPropertyListBinaryFormat_v1_0 = kCFPropertyListBinaryFormat_v1_0
27 }
28
29 alias NSPropertyListFormat.NSPropertyListOpenStepFormat NSPropertyListOpenStepFormat;
30 alias NSPropertyListFormat.NSPropertyListXMLFormat_v1_0 NSPropertyListXMLFormat_v1_0;
31 alias NSPropertyListFormat.NSPropertyListBinaryFormat_v1_0 NSPropertyListBinaryFormat_v1_0;
32
33 enum NSPropertyListMutabilityOptions
34 {
35 NSPropertyListImmutable = kCFPropertyListImmutable,
36 NSPropertyListMutableContainers = kCFPropertyListMutableContainers,
37 NSPropertyListMutableContainersAndLeaves = kCFPropertyListMutableContainersAndLeaves
38 }
39
40 alias NSPropertyListMutabilityOptions.NSPropertyListImmutable NSPropertyListImmutable;
41 alias NSPropertyListMutabilityOptions.NSPropertyListMutableContainers NSPropertyListMutableContainers;
42 alias NSPropertyListMutabilityOptions.NSPropertyListMutableContainersAndLeaves NSPropertyListMutableContainersAndLeaves;
43
44 public class NSPropertyListSerialization : NSObject
45 {
46
47 public this ()
48 {
49 super();
50 }
51
52 public this (objc.id id)
53 {
54 super(id);
55 }
56
57 public static NSData dataFromPropertyList (id plist, NSPropertyListFormat format, objc.id** errorString)
58 {
59 objc.id result = OS.objc_msgSend(OS.class_NSPropertyListSerialization, OS.sel_dataFromPropertyList_1format_1errorDescription_1,
60 plist !is null ? plist.id : null, format, errorString);
61 return result !is null ? new NSData(result) : null;
62 }
63
64 public static bool propertyList (id plist, NSPropertyListFormat format)
65 {
66 return OS.objc_msgSend(OS.class_NSPropertyListSerialization, OS.sel_propertyList_1isValidForFormat_1, plist !is null ? plist.id : null,
67 format) !is null;
68 }
69
70 public static id propertyListFromData (NSData data, NSPropertyListMutabilityOptions opt, NSPropertyListFormat* format, objc.id** errorString)
71 {
72 objc.id result = OS.objc_msgSend(OS.class_NSPropertyListSerialization,
73 OS.sel_propertyListFromData_1mutabilityOption_1format_1errorDescription_1, data !is null ? data.id : null, opt, format, errorString);
74 return result !is null ? new id(result) : null;
75 }
76
77 }