view dwt/internal/cocoa/NSData.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.NSData;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSRange;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSURL;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSData : NSObject
{

    public this ()
    {
        super();
    }

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

    public void* bytes ()
    {
        return cast(void*) OS.objc_msgSend(this.id_, OS.sel_bytes);
    }

    public static id data ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_data);
        return result !is null ? new id(result) : null;
    }

    public static id dataWithBytes (/*const*/void* bytes, NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytes_1length_1, bytes, length);
        return result !is null ? new id(result) : null;
    }

    public static id static_dataWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1, bytes, length);
        return result !is null ? new id(result) : null;
    }

    public static id static_dataWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
        return result !is null ? new id(result) : null;
    }

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

    public static id static_dataWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfFile_1options_1error_1, path !is null ? path.id_ : null,
                readOptionsMask, errorPtr);
        return result !is null ? new id(result) : null;
    }

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

    public static id static_dataWithContentsOfURL_ (NSURL url)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1, url !is null ? url.id_ : null);
        return result !is null ? new id(result) : null;
    }

    public static id static_dataWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSData, OS.sel_dataWithContentsOfURL_1options_1error_1, url !is null ? url.id_ : null,
                readOptionsMask, errorPtr);
        return result !is null ? new id(result) : null;
    }

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

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

    public void getBytes_ (void* buffer)
    {
        OS.objc_msgSend(this.id_, OS.sel_getBytes_1, buffer);
    }

    public void getBytes_length_ (void* buffer, NSUInteger length)
    {
        OS.objc_msgSend(this.id_, OS.sel_getBytes_1length_1, buffer, length);
    }

    public void getBytes_range_ (void* buffer, NSRange range)
    {
        OS.objc_msgSend(this.id_, OS.sel_getBytes_1range_1, buffer, range);
    }

    public NSData initWithBytes (void* bytes, NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytes_1length_1, bytes, length);
        return result !is null ? this : null;
    }

    public NSData initWithBytesNoCopy_length_ (void* bytes, NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytesNoCopy_1length_1, bytes, length);
        return result !is null ? this : null;
    }

    public NSData initWithBytesNoCopy_length_freeWhenDone_ (void* bytes, NSUInteger length, bool b)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithBytesNoCopy_1length_1freeWhenDone_1, bytes, length, b);
        return result !is null ? this : null;
    }

    public NSData initWithContentsOfFile_ (NSString path)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, path !is null ? path.id_ : null);
        return result !is null ? this : null;
    }

    public NSData initWithContentsOfFile_options_error_ (NSString path, NSUInteger readOptionsMask, objc.id** errorPtr)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1options_1error_1, path !is null ? path.id_ : null, readOptionsMask,
                errorPtr);
        return result !is null ? this : null;
    }

    public NSData initWithContentsOfMappedFile (NSString path)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfMappedFile_1, path !is null ? path.id_ : null);
        return result !is null ? this : null;
    }

    public NSData initWithContentsOfURL_ (NSURL url)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null);
        return result !is null ? this : null;
    }

    public NSData initWithContentsOfURL_options_error_ (NSURL url, NSUInteger readOptionsMask, objc.id** errorPtr)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1options_1error_1, url !is null ? url.id_ : null, readOptionsMask,
                errorPtr);
        return result !is null ? this : null;
    }

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

    public bool isEqualToData (NSData other)
    {
        return OS.objc_msgSend(this.id_, OS.sel_isEqualToData_1, other !is null ? other.id_ : null) !is null;
    }

    public NSUInteger length ()
    {
        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_length);
    }

    public NSData subdataWithRange (NSRange range)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_subdataWithRange_1, range);
        return result is this.id_ ? this : (result !is null ? new NSData(result) : null);
    }

    public bool writeToFile_atomically_ (NSString path, bool useAuxiliaryFile)
    {
        return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1atomically_1, path !is null ? path.id_ : null, useAuxiliaryFile) !is null;
    }

    public bool writeToFile_options_error_ (NSString path, NSUInteger writeOptionsMask, objc.id** errorPtr)
    {
        return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1options_1error_1, path !is null ? path.id_ : null, writeOptionsMask, errorPtr) !is null;
    }

    public bool writeToURL_atomically_ (NSURL url, bool atomically)
    {
        return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1atomically_1, url !is null ? url.id_ : null, atomically) !is null;
    }

    public bool writeToURL_options_error_ (NSURL url, NSUInteger writeOptionsMask, objc.id** errorPtr)
    {
        return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1options_1error_1, url !is null ? url.id_ : null, writeOptionsMask, errorPtr) !is null;
    }

}