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

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSDictionary;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSPredicate : NSObject
{

    public this ()
    {
        super();
    }

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

    public bool evaluateWithObject_ (id object)
    {
        return OS.objc_msgSend(this.id_, OS.sel_evaluateWithObject_1, object !is null ? object.id_ : null) !is null;
    }

    public bool evaluateWithObject_substitutionVariables_ (id object, NSDictionary bindings)
    {
        return OS.objc_msgSend(this.id_, OS.sel_evaluateWithObject_1substitutionVariables_1, object !is null ? object.id_ : null,
                bindings !is null ? bindings.id_ : null) !is null;
    }

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

    public static NSPredicate static_predicateWithFormat_ (NSString predicateWithFormat)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithFormat_1,
                predicateWithFormat !is null ? predicateWithFormat.id_ : null);
        return result !is null ? new NSPredicate(result) : null;
    }

    public static NSPredicate static_predicateWithFormat_argumentArray_ (NSString predicateFormat, NSArray arguments)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithFormat_1argumentArray_1,
                predicateFormat !is null ? predicateFormat.id_ : null, arguments !is null ? arguments.id_ : null);
        return result !is null ? new NSPredicate(result) : null;
    }

    public static NSPredicate static_predicateWithFormat_arguments_ (NSString predicateFormat, ...)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithFormat_1arguments_1,
                predicateFormat !is null ? predicateFormat.id_ : null, _argptr);
        return result !is null ? new NSPredicate(result) : null;
    }

    public NSPredicate predicateWithSubstitutionVariables (NSDictionary variables)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_predicateWithSubstitutionVariables_1, variables !is null ? variables.id_ : null);
        return result is this.id_ ? this : (result !is null ? new NSPredicate(result) : null);
    }

    public static NSPredicate predicateWithValue (bool value)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSPredicate, OS.sel_predicateWithValue_1, value);
        return result !is null ? new NSPredicate(result) : null;
    }

}