/***************************************************************************
                            QTranslatorMessage.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_QTranslatorMessage.h>
#include <qtobjc/QTranslatorMessage.h>

@implementation  QTranslatorMessage

- (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_QTranslatorMessage()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)context sourceText: (NSString *)sourceText comment: (NSString *)comment translation: (NSString *)translation
{
static qt_QString * _qstring_translation = 0L;
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTranslatorMessage1((char*) [context cString], (char*) [sourceText cString], (char*) [comment cString], (qt_QString *) [translation toQString: &_qstring_translation])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithText: (NSString *)context sourceText: (NSString *)sourceText comment: (NSString *)comment 
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTranslatorMessage1((char*) [context cString], (char*) [sourceText cString], (char*) [comment cString], qt_QString_null())];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithDataStream: (QDataStream *)arg1
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QTranslatorMessage2((qt_QDataStream *) [arg1 qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (unsigned int) hash
{
	return (unsigned int) qt_QTranslatorMessage_hash((qt_QTranslatorMessage *)[self qt]);
}

- (NSString *) context
{
	return (NSString *) [NSString stringWithCString: qt_QTranslatorMessage_context((qt_QTranslatorMessage *)[self qt])];
}

- (NSString *) sourceText
{
	return (NSString *) [NSString stringWithCString: qt_QTranslatorMessage_sourceText((qt_QTranslatorMessage *)[self qt])];
}

- (NSString *) comment
{
	return (NSString *) [NSString stringWithCString: qt_QTranslatorMessage_comment((qt_QTranslatorMessage *)[self qt])];
}

- setTranslation: (NSString *)translation
{
static qt_QString * _qstring_translation = 0L;
	qt_QTranslatorMessage_setTranslation((qt_QTranslatorMessage *)[self qt], (qt_QString *) [translation toQString: &_qstring_translation]);
	return self;
}

- (NSString *) translation
{
static qt_QString * _qstring = 0L;
	_qstring = qt_QTranslatorMessage_translation((qt_QTranslatorMessage *)[self qt]);
	return [NSString fromQString: _qstring];
}

- write: (QDataStream *)s strip: (BOOL)strip prefix: (int)prefix
{
	qt_QTranslatorMessage_write((qt_QTranslatorMessage *)[self qt], (qt_QDataStream *) [s qt], (int)strip, (int)prefix);
	return self;
}

- write: (QDataStream *)s 
{
	qt_QTranslatorMessage_write((qt_QTranslatorMessage *)[self qt], (qt_QDataStream *) [s qt], 0, [QTranslatorMessage HashContextSourceTextComment]);
	return self;
}

- (int) commonPrefix: (QTranslatorMessage*)arg1
{
	return (int) qt_QTranslatorMessage_commonPrefix((qt_QTranslatorMessage *)[self qt], (qt_QTranslatorMessage*) [arg1 qt]);
}

+ (int) NoPrefix
{
	return (int) QTRANSLATORMESSAGE_NoPrefix;
}

+ (int) Hash
{
	return (int) QTRANSLATORMESSAGE_Hash;
}

+ (int) HashContext
{
	return (int) QTRANSLATORMESSAGE_HashContext;
}

+ (int) HashContextSourceText
{
	return (int) QTRANSLATORMESSAGE_HashContextSourceText;
}

+ (int) HashContextSourceTextComment
{
	return (int) QTRANSLATORMESSAGE_HashContextSourceTextComment;
}

@end
