/***************************************************************************
                            QBitArray.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_QBitArray.h>
#include <qtobjc/QBitArray.h>

@implementation  QBitArray


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

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

- copyWithZone: (NSZone *) zone
{
	QBitArray * aCopy;
	aCopy = [[(QBitArray *)[[self class] allocWithZone: zone] setQt: qt_new_QBitArray2([self qt])] init];
	[aCopy setAllocatedInObjcWorld: YES];
	[QtSupport setObject: aCopy forQtKey: [aCopy qt]];
	return aCopy;
}

- (unsigned int) size
{
	return (unsigned int) qt_QBitArray_size((qt_QBitArray *)[self qt]);
}

- (BOOL) resize: (unsigned int)size
{
	return (BOOL) qt_QBitArray_resize((qt_QBitArray *)[self qt], (unsigned int)size);
}

- (BOOL) fill: (BOOL)v size: (int)size
{
	return (BOOL) qt_QBitArray_fill((qt_QBitArray *)[self qt], (int)v, (int)size);
}

- (BOOL) fill: (BOOL)v 
{
	return (BOOL) qt_QBitArray_fill((qt_QBitArray *)[self qt], (int)v, -1);
}

- detach
{
	qt_QBitArray_detach((qt_QBitArray *)[self qt]);
	return self;
}

- (QBitArray*) copy
{
	return (QBitArray*) [QtSupport objectForQtKey: qt_QBitArray_copy((qt_QBitArray *)[self qt]) withClass: [QBitArray class] allocatedInObjcWorld: YES];
}

- (BOOL) testBit: (unsigned int)index
{
	return (BOOL) qt_QBitArray_testBit((qt_QBitArray *)[self qt], (unsigned int)index);
}

- setBit: (unsigned int)index
{
	qt_QBitArray_setBit((qt_QBitArray *)[self qt], (unsigned int)index);
	return self;
}

- setBit: (unsigned int)index value: (BOOL)value
{
	qt_QBitArray_setBit1((qt_QBitArray *)[self qt], (unsigned int)index, (int)value);
	return self;
}

- clearBit: (unsigned int)index
{
	qt_QBitArray_clearBit((qt_QBitArray *)[self qt], (unsigned int)index);
	return self;
}

- (BOOL) toggleBit: (unsigned int)index
{
	return (BOOL) qt_QBitArray_toggleBit((qt_QBitArray *)[self qt], (unsigned int)index);
}

- (BOOL) at: (unsigned int)index
{
	return (BOOL) qt_QBitArray_at((qt_QBitArray *)[self qt], (unsigned int)index);
}

- (void*) newData
{
	return (void*) qt_QBitArray_newData((qt_QBitArray *)[self qt]);
}

//- deleteData: (void*)d
//{
//	qt_QBitArray_deleteData((qt_QBitArray *)[self qt], (void*)d);
//	return self;
//}

@end
