view dwt/internal/cocoa/NSKeyedUnarchiver.d @ 13:f565d3a95c0a

Ported dwt.internal
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 22 Aug 2008 16:46:34 +0200
parents 8b48be5454ce
children d8635bb48c7c
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.NSKeyedUnarchiver;

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

public class NSKeyedUnarchiver : NSCoder
{

    public this ()
    {
        super();
    }

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

    public objc.Class classForClassName_ (NSString codedName)
    {
        return cast(objc.Class) OS.objc_msgSend(this.id_, OS.sel_classForClassName_1, codedName !is null ? codedName.id_ : null);
    }

    public static objc.Class static_classForClassName_ (NSString codedName)
    {
        return cast(objc.Class) OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_classForClassName_1, codedName !is null ? codedName.id_ : null);
    }

    public bool containsValueForKey (NSString key)
    {
        return OS.objc_msgSend(this.id_, OS.sel_containsValueForKey_1, key !is null ? key.id_ : null) !is null;
    }

    public bool decodeBoolForKey (NSString key)
    {
        return OS.objc_msgSend(this.id_, OS.sel_decodeBoolForKey_1, key !is null ? key.id_ : null) !is null;
    }

    public /*const*/ubyte* decodeBytesForKey (NSString key, NSUInteger* lengthp)
    {
        return cast(/*const*/ubyte*) OS.objc_msgSend(this.id_, OS.sel_decodeBytesForKey_1returnedLength_1, key !is null ? key.id_ : null, lengthp);
    }

    public double decodeDoubleForKey (NSString key)
    {
        return cast(double) OS.objc_msgSend_fpret(this.id_, OS.sel_decodeDoubleForKey_1, key !is null ? key.id_ : null);
    }

    public float decodeFloatForKey (NSString key)
    {
        return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_decodeFloatForKey_1, key !is null ? key.id_ : null);
    }

    public int decodeInt32ForKey (NSString key)
    {
        return cast(int) OS.objc_msgSend(this.id_, OS.sel_decodeInt32ForKey_1, key !is null ? key.id_ : null);
    }

    public long decodeInt64ForKey (NSString key)
    {
        return cast(long) OS.objc_msgSend(this.id_, OS.sel_decodeInt64ForKey_1, key !is null ? key.id_ : null);
    }

    public int decodeIntForKey (NSString key)
    {
        return cast(int) OS.objc_msgSend(this.id_, OS.sel_decodeIntForKey_1, key !is null ? key.id_ : null);
    }

    public id decodeObjectForKey (NSString key)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodeObjectForKey_1, key !is null ? key.id_ : null);
        return result !is null ? new id(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 finishDecoding ()
    {
        OS.objc_msgSend(this.id_, OS.sel_finishDecoding);
    }

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

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

    public static void static_setClass_forClassName_ (objc.Class cls, NSString codedName)
    {
        OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_setClass_1forClassName_1, cls, codedName !is null ? codedName.id_ : null);
    }

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

    public static id unarchiveObjectWithData (NSData data)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithData_1, data !is null ? data.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id unarchiveObjectWithFile (NSString path)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithFile_1, path !is null ? path.id_ : null);
        return result !is null ? new id(result) : null;
    }

}