/***************************************************************************
                            QSqlError.cpp -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 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 17:05:56 2001, using kalyptus 0.9.
 ***************************************************************************/

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

#define _BOOL_H_
#include <qsqlerror.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <qtjava/QSqlError.h>

class QSqlErrorJBridge : public QSqlError
{
public:
	QSqlErrorJBridge(const QString& driverText, const QString& databaseText, int type, int number) : QSqlError(driverText, databaseText, type, number) {}
	QSqlErrorJBridge(const QSqlError& other) : QSqlError(other) {}
	~QSqlErrorJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_newQSqlError__Ljava_lang_String_2Ljava_lang_String_2II(JNIEnv *env, jobject obj, jstring driverText, jstring databaseText, jint type, jint number)
{
static QString * _qstring_databaseText = 0;
static QString * _qstring_driverText = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QSqlErrorJBridge((QString&) * (QString *) QtSupport::toQString(env, driverText, &_qstring_driverText), (QString&) * (QString *) QtSupport::toQString(env, databaseText, &_qstring_databaseText), (int) type, (int) number));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_newQSqlError__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QSqlErrorJBridge(QString::null, QString::null, QSqlError::None, -1));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_newQSqlError__Lorg_kde_qt_QSqlError_2(JNIEnv *env, jobject obj, jobject other)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QSqlErrorJBridge((QSqlError&) *(QSqlError *) QtSupport::getQt(env, other)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (QSqlError*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QSqlError_driverText(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->driverText();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_setDriverText(JNIEnv *env, jobject obj, jstring driverText)
{
static QString * _qstring_driverText = 0;
	((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->setDriverText((QString&) * (QString *) QtSupport::toQString(env, driverText, &_qstring_driverText));
	return;
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QSqlError_databaseText(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->databaseText();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_setDatabaseText(JNIEnv *env, jobject obj, jstring databaseText)
{
static QString * _qstring_databaseText = 0;
	((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->setDatabaseText((QString&) * (QString *) QtSupport::toQString(env, databaseText, &_qstring_databaseText));
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QSqlError_type(JNIEnv *env, jobject obj)
{
	return (jint) ((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->type();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_setType(JNIEnv *env, jobject obj, jint type)
{
	((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->setType((int) type);
	return;
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QSqlError_number(JNIEnv *env, jobject obj)
{
	return (jint) ((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->number();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QSqlError_setNumber(JNIEnv *env, jobject obj, jint number)
{
	((QSqlErrorJBridge*) QtSupport::getQt(env, obj))->setNumber((int) number);
	return;
}

