/***************************************************************************
                            QDomElement.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_QDomElement.h>
#include <qtobjc/QDomElement.h>
#include <qtobjc/QDomAttr.h>

@implementation  QDomElement


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

- copyWithZone: (NSZone *) zone
{
	QDomElement * aCopy;
	aCopy = [[(QDomElement *)[[self class] allocWithZone: zone] setQt: qt_new_QDomElement1([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_QDomElement((qt_QDomElement *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (NSString *) attribute: (NSString *)name defValue: (NSString *)defValue
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_defValue = 0L;
static qt_QString * _qstring_name = 0L;
	_qstring = qt_QDomElement_attribute((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (qt_QString *) [defValue toQString: &_qstring_defValue]);
	return [NSString fromQString: _qstring];
}

- setAttribute: (NSString *)name textValue: (NSString *)value
{
static qt_QString * _qstring_value = 0L;
static qt_QString * _qstring_name = 0L;
	qt_QDomElement_setAttribute((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (qt_QString *) [value toQString: &_qstring_value]);
	return self;
}

- setAttribute: (NSString *)name intValue: (int)value
{
static qt_QString * _qstring_name = 0L;
	qt_QDomElement_setAttribute1((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (int)value);
	return self;
}

- setAttribute: (NSString *)name unsignedIntValue: (unsigned int)value
{
static qt_QString * _qstring_name = 0L;
	qt_QDomElement_setAttribute2((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (unsigned int)value);
	return self;
}

- setAttribute: (NSString *)name doubleValue: (double)value
{
static qt_QString * _qstring_name = 0L;
	qt_QDomElement_setAttribute3((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name], (double)value);
	return self;
}

- removeAttribute: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	qt_QDomElement_removeAttribute((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name]);
	return self;
}

- (QDomAttr*) attributeNode: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomElement_attributeNode((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name]) withClass: [QDomAttr class] allocatedInObjcWorld: YES];
}

- (QDomAttr*) setAttributeNode: (QDomAttr*)newAttr
{
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomElement_setAttributeNode((qt_QDomElement *)[self qt], (qt_QDomAttr*) [newAttr qt]) withClass: [QDomAttr class] allocatedInObjcWorld: YES];
}

- (QDomAttr*) removeAttributeNode: (QDomAttr*)oldAttr
{
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomElement_removeAttributeNode((qt_QDomElement *)[self qt], (qt_QDomAttr*) [oldAttr qt]) withClass: [QDomAttr class] allocatedInObjcWorld: YES];
}

- (NSArray *) elementsByTagName: (NSString *)tagname
{
static qt_QDomNodeList * _qlist = 0L;
static qt_QString * _qstring_tagname = 0L;
	_qlist = qt_QDomElement_elementsByTagName((qt_QDomElement *)[self qt], (qt_QString *) [tagname toQString: &_qstring_tagname]);
	return (NSArray *) [NSMutableArray arrayWithQDomNodeList: _qlist];
}

- (BOOL) hasAttribute: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	return (BOOL) qt_QDomElement_hasAttribute((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name]);
}

- (NSString *) attributeNS: (NSString *)nsURI localName: (NSString *)localName defValue: (NSString *)defValue
{
static qt_QString * _qstring = 0L;
static qt_QString * _qstring_defValue = 0L;
static qt_QString * _qstring_localName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	_qstring = qt_QDomElement_attributeNS((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [localName toQString: &_qstring_localName], (qt_QString *) [defValue toQString: &_qstring_defValue]);
	return [NSString fromQString: _qstring];
}

- setAttributeNS: (NSString *)nsURI qName: (NSString *)qName stringValue: (NSString *)value
{
static qt_QString * _qstring_value = 0L;
static qt_QString * _qstring_qName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	qt_QDomElement_setAttributeNS((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [qName toQString: &_qstring_qName], (qt_QString *) [value toQString: &_qstring_value]);
	return self;
}

- setAttributeNS: (NSString *)nsURI qName: (NSString *)qName intValue: (int)value
{
static qt_QString * _qstring_qName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	qt_QDomElement_setAttributeNS1((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [qName toQString: &_qstring_qName], (int)value);
	return self;
}

- setAttributeNS: (NSString *)nsURI qName: (NSString *)qName unsignedIntValue: (unsigned int)value
{
static qt_QString * _qstring_qName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	qt_QDomElement_setAttributeNS2((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [qName toQString: &_qstring_qName], (unsigned int)value);
	return self;
}

- setAttributeNS: (NSString *)nsURI qName: (NSString *)qName doubleValue: (double)value
{
static qt_QString * _qstring_qName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	qt_QDomElement_setAttributeNS3((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [qName toQString: &_qstring_qName], (double)value);
	return self;
}

- removeAttributeNS: (NSString *)nsURI localName: (NSString *)localName
{
static qt_QString * _qstring_localName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	qt_QDomElement_removeAttributeNS((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [localName toQString: &_qstring_localName]);
	return self;
}

- (QDomAttr*) attributeNodeNS: (NSString *)nsURI localName: (NSString *)localName
{
static qt_QString * _qstring_localName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomElement_attributeNodeNS((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [localName toQString: &_qstring_localName]) withClass: [QDomAttr class] allocatedInObjcWorld: YES];
}

- (QDomAttr*) setAttributeNodeNS: (QDomAttr*)newAttr
{
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomElement_setAttributeNodeNS((qt_QDomElement *)[self qt], (qt_QDomAttr*) [newAttr qt]) withClass: [QDomAttr class] allocatedInObjcWorld: YES];
}

- (NSArray *) elementsByTagNameNS: (NSString *)nsURI localName: (NSString *)localName
{
static qt_QDomNodeList * _qlist = 0L;
static qt_QString * _qstring_localName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	_qlist = qt_QDomElement_elementsByTagNameNS((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [localName toQString: &_qstring_localName]);
	return (NSArray *) [NSMutableArray arrayWithQDomNodeList: _qlist];
}

- (BOOL) hasAttributeNS: (NSString *)nsURI localName: (NSString *)localName
{
static qt_QString * _qstring_localName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	return (BOOL) qt_QDomElement_hasAttributeNS((qt_QDomElement *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [localName toQString: &_qstring_localName]);
}

- (NSString *) tagName
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomElement_tagName((qt_QDomElement *)[self qt]);
	return [NSString fromQString: _qstring];
}

- setTagName: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	qt_QDomElement_setTagName((qt_QDomElement *)[self qt], (qt_QString *) [name toQString: &_qstring_name]);
	return self;
}

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

- (int) nodeType
{
	return (int) qt_QDomElement_nodeType((qt_QDomElement *)[self qt]);
}

- (BOOL) isElement
{
	return (BOOL) qt_QDomElement_isElement((qt_QDomElement *)[self qt]);
}

- (NSString *) text
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomElement_text((qt_QDomElement *)[self qt]);
	return [NSString fromQString: _qstring];
}

@end
