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

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

public class NSMutableData : NSData
{

    public this ()
    {
        super();
    }

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

    public void appendBytes (/*const*/void* bytes, NSUInteger length)
    {
        OS.objc_msgSend(this.id_, OS.sel_appendBytes_1length_1, bytes, length);
    }

    public void appendData (NSData other)
    {
        OS.objc_msgSend(this.id_, OS.sel_appendData_1, other !is null ? other.id_ : null);
    }

    public static id dataWithCapacity (NSUInteger aNumItems)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSMutableData, OS.sel_dataWithCapacity_1, aNumItems);
        return result !is null ? new id(result) : null;
    }

    public static id dataWithLength (NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSMutableData, OS.sel_dataWithLength_1, length);
        return result !is null ? new id(result) : null;
    }

    public void increaseLengthBy (NSUInteger extraLength)
    {
        OS.objc_msgSend(this.id_, OS.sel_increaseLengthBy_1, extraLength);
    }

    public NSMutableData initWithCapacity (NSUInteger capacity)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCapacity_1, capacity);
        return result !is null ? this : null;
    }

    public NSMutableData initWithLength (NSUInteger length)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithLength_1, length);
        return result !is null ? this : null;
    }

    public void* mutableBytes ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_mutableBytes);
    }

    public void replaceBytesInRange_withBytes_ (NSRange range, /*const*/void* bytes)
    {
        OS.objc_msgSend(this.id_, OS.sel_replaceBytesInRange_1withBytes_1, range, bytes);
    }

    public void replaceBytesInRange_withBytes_length_ (NSRange range, /*const*/void* replacementBytes, NSUInteger replacementLength)
    {
        OS.objc_msgSend(this.id_, OS.sel_replaceBytesInRange_1withBytes_1length_1, range, replacementBytes, replacementLength);
    }

    public void resetBytesInRange (NSRange range)
    {
        OS.objc_msgSend(this.id_, OS.sel_resetBytesInRange_1, range);
    }

    public void setData (NSData data)
    {
        OS.objc_msgSend(this.id_, OS.sel_setData_1, data !is null ? data.id_ : null);
    }

    public void setLength (NSUInteger length)
    {
        OS.objc_msgSend(this.id_, OS.sel_setLength_1, length);
    }

}