/***************************************************************************
                            QDomNode.m -  description
                             -------------------
    begin                : Wed Nov 21 12:08:37 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 12:08:37 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <qtc/qt_QDomNode.h>
#include <qtobjc/QDomNode.h>
#include <qtobjc/QTextStream.h>

@implementation  QDomNode

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


- init
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDomNode()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- copyWithZone: (NSZone *) zone
{
	QDomNode * aCopy;
	aCopy = [[(QDomNode *)[[self class] allocWithZone: zone] setQt: qt_new_QDomNode1([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			qt_del_QDomNode((qt_QDomNode *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (QDomNode*) insertBefore: (QDomNode*)newChild refChild: (QDomNode*)refChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_insertBefore((qt_QDomNode *)[self qt], (qt_QDomNode*) [newChild qt], (qt_QDomNode*) [refChild qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) insertAfter: (QDomNode*)newChild refChild: (QDomNode*)refChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_insertAfter((qt_QDomNode *)[self qt], (qt_QDomNode*) [newChild qt], (qt_QDomNode*) [refChild qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) replaceChild: (QDomNode*)newChild oldChild: (QDomNode*)oldChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_replaceChild((qt_QDomNode *)[self qt], (qt_QDomNode*) [newChild qt], (qt_QDomNode*) [oldChild qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) removeChild: (QDomNode*)oldChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_removeChild((qt_QDomNode *)[self qt], (qt_QDomNode*) [oldChild qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) appendChild: (QDomNode*)newChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_appendChild((qt_QDomNode *)[self qt], (qt_QDomNode*) [newChild qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (BOOL) hasChildNodes
{
	return (BOOL) qt_QDomNode_hasChildNodes((qt_QDomNode *)[self qt]);
}

- (QDomNode*) cloneNode: (BOOL)deep
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_cloneNode((qt_QDomNode *)[self qt], (int)deep) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) cloneNode
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_cloneNode((qt_QDomNode *)[self qt], 1) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- normalize
{
	qt_QDomNode_normalize((qt_QDomNode *)[self qt]);
	return self;
}

- (BOOL) isSupported: (NSString *)feature version: (NSString *)version
{
static qt_QString * _qstring_version = 0L;
static qt_QString * _qstring_feature = 0L;
	return (BOOL) qt_QDomNode_isSupported((qt_QDomNode *)[self qt], (qt_QString *) [feature toQString: &_qstring_feature], (qt_QString *) [version toQString: &_qstring_version]);
}

- (NSString *) nodeName
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomNode_nodeName((qt_QDomNode *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (int) nodeType
{
	return (int) qt_QDomNode_nodeType((qt_QDomNode *)[self qt]);
}

- (QDomNode*) parentNode
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_parentNode((qt_QDomNode *)[self qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (NSArray *) childNodes
{
static qt_QDomNodeList * _qlist = 0L;
	_qlist = qt_QDomNode_childNodes((qt_QDomNode *)[self qt]);
	return (NSArray *) [NSMutableArray arrayWithQDomNodeList: _qlist];
}

- (QDomNode*) firstChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_firstChild((qt_QDomNode *)[self qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) lastChild
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_lastChild((qt_QDomNode *)[self qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) previousSibling
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_previousSibling((qt_QDomNode *)[self qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNode*) nextSibling
{
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_nextSibling((qt_QDomNode *)[self qt]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (QDomNamedNodeMap*) attributes
{
	return (QDomNamedNodeMap*) [QtSupport objectForQtKey: qt_QDomNode_attributes((qt_QDomNode *)[self qt]) withClass: [QDomNamedNodeMap class] allocatedInObjcWorld: YES];
}

- (QDomDocument*) ownerDocument
{
	return (QDomDocument*) [QtSupport objectForQtKey: qt_QDomNode_ownerDocument((qt_QDomNode *)[self qt]) withClass: [QDomDocument class] allocatedInObjcWorld: YES];
}

- (NSString *) namespaceURI
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomNode_namespaceURI((qt_QDomNode *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) localName
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomNode_localName((qt_QDomNode *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (BOOL) hasAttributes
{
	return (BOOL) qt_QDomNode_hasAttributes((qt_QDomNode *)[self qt]);
}

- (NSString *) nodeValue
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomNode_nodeValue((qt_QDomNode *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setNodeValue: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	qt_QDomNode_setNodeValue((qt_QDomNode *)[self qt], (qt_QString *) [arg1 toQString: &_qstring_arg1]);
	return self;
}

- (NSString *) prefix
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomNode_prefix((qt_QDomNode *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setPrefix: (NSString *)pre
{
static qt_QString * _qstring_pre = 0L;
	qt_QDomNode_setPrefix((qt_QDomNode *)[self qt], (qt_QString *) [pre toQString: &_qstring_pre]);
	return self;
}

- (BOOL) isAttr
{
	return (BOOL) qt_QDomNode_isAttr((qt_QDomNode *)[self qt]);
}

- (BOOL) isCDATASection
{
	return (BOOL) qt_QDomNode_isCDATASection((qt_QDomNode *)[self qt]);
}

- (BOOL) isDocumentFragment
{
	return (BOOL) qt_QDomNode_isDocumentFragment((qt_QDomNode *)[self qt]);
}

- (BOOL) isDocument
{
	return (BOOL) qt_QDomNode_isDocument((qt_QDomNode *)[self qt]);
}

- (BOOL) isDocumentType
{
	return (BOOL) qt_QDomNode_isDocumentType((qt_QDomNode *)[self qt]);
}

- (BOOL) isElement
{
	return (BOOL) qt_QDomNode_isElement((qt_QDomNode *)[self qt]);
}

- (BOOL) isEntityReference
{
	return (BOOL) qt_QDomNode_isEntityReference((qt_QDomNode *)[self qt]);
}

- (BOOL) isText
{
	return (BOOL) qt_QDomNode_isText((qt_QDomNode *)[self qt]);
}

- (BOOL) isEntity
{
	return (BOOL) qt_QDomNode_isEntity((qt_QDomNode *)[self qt]);
}

- (BOOL) isNotation
{
	return (BOOL) qt_QDomNode_isNotation((qt_QDomNode *)[self qt]);
}

- (BOOL) isProcessingInstruction
{
	return (BOOL) qt_QDomNode_isProcessingInstruction((qt_QDomNode *)[self qt]);
}

- (BOOL) isCharacterData
{
	return (BOOL) qt_QDomNode_isCharacterData((qt_QDomNode *)[self qt]);
}

- (BOOL) isComment
{
	return (BOOL) qt_QDomNode_isComment((qt_QDomNode *)[self qt]);
}

- (QDomNode*) namedItem: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	return (QDomNode*) [QtSupport objectForQtKey: qt_QDomNode_namedItem((qt_QDomNode *)[self qt], (qt_QString *) [name toQString: &_qstring_name]) withClass: [QDomNode class] allocatedInObjcWorld: YES];
}

- (BOOL) isNull
{
	return (BOOL) qt_QDomNode_isNull((qt_QDomNode *)[self qt]);
}

- clear
{
	qt_QDomNode_clear((qt_QDomNode *)[self qt]);
	return self;
}

- (QDomAttr*) toAttr
{
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomNode_toAttr((qt_QDomNode *)[self qt]) withClass: [QDomAttr class] allocatedInObjcWorld: YES];
}

- (QDomCDATASection*) toCDATASection
{
	return (QDomCDATASection*) [QtSupport objectForQtKey: qt_QDomNode_toCDATASection((qt_QDomNode *)[self qt]) withClass: [QDomCDATASection class] allocatedInObjcWorld: YES];
}

- (QDomDocumentFragment*) toDocumentFragment
{
	return (QDomDocumentFragment*) [QtSupport objectForQtKey: qt_QDomNode_toDocumentFragment((qt_QDomNode *)[self qt]) withClass: [QDomDocumentFragment class] allocatedInObjcWorld: YES];
}

- (QDomDocument*) toDocument
{
	return (QDomDocument*) [QtSupport objectForQtKey: qt_QDomNode_toDocument((qt_QDomNode *)[self qt]) withClass: [QDomDocument class] allocatedInObjcWorld: YES];
}

- (QDomDocumentType*) toDocumentType
{
	return (QDomDocumentType*) [QtSupport objectForQtKey: qt_QDomNode_toDocumentType((qt_QDomNode *)[self qt]) withClass: [QDomDocumentType class] allocatedInObjcWorld: YES];
}

- (QDomElement*) toElement
{
	return (QDomElement*) [QtSupport objectForQtKey: qt_QDomNode_toElement((qt_QDomNode *)[self qt]) withClass: [QDomElement class] allocatedInObjcWorld: YES];
}

- (QDomEntityReference*) toEntityReference
{
	return (QDomEntityReference*) [QtSupport objectForQtKey: qt_QDomNode_toEntityReference((qt_QDomNode *)[self qt]) withClass: [QDomEntityReference class] allocatedInObjcWorld: YES];
}

- (QDomText*) toText
{
	return (QDomText*) [QtSupport objectForQtKey: qt_QDomNode_toText((qt_QDomNode *)[self qt]) withClass: [QDomText class] allocatedInObjcWorld: YES];
}

- (QDomEntity*) toEntity
{
	return (QDomEntity*) [QtSupport objectForQtKey: qt_QDomNode_toEntity((qt_QDomNode *)[self qt]) withClass: [QDomEntity class] allocatedInObjcWorld: YES];
}

- (QDomNotation*) toNotation
{
	return (QDomNotation*) [QtSupport objectForQtKey: qt_QDomNode_toNotation((qt_QDomNode *)[self qt]) withClass: [QDomNotation class] allocatedInObjcWorld: YES];
}

- (QDomProcessingInstruction*) toProcessingInstruction
{
	return (QDomProcessingInstruction*) [QtSupport objectForQtKey: qt_QDomNode_toProcessingInstruction((qt_QDomNode *)[self qt]) withClass: [QDomProcessingInstruction class] allocatedInObjcWorld: YES];
}

- (QDomCharacterData*) toCharacterData
{
	return (QDomCharacterData*) [QtSupport objectForQtKey: qt_QDomNode_toCharacterData((qt_QDomNode *)[self qt]) withClass: [QDomCharacterData class] allocatedInObjcWorld: YES];
}

- (QDomComment*) toComment
{
	return (QDomComment*) [QtSupport objectForQtKey: qt_QDomNode_toComment((qt_QDomNode *)[self qt]) withClass: [QDomComment class] allocatedInObjcWorld: YES];
}

- save: (QTextStream*)arg1 int: (int)arg2
{
	qt_QDomNode_save((qt_QDomNode *)[self qt], (qt_QTextStream*) [arg1 qt], (int)arg2);
	return self;
}

//- initWithDomNodePrivate: (QDomNodePrivate*)arg1
//{
//	if ([self qt] == 0L) {
//		[self setQt: qt_new_QDomNode2((qt_QDomNodePrivate*) [arg1 qt])];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

+ (int) ElementNode
{
	return (int) QDOMNODE_ElementNode;
}

+ (int) AttributeNode
{
	return (int) QDOMNODE_AttributeNode;
}

+ (int) TextNode
{
	return (int) QDOMNODE_TextNode;
}

+ (int) CDATASectionNode
{
	return (int) QDOMNODE_CDATASectionNode;
}

+ (int) EntityReferenceNode
{
	return (int) QDOMNODE_EntityReferenceNode;
}

+ (int) EntityNode
{
	return (int) QDOMNODE_EntityNode;
}

+ (int) ProcessingInstructionNode
{
	return (int) QDOMNODE_ProcessingInstructionNode;
}

+ (int) CommentNode
{
	return (int) QDOMNODE_CommentNode;
}

+ (int) DocumentNode
{
	return (int) QDOMNODE_DocumentNode;
}

+ (int) DocumentTypeNode
{
	return (int) QDOMNODE_DocumentTypeNode;
}

+ (int) DocumentFragmentNode
{
	return (int) QDOMNODE_DocumentFragmentNode;
}

+ (int) NotationNode
{
	return (int) QDOMNODE_NotationNode;
}

+ (int) BaseNode
{
	return (int) QDOMNODE_BaseNode;
}

+ (int) CharacterDataNode
{
	return (int) QDOMNODE_CharacterDataNode;
}

@end
