/***************************************************************************
                            KRegExp.cpp -  description
                             -------------------
    begin                : Sun Jan 27 16:22:17 2002
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Jan 27 16:22:17 2002, 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 <kregexp.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <kdejava/KDESupport.h>
#include <kdejava/KRegExp.h>

class KRegExpJBridge : public KRegExp
{
public:
	KRegExpJBridge() : KRegExp() {}
	KRegExpJBridge(const char* _pattern, const char* _mode) : KRegExp(_pattern, _mode) {}
	~KRegExpJBridge() {QtSupport::qtKeyDeleted(this);}
};


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

JNIEXPORT void JNICALL
Java_org_kde_koala_KRegExp_newKRegExp__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring _pattern, jstring _mode)
{
static QCString * _qstring__mode = 0;
static QCString * _qstring__pattern = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KRegExpJBridge((char*) QtSupport::toCharString(env, _pattern, &_qstring__pattern), (char*) QtSupport::toCharString(env, _mode, &_qstring__mode)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_koala_KRegExp_newKRegExp__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring _pattern)
{
static QCString * _qstring__pattern = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new KRegExpJBridge((char*) QtSupport::toCharString(env, _pattern, &_qstring__pattern), ""));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

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

JNIEXPORT void JNICALL
Java_org_kde_koala_KRegExp_dispose(JNIEnv *env, jobject obj)
{
	Java_org_kde_koala_KRegExp_finalize(env, obj);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRegExp_isDisposed(JNIEnv *env, jobject obj)
{
	return (QtSupport::getQt(env, obj) == 0);
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRegExp_compile__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring _pattern, jstring _mode)
{
static QCString * _qstring__mode = 0;
static QCString * _qstring__pattern = 0;
	return (jboolean) ((KRegExp*) QtSupport::getQt(env, obj))->compile((char*) QtSupport::toCharString(env, _pattern, &_qstring__pattern), (char*) QtSupport::toCharString(env, _mode, &_qstring__mode));
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRegExp_compile__Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring _pattern)
{
static QCString * _qstring__pattern = 0;
	return (jboolean) ((KRegExp*) QtSupport::getQt(env, obj))->compile((char*) QtSupport::toCharString(env, _pattern, &_qstring__pattern), "");
}

JNIEXPORT jboolean JNICALL
Java_org_kde_koala_KRegExp_match(JNIEnv *env, jobject obj, jstring _string)
{
static QCString * _qstring__string = 0;
	return (jboolean) ((KRegExp*) QtSupport::getQt(env, obj))->match((char*) QtSupport::toCharString(env, _string, &_qstring__string));
}

JNIEXPORT jstring JNICALL
Java_org_kde_koala_KRegExp_group(JNIEnv *env, jobject obj, jint _grp)
{
	const char * _qcstring;
	_qcstring = (const char *)((KRegExp*) QtSupport::getQt(env, obj))->group((int) _grp);
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KRegExp_groupStart(JNIEnv *env, jobject obj, jint _grp)
{
	return (jint) ((KRegExp*) QtSupport::getQt(env, obj))->groupStart((int) _grp);
}

JNIEXPORT jint JNICALL
Java_org_kde_koala_KRegExp_groupEnd(JNIEnv *env, jobject obj, jint _grp)
{
	return (jint) ((KRegExp*) QtSupport::getQt(env, obj))->groupEnd((int) _grp);
}

