/***************************************************************************
                            QSqlIndex.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_QSqlIndex.h>
#include <qtobjc/QSqlIndex.h>
#include <qtobjc/QSqlCursor.h>
#include <qtobjc/QSqlField.h>


@implementation  QSqlIndex


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

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

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

- setCursorName: (NSString *)cursorName
{
static qt_QString * _qstring_cursorName = 0L;
	qt_QSqlIndex_setCursorName((qt_QSqlIndex *)[self qt], (qt_QString *) [cursorName toQString: &_qstring_cursorName]);
	return self;
}

- (NSString *) cursorName
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSqlIndex_cursorName((qt_QSqlIndex *)[self qt]);
	return [NSString fromQString: _qstring];
}

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

- (NSString *) name
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QSqlIndex_name((qt_QSqlIndex *)[self qt]);
	return [NSString fromQString: _qstring];
}

- append: (QSqlField*)field
{
	qt_QSqlIndex_append((qt_QSqlIndex *)[self qt], (qt_QSqlField*) [field qt]);
	return self;
}

- append: (QSqlField*)field desc: (BOOL)desc
{
	qt_QSqlIndex_append1((qt_QSqlIndex *)[self qt], (qt_QSqlField*) [field qt], (int)desc);
	return self;
}

- (BOOL) isDescending: (int)i
{
	return (BOOL) qt_QSqlIndex_isDescending((qt_QSqlIndex *)[self qt], (int)i);
}

- setDescending: (int)i desc: (BOOL)desc
{
	qt_QSqlIndex_setDescending((qt_QSqlIndex *)[self qt], (int)i, (int)desc);
	return self;
}

//- (NSString *) toString: (NSString *)prefix separator: (NSString*) sep verbose: (BOOL)verbose;
//{
//static qt_QString * _qstring = 0L;
//static qt_QString * _qstring_sep = 0L;
//static qt_QString * _qstring_prefix = 0L;
//	_qstring = qt_QSqlIndex_toString((qt_QSqlIndex *)[self qt], (qt_QString *) [prefix toQString: &_qstring_prefix], (qt_QString *) [sep toQString: &_qstring_sep], (int)verbose);
//	return [NSString fromQString: _qstring];
//}

- (NSArray *) toStringList: (NSString *)prefix verbose: (BOOL)verbose
{
static qt_QStringList * _qlist = 0L;
static qt_QString * _qstring_prefix = 0L;
	_qlist = qt_QSqlIndex_toStringList((qt_QSqlIndex *)[self qt], (qt_QString *) [prefix toQString: &_qstring_prefix], (int)verbose);
	return (NSArray *) [NSMutableArray arrayWithQStringList: _qlist];
}

+ (QSqlIndex*) fromStringList: (NSArray *)l cursor: (QSqlCursor*)cursor
{
static qt_QStringList * _qlist_l = 0L;
	return (QSqlIndex*) [QtSupport objectForQtKey: qt_QSqlIndex_fromStringList((qt_QStringList*) [l toQStringList: (void *)&_qlist_l], (qt_QSqlCursor*) [cursor qt]) withClass: [QSqlIndex class] allocatedInObjcWorld: YES];
}

@end
