view dwt/internal/cocoa/NSKeyedArchiver.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 * Port to the D Programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.internal.cocoa.NSKeyedArchiver;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSCoder;
import dwt.internal.cocoa.NSData;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSMutableData;
import dwt.internal.cocoa.NSPropertyListFormat;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSKeyedArchiver : NSCoder
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public static bool archiveRootObject (id rootObject, NSString path)
    {
        return OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archiveRootObject_1toFile_1, rootObject !is null ? rootObject.id_ : null,
                path !is null ? path.id_ : null) !is null;
    }

    public static NSData archivedDataWithRootObject (id rootObject)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archivedDataWithRootObject_1, rootObject !is null ? rootObject.id_ : null);
        return result !is null ? new NSData(result) : null;
    }

    public NSString classNameForClass_ (objc.Class cls)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_classNameForClass_1, cls);
        return result !is null ? new NSString(result) : null;
    }

    public static NSString static_classNameForClass_ (objc.Class cls)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_classNameForClass_1, cls);
        return result !is null ? new NSString(result) : null;
    }

    public id delegatee ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
        return result !is null ? new id(result) : null;
    }

    public void encodeBool (bool boolv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeBool_1forKey_1, boolv, key !is null ? key.id_ : null);
    }

    public void encodeBytes (/*const*/ubyte* bytesp, NSUInteger lenv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeBytes_1length_1forKey_1, bytesp, lenv, key !is null ? key.id_ : null);
    }

    public void encodeConditionalObject (id objv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeConditionalObject_1forKey_1, objv !is null ? objv.id_ : null, key !is null ? key.id_ : null);
    }

    public void encodeDouble (double realv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeDouble_1forKey_1, realv, key !is null ? key.id_ : null);
    }

    public void encodeFloat (float realv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeFloat_1forKey_1, realv, key !is null ? key.id_ : null);
    }

    public void encodeInt32 (int intv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeInt32_1forKey_1, intv, key !is null ? key.id_ : null);
    }

    public void encodeInt64 (long intv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeInt64_1forKey_1, intv, key !is null ? key.id_ : null);
    }

    public void encodeInt (int intv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeInt_1forKey_1, intv, key !is null ? key.id_ : null);
    }

    public void encodeObject (id objv, NSString key)
    {
        OS.objc_msgSend(this.id_, OS.sel_encodeObject_1forKey_1, objv !is null ? objv.id_ : null, key !is null ? key.id_ : null);
    }

    public void finishEncoding ()
    {
        OS.objc_msgSend(this.id_, OS.sel_finishEncoding);
    }

    public id initForWritingWithMutableData (NSMutableData data)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initForWritingWithMutableData_1, data !is null ? data.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public NSPropertyListFormat outputFormat ()
    {
        return cast(NSPropertyListFormat) OS.objc_msgSend(this.id_, OS.sel_outputFormat);
    }

    public static void static_setClassName_forClass_ (NSString codedName, objc.Class cls)
    {
        OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_setClassName_1forClass_1, codedName !is null ? codedName.id_ : null, cls);
    }

    public void setClassName_forClass_ (NSString codedName, objc.Class cls)
    {
        OS.objc_msgSend(this.id_, OS.sel_setClassName_1forClass_1, codedName !is null ? codedName.id_ : null, cls);
    }

    public void setDelegate (id delegatee)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null);
    }

    public void setOutputFormat (NSPropertyListFormat format)
    {
        OS.objc_msgSend(this.id_, OS.sel_setOutputFormat_1, format);
    }

}