view dstep/foundation/NSXMLNode.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 7ff919f595d5
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.NSObject;
import dstep.foundation.NSString;
import dstep.foundation.NSURL;
import dstep.foundation.NSXMLDocument;
import dstep.foundation.NSXMLElement;
import dstep.foundation.NSXMLNodeOptions;
import dstep.objc.bridge.Bridge;
import dstep.objc.objc : id;

alias NSUInteger NSXMLNodeKind;

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

class NSXMLNode : NSObject, INSCopying
{
	mixin ObjcWrap;

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

	this (uint kind)
	{
		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
		id result = Bridge.invokeObjcMethod!(id, "initWithKind:", uint)(objcObject, kind);

		if (result)
			objcObject = ret;

		dObject = this;
	}

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

	this (uint kind, NSUInteger options)
	{
		objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
		id result = Bridge.invokeObjcMethod!(id, "initWithKind:options:", uint, NSUInteger)(objcObject, kind, options);

		if (result)
			objcObject = ret;

		dObject = this;
	}

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

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

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

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

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

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

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

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

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

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

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

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

	static Object DTDNodeWithXMLString (NSString string)
	{
		return invokeObjcSelfClass!(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)(indexreturn 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 invokeObjcSelfClass!(NSString, "localNameForName:", NSString)(name);
	}

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

	static NSXMLNode predefinedNamespaceForPrefix (NSString name)
	{
		return invokeObjcSelfClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(namereturn result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null);	}

	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, NSError** error)
	{
		return invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, NSError**)(xpath, error);
	}

	NSArray objectsForXQuery (NSString xquery, NSDictionary constants, NSError** error)
	{
		return invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, NSError**)(xquery, constants, error);
	}

	NSArray objectsForXQuery (NSString xquery, NSError** error)
	{
		return invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, NSError**)(xquery, error);
	}

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