view dstep/foundation/NSXMLNode.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 7ff919f595d5
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.NSXMLNode;

import dstep.foundation.NSArray;
import dstep.foundation.NSDictionary;
import dstep.foundation.NSError;
import dstep.foundation.NSObjCRuntime;
import dstep.foundation.NSObject;
import dstep.foundation.NSString;
import dstep.foundation.NSURL;
import dstep.foundation.NSXMLDocument;
import dstep.foundation.NSXMLElement;
import dstep.foundation.NSXMLNodeOptions;
import dstep.foundation.NSZone;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc;

alias NSUInteger NSXMLNodeKind;

enum
{
	NSXMLInvalidKind = 0,
	NSXMLDocumentKind,
	NSXMLElementKind,
	NSXMLAttributeKind,
	NSXMLNamespaceKind,
	NSXMLProcessingInstructionKind,
	NSXMLCommentKind,
	NSXMLTextKind,
	NSXMLDTDKind,
	NSXMLEntityDeclarationKind,
	NSXMLAttributeDeclarationKind,
	NSXMLElementDeclarationKind,
	NSXMLNotationDeclarationKind
}

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

	Object initWithKind (uint kind)
	{
		return invokeObjcSelf!(Object, "initWithKind:", uint)(kind);
	}

	this (uint kind)
	{
		typeof(this).alloc.initWithKind(kind);
	}

	Object initWithKind (uint kind, NSUInteger options)
	{
		return invokeObjcSelf!(Object, "initWithKind:options:", uint, NSUInteger)(kind, options);
	}

	this (uint kind, NSUInteger options)
	{
		typeof(this).alloc.initWithKind(kind, options);
	}

	static Object document ()
	{
		return invokeObjcSuperClass!(Object, "document");
	}

	static Object documentWithRootElement (NSXMLElement element)
	{
		return invokeObjcSuperClass!(Object, "documentWithRootElement:", NSXMLElement)(element);
	}

	static Object elementWithName (NSString name)
	{
		return invokeObjcSuperClass!(Object, "elementWithName:", NSString)(name);
	}

	static Object elementWithName_URI (NSString name, NSString URI)
	{
		return invokeObjcSuperClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI);
	}

	static Object elementWithName (NSString name, NSString string)
	{
		return invokeObjcSuperClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string);
	}

	static Object elementWithName (NSString name, NSArray children, NSArray attributes)
	{
		return invokeObjcSuperClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes);
	}

	static Object attributeWithName (NSString name, NSString stringValue)
	{
		return invokeObjcSuperClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue);
	}

	static Object attributeWithName (NSString name, NSString URI, NSString stringValue)
	{
		return invokeObjcSuperClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue);
	}

	static Object namespaceWithName (NSString name, NSString stringValue)
	{
		return invokeObjcSuperClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue);
	}

	static Object processingInstructionWithName (NSString name, NSString stringValue)
	{
		return invokeObjcSuperClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue);
	}

	static Object commentWithStringValue (NSString stringValue)
	{
		return invokeObjcSuperClass!(Object, "commentWithStringValue:", NSString)(stringValue);
	}

	static Object textWithStringValue (NSString stringValue)
	{
		return invokeObjcSuperClass!(Object, "textWithStringValue:", NSString)(stringValue);
	}

	static Object DTDNodeWithXMLString (NSString string)
	{
		return invokeObjcSuperClass!(Object, "DTDNodeWithXMLString:", NSString)(string);
	}

	uint kind ()
	{
		return invokeObjcSelf!(uint, "kind");
	}

	void setName (NSString name)
	{
		return invokeObjcSelf!(void, "setName:", NSString)(name);
	}

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

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

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

	void setStringValue (NSString string)
	{
		return invokeObjcSelf!(void, "setStringValue:", NSString)(string);
	}

	void setStringValue (NSString string, bool resolve)
	{
		return invokeObjcSelf!(void, "setStringValue:resolvingEntities:", NSString, bool)(string, resolve);
	}

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

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

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

	NSXMLDocument rootDocument ()
	{
		return invokeObjcSelf!(NSXMLDocument, "rootDocument");
	}

	NSXMLNode parent ()
	{
		id result = invokeObjcSelf!(id, "parent");
		return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);
	}

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

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

	NSXMLNode childAtIndex (NSUInteger index)
	{
		id result = invokeObjcSelf!(id, "childAtIndex:", NSUInteger)(index);
		return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);
	}

	NSXMLNode previousSibling ()
	{
		id result = invokeObjcSelf!(id, "previousSibling");
		return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);
	}

	NSXMLNode nextSibling ()
	{
		id result = invokeObjcSelf!(id, "nextSibling");
		return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);
	}

	NSXMLNode previousNode ()
	{
		id result = invokeObjcSelf!(id, "previousNode");
		return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);
	}

	NSXMLNode nextNode ()
	{
		id result = invokeObjcSelf!(id, "nextNode");
		return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);
	}

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

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

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

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

	void setURI (NSString URI)
	{
		return invokeObjcSelf!(void, "setURI:", NSString)(URI);
	}

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

	static NSString localNameForName (NSString name)
	{
		return invokeObjcSuperClass!(NSString, "localNameForName:", NSString)(name);
	}

	static NSString prefixForName (NSString name)
	{
		return invokeObjcSuperClass!(NSString, "prefixForName:", NSString)(name);
	}

	static NSXMLNode predefinedNamespaceForPrefix (NSString name)
	{
		return invokeObjcSuperClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(name);
	}

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

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

	NSString XMLStringWithOptions (NSUInteger options)
	{
		return invokeObjcSelf!(NSString, "XMLStringWithOptions:", NSUInteger)(options);
	}

	NSString canonicalXMLStringPreservingComments (bool comments)
	{
		return invokeObjcSelf!(NSString, "canonicalXMLStringPreservingComments:", bool)(comments);
	}

	NSArray nodesForXPath (NSString xpath, ref NSError error)
	{
		id err = error ? new objc_object : null;
		NSArray result = invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, id*)(xpath, &err);
		
		if (err)
			error = new NSError(err);
		
		return result;
	}

	NSArray objectsForXQuery (NSString xquery, NSDictionary constants, ref NSError error)
	{
		id err = error ? new objc_object : null;
		NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, id*)(xquery, constants, &err);
		
		if (err)
			error = new NSError(err);
		
		return result;
	}

	NSArray objectsForXQuery (NSString xquery, ref NSError error)
	{
		id err = error ? new objc_object : null;
		NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, id*)(xquery, &err);
		
		if (err)
			error = new NSError(err);
		
		return result;
	}

	Object copyWithZone (NSZone* zone)
	{
		return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
	}
}