/***************************************************************************
                            QDomDocument.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_QDomDocument.h>
#include <qtobjc/QDomDocument.h>
#include <qtobjc/QByteArray.h>
#include <qtobjc/QDomDocumentType.h>


@implementation  QDomDocument


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

- initWithText: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDomDocument1((qt_QString *) [name toQString: &_qstring_name])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDomDocumentType: (QDomDocumentType*)doctype
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QDomDocument2((qt_QDomDocumentType*) [doctype qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (QDomElement*) createElement: (NSString *)tagName
{
static qt_QString * _qstring_tagName = 0L;
	return (QDomElement*) [QtSupport objectForQtKey: qt_QDomDocument_createElement((qt_QDomDocument *)[self qt], (qt_QString *) [tagName toQString: &_qstring_tagName]) withClass: [QDomElement class] allocatedInObjcWorld: YES];
}

- (QDomDocumentFragment*) createDocumentFragment
{
	return (QDomDocumentFragment*) [QtSupport objectForQtKey: qt_QDomDocument_createDocumentFragment((qt_QDomDocument *)[self qt]) withClass: [QDomDocumentFragment class] allocatedInObjcWorld: YES];
}

- (QDomText*) createTextNode: (NSString *)data
{
static qt_QString * _qstring_data = 0L;
	return (QDomText*) [QtSupport objectForQtKey: qt_QDomDocument_createTextNode((qt_QDomDocument *)[self qt], (qt_QString *) [data toQString: &_qstring_data]) withClass: [QDomText class] allocatedInObjcWorld: YES];
}

- (QDomComment*) createComment: (NSString *)data
{
static qt_QString * _qstring_data = 0L;
	return (QDomComment*) [QtSupport objectForQtKey: qt_QDomDocument_createComment((qt_QDomDocument *)[self qt], (qt_QString *) [data toQString: &_qstring_data]) withClass: [QDomComment class] allocatedInObjcWorld: YES];
}

- (QDomCDATASection*) createCDATASection: (NSString *)data
{
static qt_QString * _qstring_data = 0L;
	return (QDomCDATASection*) [QtSupport objectForQtKey: qt_QDomDocument_createCDATASection((qt_QDomDocument *)[self qt], (qt_QString *) [data toQString: &_qstring_data]) withClass: [QDomCDATASection class] allocatedInObjcWorld: YES];
}

- (QDomProcessingInstruction*) createProcessingInstruction: (NSString *)target data: (NSString *)data
{
static qt_QString * _qstring_data = 0L;
static qt_QString * _qstring_target = 0L;
	return (QDomProcessingInstruction*) [QtSupport objectForQtKey: qt_QDomDocument_createProcessingInstruction((qt_QDomDocument *)[self qt], (qt_QString *) [target toQString: &_qstring_target], (qt_QString *) [data toQString: &_qstring_data]) withClass: [QDomProcessingInstruction class] allocatedInObjcWorld: YES];
}

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

- (QDomEntityReference*) createEntityReference: (NSString *)name
{
static qt_QString * _qstring_name = 0L;
	return (QDomEntityReference*) [QtSupport objectForQtKey: qt_QDomDocument_createEntityReference((qt_QDomDocument *)[self qt], (qt_QString *) [name toQString: &_qstring_name]) withClass: [QDomEntityReference class] allocatedInObjcWorld: YES];
}

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

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

- (QDomElement*) createElementNS: (NSString *)nsURI qName: (NSString *)qName
{
static qt_QString * _qstring_qName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	return (QDomElement*) [QtSupport objectForQtKey: qt_QDomDocument_createElementNS((qt_QDomDocument *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [qName toQString: &_qstring_qName]) withClass: [QDomElement class] allocatedInObjcWorld: YES];
}

- (QDomAttr*) createAttributeNS: (NSString *)nsURI qName: (NSString *)qName
{
static qt_QString * _qstring_qName = 0L;
static qt_QString * _qstring_nsURI = 0L;
	return (QDomAttr*) [QtSupport objectForQtKey: qt_QDomDocument_createAttributeNS((qt_QDomDocument *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [qName toQString: &_qstring_qName]) 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_QDomDocument_elementsByTagNameNS((qt_QDomDocument *)[self qt], (qt_QString *) [nsURI toQString: &_qstring_nsURI], (qt_QString *) [localName toQString: &_qstring_localName]);
	return (NSArray *) [NSMutableArray arrayWithQDomNodeList: _qlist];
}

- (QDomElement*) elementById: (NSString *)elementId
{
static qt_QString * _qstring_elementId = 0L;
	return (QDomElement*) [QtSupport objectForQtKey: qt_QDomDocument_elementById((qt_QDomDocument *)[self qt], (qt_QString *) [elementId toQString: &_qstring_elementId]) withClass: [QDomElement class] allocatedInObjcWorld: YES];
}

- (QDomDocumentType*) doctype
{
	return (QDomDocumentType*) [QtSupport objectForQtKey: qt_QDomDocument_doctype((qt_QDomDocument *)[self qt]) withClass: [QDomDocumentType class] allocatedInObjcWorld: YES];
}

- (QDomImplementation*) implementation
{
	return (QDomImplementation*) [QtSupport objectForQtKey: qt_QDomDocument_implementation((qt_QDomDocument *)[self qt]) withClass: [QDomImplementation class] allocatedInObjcWorld: YES];
}

- (QDomElement*) documentElement
{
	return (QDomElement*) [QtSupport objectForQtKey: qt_QDomDocument_documentElement((qt_QDomDocument *)[self qt]) withClass: [QDomElement class] allocatedInObjcWorld: YES];
}

- (BOOL) setContent: (NSString *)text namespaceProcessing: (BOOL)namespaceProcessing errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
{
static qt_QString * _qstring_errorMsg = 0L;
static qt_QCString * _qcstring_text = 0L;
	return (BOOL) qt_QDomDocument_setContent((qt_QDomDocument *)[self qt], (qt_QCString*) [text toQCString: &_qcstring_text], (int)namespaceProcessing, (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
}

- (BOOL) setContent: (NSString *)text namespaceProcessing: (BOOL)namespaceProcessing 
{
static qt_QCString * _qcstring_text = 0L;
	return (BOOL) qt_QDomDocument_setContent((qt_QDomDocument *)[self qt], (qt_QCString*) [text toQCString: &_qcstring_text], (int)namespaceProcessing, 0, 0, 0);
}

- (BOOL) setContentFromByteArray: (QByteArray*)text namespaceProcessing: (BOOL)namespaceProcessing errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
{
static qt_QString * _qstring_errorMsg = 0L;
	return (BOOL) qt_QDomDocument_setContent1((qt_QDomDocument *)[self qt], (qt_QByteArray*) [text qt], (int)namespaceProcessing, (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
}

- (BOOL) setContentFromByteArray: (QByteArray*)text namespaceProcessing: (BOOL)namespaceProcessing
{
	return (BOOL) qt_QDomDocument_setContent1((qt_QDomDocument *)[self qt], (qt_QByteArray*) [text qt], (int)namespaceProcessing, 0, 0, 0);
}

//- (BOOL) setContent: (NSString *)text namespaceProcessing: (BOOL)namespaceProcessing errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
//{
//static qt_QString * _qstring_errorMsg = 0L;
//static qt_QString * _qstring_text = 0L;
//	return (BOOL) qt_QDomDocument_setContent2((qt_QDomDocument *)[self qt], (qt_QString *) [text toQString: &_qstring_text], (int)namespaceProcessing, (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
//}

//- (BOOL) setContent: (NSString *)text namespaceProcessing: (BOOL)namespaceProcessing
//{
//static qt_QString * _qstring_text = 0L;
//	return (BOOL) qt_QDomDocument_setContent2((qt_QDomDocument *)[self qt], (qt_QString *) [text toQString: &_qstring_text], (int)namespaceProcessing, 0, 0, 0);
//}

- (BOOL) setContentFromIODevice: (QIODevice *)dev namespaceProcessing: (BOOL)namespaceProcessing errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
{
static qt_QString * _qstring_errorMsg = 0L;
	return (BOOL) qt_QDomDocument_setContent3((qt_QDomDocument *)[self qt], (qt_QIODevice *) [dev qt], (int)namespaceProcessing, (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
}

- (BOOL) setContentFromIODevice: (QIODevice *)dev namespaceProcessing: (BOOL)namespaceProcessing
{
	return (BOOL) qt_QDomDocument_setContent3((qt_QDomDocument *)[self qt], (qt_QIODevice *) [dev qt], (int)namespaceProcessing, 0, 0, 0);
}

- (BOOL) setContent: (NSString *)text errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
{
static qt_QString * _qstring_errorMsg = 0L;
static qt_QCString * _qcstring_text = 0L;
	return (BOOL) qt_QDomDocument_setContent4((qt_QDomDocument *)[self qt], (qt_QCString*) [text toQCString: &_qcstring_text], (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
}

//- (BOOL) setContent: (NSString *)text
//{
//static qt_QCString * _qcstring_text = 0L;
//	return (BOOL) qt_QDomDocument_setContent4((qt_QDomDocument *)[self qt], (qt_QCString*) [text toQCString: &_qcstring_text], 0, 0, 0);
//}

- (BOOL) setContentFromByteArray: (QByteArray*)text errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
{
static qt_QString * _qstring_errorMsg = 0L;
	return (BOOL) qt_QDomDocument_setContent5((qt_QDomDocument *)[self qt], (qt_QByteArray*) [text qt], (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
}

- (BOOL) setContentFromByteArray: (QByteArray*)text
{
	return (BOOL) qt_QDomDocument_setContent5((qt_QDomDocument *)[self qt], (qt_QByteArray*) [text qt], 0, 0, 0);
}

//- (BOOL) setContent: (NSString *)text errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
//{
//static qt_QString * _qstring_errorMsg = 0L;
//static qt_QString * _qstring_text = 0L;
//	return (BOOL) qt_QDomDocument_setContent6((qt_QDomDocument *)[self qt], (qt_QString *) [text toQString: &_qstring_text], (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
//}

- (BOOL) setContent: (NSString *)text 
{
static qt_QString * _qstring_text = 0L;
	return (BOOL) qt_QDomDocument_setContent6((qt_QDomDocument *)[self qt], (qt_QString *) [text toQString: &_qstring_text], 0, 0, 0);
}

- (BOOL) setContentFromIODevice: (QIODevice *)dev errorMsg: (NSString *)errorMsg errorLine: (int*)errorLine errorColumn: (int*)errorColumn
{
static qt_QString * _qstring_errorMsg = 0L;
	return (BOOL) qt_QDomDocument_setContent7((qt_QDomDocument *)[self qt], (qt_QIODevice *) [dev qt], (qt_QString*) [errorMsg toQString: &_qstring_errorMsg], (int*)errorLine, (int*)errorColumn);
}

- (BOOL) setContentFromIODevice: (QIODevice *)dev
{
	return (BOOL) qt_QDomDocument_setContent7((qt_QDomDocument *)[self qt], (qt_QIODevice *) [dev qt], 0, 0, 0);
}

- (int) nodeType
{
	return (int) qt_QDomDocument_nodeType((qt_QDomDocument *)[self qt]);
}

- (BOOL) isDocument
{
	return (BOOL) qt_QDomDocument_isDocument((qt_QDomDocument *)[self qt]);
}

- (NSString *) toString
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QDomDocument_toString((qt_QDomDocument *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (NSString *) toCString
{
static qt_QCString * _qcstring = 0L;
	_qcstring = qt_QDomDocument_toCString((qt_QDomDocument *)[self qt]);
	return [NSString fromQCString: _qcstring];
}

@end
