/***************************************************************************
                            QRegExp.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 <qregexp.h>
#include <qstring.h>
#include <qcstring.h>

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

class QRegExpJBridge : public QRegExp
{
public:
	QRegExpJBridge() : QRegExp() {}
	QRegExpJBridge(const QString& pattern, bool caseSensitive, bool wildcard) : QRegExp(pattern, caseSensitive, wildcard) {}
	QRegExpJBridge(const QRegExp& rx) : QRegExp(rx) {}
	~QRegExpJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_newQRegExp__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QRegExpJBridge());
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_newQRegExp__Ljava_lang_String_2ZZ(JNIEnv *env, jobject obj, jstring pattern, jboolean caseSensitive, jboolean wildcard)
{
static QString * _qstring_pattern = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QRegExpJBridge((QString&) * (QString *) QtSupport::toQString(env, pattern, &_qstring_pattern), (bool) caseSensitive, (bool) wildcard));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_newQRegExp__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring pattern)
{
static QString * _qstring_pattern = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QRegExpJBridge((QString&) * (QString *) QtSupport::toQString(env, pattern, &_qstring_pattern), TRUE, FALSE));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_newQRegExp__Lorg_kde_qt_QRegExp_2(JNIEnv *env, jobject obj, jobject rx)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QRegExpJBridge((QRegExp&) *(QRegExp *) QtSupport::getQt(env, rx)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QRegExp_isEmpty(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->isEmpty();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QRegExp_isValid(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->isValid();
}

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

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_setPattern(JNIEnv *env, jobject obj, jstring pattern)
{
static QString * _qstring_pattern = 0;
	((QRegExpJBridge*) QtSupport::getQt(env, obj))->setPattern((QString&) * (QString *) QtSupport::toQString(env, pattern, &_qstring_pattern));
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QRegExp_caseSensitive(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->caseSensitive();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_setCaseSensitive(JNIEnv *env, jobject obj, jboolean sensitive)
{
	((QRegExpJBridge*) QtSupport::getQt(env, obj))->setCaseSensitive((bool) sensitive);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QRegExp_wildcard(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->wildcard();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_setWildcard(JNIEnv *env, jobject obj, jboolean wildcard)
{
	((QRegExpJBridge*) QtSupport::getQt(env, obj))->setWildcard((bool) wildcard);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QRegExp_minimal(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->minimal();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QRegExp_setMinimal(JNIEnv *env, jobject obj, jboolean minimal)
{
	((QRegExpJBridge*) QtSupport::getQt(env, obj))->setMinimal((bool) minimal);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QRegExp_exactMatch(JNIEnv *env, jobject obj, jstring str)
{
static QString * _qstring_str = 0;
	return (jboolean) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->exactMatch((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str));
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_match__Ljava_lang_String_2I_3IZ(JNIEnv *env, jobject obj, jstring str, jint index, jintArray len, jboolean indexIsStart)
{
static QString * _qstring_str = 0;
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->match((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), (int) index,  (int*) QtSupport::toIntPtr(env, len), (bool) indexIsStart);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_match__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring str)
{
static QString * _qstring_str = 0;
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->match((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), 0, 0, TRUE);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_search__Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring str, jint start)
{
static QString * _qstring_str = 0;
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->search((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), (int) start);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_search__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring str)
{
static QString * _qstring_str = 0;
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->search((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), 0);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_searchRev__Ljava_lang_String_2I(JNIEnv *env, jobject obj, jstring str, jint start)
{
static QString * _qstring_str = 0;
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->searchRev((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), (int) start);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_searchRev__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring str)
{
static QString * _qstring_str = 0;
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->searchRev((QString&) * (QString *) QtSupport::toQString(env, str, &_qstring_str), -1);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_matchedLength(JNIEnv *env, jobject obj)
{
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->matchedLength();
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QRegExp_capturedTexts(JNIEnv *env, jobject obj)
{
	QStringList  _qlist;
	_qlist = ((QRegExpJBridge*) QtSupport::getQt(env, obj))->capturedTexts();
	return (jobject) QtSupport::arrayWithQStringList(env, (QStringList *) &_qlist);
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QRegExp_cap(JNIEnv *env, jobject obj, jint nth)
{
	QString  _qstring;
	_qstring = ((QRegExpJBridge*) QtSupport::getQt(env, obj))->cap((int) nth);
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_pos__I(JNIEnv *env, jobject obj, jint nth)
{
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->pos((int) nth);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QRegExp_pos__(JNIEnv *env, jobject obj)
{
	return (jint) ((QRegExpJBridge*) QtSupport::getQt(env, obj))->pos(0);
}

