Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.bugvm.apple.corefoundation.CFMutableData Maven / Gradle / Ivy
/*
* Copyright (C) 2013-2015 RoboVM AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bugvm.apple.corefoundation;
/**/
import java.io.*;
import java.nio.*;
import java.util.*;
import com.bugvm.objc.*;
import com.bugvm.objc.annotation.*;
import com.bugvm.objc.block.*;
import com.bugvm.rt.*;
import com.bugvm.rt.annotation.*;
import com.bugvm.rt.bro.*;
import com.bugvm.rt.bro.annotation.*;
import com.bugvm.rt.bro.ptr.*;
import com.bugvm.apple.foundation.*;
import com.bugvm.apple.dispatch.*;
import com.bugvm.apple.coreservices.*;
import com.bugvm.apple.coremedia.*;
import com.bugvm.apple.uikit.*;
import com.bugvm.apple.coretext.*;
/* */
/**/
/* */
/**/@Library("CoreFoundation")/* */
/**/public/* */ class /**/CFMutableData/* */
extends /**/CFData/* */
/**//* */ {
/**/public static class CFMutableDataPtr extends Ptr {}/* */
/**/static { Bro.bind(CFMutableData.class); }/* */
/**//* */
/**//* */
protected CFMutableData() {}
/**//* */
/**//* */
static void checkOffsetAndCount(int arrayLength, int offset, int count) {
if ((offset | count) < 0 || offset > arrayLength || arrayLength - offset < count) {
throw new ArrayIndexOutOfBoundsException("length=" + arrayLength + "; regionStart=" + offset
+ "; regionLength=" + count);
}
}
public static CFMutableData create(long capacity) {
return create((CFAllocator)null, capacity);
}
public static CFMutableData createCopy(long capacity, CFData theData) {
return createCopy(null, capacity, theData);
}
public ByteBuffer asByteBuffer() {
return VM.newDirectByteBuffer(getMutableBytePtr(), getLength());
}
public CFMutableData append(ByteBuffer bytes) {
long handle = getEffectiveAddress(bytes) + bytes.position();
append(handle, bytes.remaining());
return this;
}
public CFMutableData append(byte[] bytes) {
return append(bytes, 0, bytes.length);
}
public CFMutableData append(byte[] bytes, int offset, int length) {
checkOffsetAndCount(bytes.length, offset, length);
if (length == 0) {
return this;
}
append(VM.getArrayValuesAddress(bytes) + offset, length);
return this;
}
public CFMutableData insert(long location, ByteBuffer bytes) {
return replace(new CFRange(location, 0), bytes);
}
public CFMutableData insert(long location, byte[] bytes) {
return replace(new CFRange(location, 0), bytes, 0, bytes.length);
}
public CFMutableData insert(long location, byte[] bytes, int offset, int length) {
return replace(new CFRange(location, 0), bytes, offset, length);
}
public CFMutableData replace(CFRange range, ByteBuffer bytes) {
long handle = getEffectiveAddress(bytes) + bytes.position();
replace(range, handle, bytes.remaining());
return this;
}
public CFMutableData replace(CFRange range, byte[] bytes) {
return replace(range, bytes, 0, bytes.length);
}
public CFMutableData replace(CFRange range, byte[] bytes, int offset, int length) {
checkOffsetAndCount(bytes.length, offset, length);
replace(range, VM.getArrayValuesAddress(bytes) + offset, length);
return this;
}
public CFMutableData delete(CFRange range) {
deleteBytes(range);
return this;
}
/**/
@Bridge(symbol="CFDataCreateMutable", optional=true)
public static native @com.bugvm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) CFMutableData create(CFAllocator allocator, @MachineSizedSInt long capacity);
@Bridge(symbol="CFDataCreateMutableCopy", optional=true)
public static native @com.bugvm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) CFMutableData createCopy(CFAllocator allocator, @MachineSizedSInt long capacity, CFData theData);
@Bridge(symbol="CFDataGetMutableBytePtr", optional=true)
protected native @Pointer long getMutableBytePtr();
@Bridge(symbol="CFDataSetLength", optional=true)
public native void setLength(@MachineSizedSInt long length);
@Bridge(symbol="CFDataIncreaseLength", optional=true)
public native void increaseLength(@MachineSizedSInt long extraLength);
@Bridge(symbol="CFDataAppendBytes", optional=true)
protected native void append(@Pointer long bytes, @MachineSizedSInt long length);
@Bridge(symbol="CFDataReplaceBytes", optional=true)
protected native void replace(@ByVal CFRange range, @Pointer long newBytes, @MachineSizedSInt long newLength);
@Bridge(symbol="CFDataDeleteBytes", optional=true)
protected native void deleteBytes(@ByVal CFRange range);
/* */
}