view dstep/foundation/NSMetadata.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents 89f3c3ef1fd2
children b9de51448c6b
line wrap: on
line source

/**
 * Copyright: Copyright (c) 2009 Jacob Carlborg.
 * Authors: Jacob Carlborg
 * Version: Initial created: Aug 3, 2009 
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
 */
module dstep.foundation.NSMetadata;

import dstep.foundation.NSArray;
import dstep.foundation.NSDate;
import dstep.foundation.NSDictionary;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSPredicate;
import dstep.foundation.NSString;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;



import bindings = dstep.foundation.NSMetadata_bindings;

private
{
	NSString NSMetadataQueryDidStartGatheringNotification_;
	NSString NSMetadataQueryGatheringProgressNotification_;
	NSString NSMetadataQueryDidFinishGatheringNotification_;
	NSString NSMetadataQueryDidUpdateNotification_;
	NSString NSMetadataQueryResultContentRelevanceAttribute_;
	NSString NSMetadataQueryUserHomeScope_;
	NSString NSMetadataQueryLocalComputerScope_;
	NSString NSMetadataQueryNetworkScope_;
}

NSString NSMetadataQueryDidStartGatheringNotification ()
{
	if (NSMetadataQueryDidStartGatheringNotification_)
		return NSMetadataQueryDidStartGatheringNotification_;
		
	return NSMetadataQueryDidStartGatheringNotification_ = new NSString(bindings.NSMetadataQueryDidStartGatheringNotification);
}

NSString NSMetadataQueryGatheringProgressNotification ()
{
	if (NSMetadataQueryGatheringProgressNotification_)
		return NSMetadataQueryGatheringProgressNotification_;
		
	return NSMetadataQueryGatheringProgressNotification_ = new NSString(bindings.NSMetadataQueryGatheringProgressNotification);
}

NSString NSMetadataQueryDidFinishGatheringNotification ()
{
	if (NSMetadataQueryDidFinishGatheringNotification_)
		return NSMetadataQueryDidFinishGatheringNotification_;
		
	return NSMetadataQueryDidFinishGatheringNotification_ = new NSString(bindings.NSMetadataQueryDidFinishGatheringNotification);
}

NSString NSMetadataQueryDidUpdateNotification ()
{
	if (NSMetadataQueryDidUpdateNotification_)
		return NSMetadataQueryDidUpdateNotification_;
		
	return NSMetadataQueryDidUpdateNotification_ = new NSString(bindings.NSMetadataQueryDidUpdateNotification);
}

NSString NSMetadataQueryResultContentRelevanceAttribute ()
{
	if (NSMetadataQueryResultContentRelevanceAttribute_)
		return NSMetadataQueryResultContentRelevanceAttribute_;
		
	return NSMetadataQueryResultContentRelevanceAttribute_ = new NSString(bindings.NSMetadataQueryResultContentRelevanceAttribute);
}

NSString NSMetadataQueryUserHomeScope ()
{
	if (NSMetadataQueryUserHomeScope_)
		return NSMetadataQueryUserHomeScope_;
		
	return NSMetadataQueryUserHomeScope_ = new NSString(bindings.NSMetadataQueryUserHomeScope);
}

NSString NSMetadataQueryLocalComputerScope ()
{
	if (NSMetadataQueryLocalComputerScope_)
		return NSMetadataQueryLocalComputerScope_;
		
	return NSMetadataQueryLocalComputerScope_ = new NSString(bindings.NSMetadataQueryLocalComputerScope);
}

NSString NSMetadataQueryNetworkScope ()
{
	if (NSMetadataQueryNetworkScope_)
		return NSMetadataQueryNetworkScope_;
		
	return NSMetadataQueryNetworkScope_ = new NSString(bindings.NSMetadataQueryNetworkScope);
}

const TNSMetadataQueryDelegate = `

	Object metadataQuery (NSMetadataQuery query, NSMetadataItem result)
	{
		return invokeObjcSelf!(Object, "metadataQuery:replacementObjectForResultObject:", NSMetadataQuery, NSMetadataItem)(query, result);
	}
	
	Object metadataQuery (NSMetadataQuery query, NSString attrName, Object attrValue)
	{
		return invokeObjcSelf!(Object, "metadataQuery:replacementValueForAttribute:value:", NSMetadataQuery, NSString, Object)(query, attrName, attrValue);
	}
	
	//mixin ObjcBindMethod!(metadataQuery, "metadataQuery:replacementObjectForResultObject:");
	//mixin ObjcBindMethod!(metadataQuery, "metadataQuery:replacementValueForAttribute:value:");
`;

class NSMetadataQueryResultGroup : NSObject
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	NSString attribute ()
	{
		return invokeObjcSelf!(NSString, "attribute");
	}

	Object value ()
	{
		return invokeObjcSelf!(Object, "value");
	}

	NSArray subgroups ()
	{
		return invokeObjcSelf!(NSArray, "subgroups");
	}

	NSUInteger resultCount ()
	{
		return invokeObjcSelf!(NSUInteger, "resultCount");
	}

	Object resultAtIndex (NSUInteger idx)
	{
		return invokeObjcSelf!(Object, "resultAtIndex:", NSUInteger)(idx);
	}

	NSArray results ()
	{
		return invokeObjcSelf!(NSArray, "results");
	}
}

class NSMetadataItem : NSObject
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	Object valueForAttribute (NSString key)
	{
		return invokeObjcSelf!(Object, "valueForAttribute:", NSString)(key);
	}

	NSDictionary valuesForAttributes (NSArray keys)
	{
		return invokeObjcSelf!(NSDictionary, "valuesForAttributes:", NSArray)(keys);
	}

	NSArray attributes ()
	{
		return invokeObjcSelf!(NSArray, "attributes");
	}
}

class NSMetadataQuery : NSObject
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	Object delegate_ ()
	{
		return invokeObjcSelf!(Object, "delegate");
	}

	void setDelegate (Object delegate_)
	{
		return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_);
	}

	NSPredicate predicate ()
	{
		return invokeObjcSelf!(NSPredicate, "predicate");
	}

	void setPredicate (NSPredicate predicate)
	{
		return invokeObjcSelf!(void, "setPredicate:", NSPredicate)(predicate);
	}

	NSArray sortDescriptors ()
	{
		return invokeObjcSelf!(NSArray, "sortDescriptors");
	}

	void setSortDescriptors (NSArray descriptors)
	{
		return invokeObjcSelf!(void, "setSortDescriptors:", NSArray)(descriptors);
	}

	NSArray valueListAttributes ()
	{
		return invokeObjcSelf!(NSArray, "valueListAttributes");
	}

	void setValueListAttributes (NSArray attrs)
	{
		return invokeObjcSelf!(void, "setValueListAttributes:", NSArray)(attrs);
	}

	NSArray groupingAttributes ()
	{
		return invokeObjcSelf!(NSArray, "groupingAttributes");
	}

	void setGroupingAttributes (NSArray attrs)
	{
		return invokeObjcSelf!(void, "setGroupingAttributes:", NSArray)(attrs);
	}

	double notificationBatchingInterval ()
	{
		return invokeObjcSelf!(double, "notificationBatchingInterval");
	}

	void setNotificationBatchingInterval (double ti)
	{
		return invokeObjcSelf!(void, "setNotificationBatchingInterval:", double)(ti);
	}

	NSArray searchScopes ()
	{
		return invokeObjcSelf!(NSArray, "searchScopes");
	}

	void setSearchScopes (NSArray scopes)
	{
		return invokeObjcSelf!(void, "setSearchScopes:", NSArray)(scopes);
	}

	bool startQuery ()
	{
		return invokeObjcSelf!(bool, "startQuery");
	}

	void stopQuery ()
	{
		return invokeObjcSelf!(void, "stopQuery");
	}

	bool isStarted ()
	{
		return invokeObjcSelf!(bool, "isStarted");
	}

	bool isGathering ()
	{
		return invokeObjcSelf!(bool, "isGathering");
	}

	bool isStopped ()
	{
		return invokeObjcSelf!(bool, "isStopped");
	}

	void disableUpdates ()
	{
		return invokeObjcSelf!(void, "disableUpdates");
	}

	void enableUpdates ()
	{
		return invokeObjcSelf!(void, "enableUpdates");
	}

	NSUInteger resultCount ()
	{
		return invokeObjcSelf!(NSUInteger, "resultCount");
	}

	Object resultAtIndex (NSUInteger idx)
	{
		return invokeObjcSelf!(Object, "resultAtIndex:", NSUInteger)(idx);
	}

	NSArray results ()
	{
		return invokeObjcSelf!(NSArray, "results");
	}

	NSUInteger indexOfResult (Object result)
	{
		return invokeObjcSelf!(NSUInteger, "indexOfResult:", Object)(result);
	}

	NSDictionary valueLists ()
	{
		return invokeObjcSelf!(NSDictionary, "valueLists");
	}

	NSArray groupedResults ()
	{
		return invokeObjcSelf!(NSArray, "groupedResults");
	}

	Object valueOfAttribute (NSString attrName, NSUInteger idx)
	{
		return invokeObjcSelf!(Object, "valueOfAttribute:forResultAtIndex:", NSString, NSUInteger)(attrName, idx);
	}
}

class NSMetadataQueryAttributeValueTuple : NSObject
{
	mixin (ObjcWrap);
	
	this ()
	{
		super(typeof(this).alloc.init.objcObject);
	}
	
	typeof(this) init ()
	{
		return invokeObjcSelf!(typeof(this), "init");
	}

	NSString attribute ()
	{
		return invokeObjcSelf!(NSString, "attribute");
	}

	Object value ()
	{
		return invokeObjcSelf!(Object, "value");
	}

	NSUInteger count ()
	{
		return invokeObjcSelf!(NSUInteger, "count");
	}
}