All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bugvm.apple.corefoundation.CFSet Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
/*
 * 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.*;
/**/
import com.bugvm.apple.foundation.NSObject;
import com.bugvm.apple.foundation.NSObject.NSObjectPtr;

/**/
/**/
/**/@Library("CoreFoundation")/**/
/**/public/**/ class /**/CFSet/**/ 
    extends /**/CFType/**/ 
    /**//**/ {

    /**/public static class CFSetPtr extends Ptr {}/**/
    /**/static { Bro.bind(CFSet.class); }/**/
    /**//**/
    /**/
    protected CFSet() {}
    /**/
    /**//**/
    /**//**/
    public static  CFSet create(Collection objects) {
        if (objects == null) {
            throw new NullPointerException("objects");
        }
        if (objects.size() == 0 || objects.iterator().next() instanceof CFType) {
            return create(objects.toArray(new CFType[objects.size()]));
        }
        if (objects.iterator().next() instanceof NSObject) {
            return create(objects.toArray(new NSObject[objects.size()]));
        }
        throw new IllegalArgumentException("items can only be of type CFType or NSObject!");
    }
    public static CFSet create(NSObject ... objects) {
        if (objects == null) {
            throw new NullPointerException("objects");
        }
        if (objects.length == 0) {
            return create(null, null, 0, getTypeCallBacks());
        }
        NSObjectPtr values = Struct.allocate(NSObjectPtr.class, objects.length);
        values.set(objects);
        return create(null, values.as(VoidPtr.VoidPtrPtr.class), objects.length, getTypeCallBacks());
    }
    public static CFSet create(CFType ... objects) {
        if (objects == null) {
            throw new NullPointerException("objects");
        }
        if (objects.length == 0) {
            return create(null, null, 0, getTypeCallBacks());
        }
        CFTypePtr values = Struct.allocate(CFTypePtr.class, objects.length);
        values.set(objects);
        return create(null, values.as(VoidPtr.VoidPtrPtr.class), objects.length, getTypeCallBacks());
    }
    
    public boolean contains(NativeObject value) {
        return containsValue(value.as(VoidPtr.class));
    }
    
    public void add(NativeObject value) {
        throw new UnsupportedOperationException("CFSet is immutable. Use CFMutableSet instead!");
    }
    public void remove(NativeObject value) {
        throw new UnsupportedOperationException("CFSet is immutable. Use CFMutableSet instead!");
    }
    public void clear() {
        throw new UnsupportedOperationException("CFSet is immutable. Use CFMutableSet instead!");
    }
    /**/
    @GlobalValue(symbol="kCFTypeSetCallBacks", optional=true)
    public static native @ByVal CFSetCallBacks getTypeCallBacks();
    @GlobalValue(symbol="kCFCopyStringSetCallBacks", optional=true)
    public static native @ByVal CFSetCallBacks getCopyStringCallBacks();
    
    @Bridge(symbol="CFSetGetTypeID", optional=true)
    public static native @MachineSizedUInt long getClassTypeID();
    @Bridge(symbol="CFSetCreate", optional=true)
    protected static native @com.bugvm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) CFSet create(CFAllocator allocator, VoidPtr.VoidPtrPtr values, @MachineSizedSInt long numValues, CFSetCallBacks callBacks);
    @Bridge(symbol="CFSetCreateCopy", optional=true)
    protected static native @com.bugvm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) CFSet createCopy(CFAllocator allocator, CFSet theSet);
    @Bridge(symbol="CFSetGetCount", optional=true)
    public native @MachineSizedSInt long size();
    @Bridge(symbol="CFSetGetCountOfValue", optional=true)
    protected native @MachineSizedSInt long getCountOfValue(VoidPtr value);
    @Bridge(symbol="CFSetContainsValue", optional=true)
    protected native boolean containsValue(VoidPtr value);
    @Bridge(symbol="CFSetGetValue", optional=true)
    protected native VoidPtr getValue(VoidPtr value);
    @Bridge(symbol="CFSetGetValueIfPresent", optional=true)
    protected native boolean getValueIfPresent(VoidPtr candidate, VoidPtr.VoidPtrPtr value);
    @Bridge(symbol="CFSetGetValues", optional=true)
    protected native void getValues(VoidPtr.VoidPtrPtr values);
    @Bridge(symbol="CFSetApplyFunction", optional=true)
    protected native void applyFunction(FunctionPtr applier, VoidPtr context);
    /**/
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy