/***************************************************************************
                            QUuid.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_QUuid.h>
#include <qtobjc/QUuid.h>

@implementation  QUuid

- (void *) qt
{
	return _qt;
}

- setQt: (void *) qt
{
	_qt = qt;
	return self;
}

- (BOOL) allocatedInObjcWorld
{
	return _allocatedInObjcWorld;
}

- setAllocatedInObjcWorld: (BOOL) yn
{
	_allocatedInObjcWorld = yn;
	return self;
}


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

- initWithUnsigned: (unsigned long)l w1: (unsigned short)w1 w2: (unsigned short)w2 b1: (unsigned char)b1 b2: (unsigned char)b2 b3: (unsigned char)b3 b4: (unsigned char)b4 b5: (unsigned char)b5 b6: (unsigned char)b6 b7: (unsigned char)b7 b8: (unsigned char)b8
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QUuid1((unsigned long)l, (unsigned short)w1, (unsigned short)w2, (unsigned char)b1, (unsigned char)b2, (unsigned char)b3, (unsigned char)b4, (unsigned char)b5, (unsigned char)b6, (unsigned char)b7, (unsigned char)b8)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- initWithText: (NSString *)arg1
{
static qt_QString * _qstring_arg1 = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QUuid3((qt_QString *) [arg1 toQString: &_qstring_arg1])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (NSString *) toString
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QUuid_toString((qt_QUuid *)[self qt]);
	return [NSString fromQString: _qstring];
}

- (BOOL) isNull
{
	return (BOOL) qt_QUuid_isNull((qt_QUuid *)[self qt]);
}

//- initWithGUID: (GUID*)guid
//{
//	if ([self qt] == 0L) {
//		[self setQt: qt_new_QUuid4((GUID) guid)];
//		[self setAllocatedInObjcWorld: YES];
//		[QtSupport setObject: self forQtKey: [self qt]];
//	}
//	[super init];
//	return self;
//}

@end
