/***************************************************************************
                            KFilterDev.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, 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 <kdec/kde_KFilterDev.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/KFilterDev.h>
#include <kdeobjc/KFilterBase.h>
#include <qtobjc/QFile.h>


@implementation  KFilterDev


- initWithFilterBase: (KFilterBase*)filter autodeleteFilterBase: (BOOL)autodeleteFilterBase
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KFilterDev((kde_KFilterBase*) [filter qt], (int)autodeleteFilterBase)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- initWithFilterBase: (KFilterBase*)filter 
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_KFilterDev((kde_KFilterBase*) [filter qt], 0)];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld]) {
			kde_del_KFilterDev((kde_KFilterDev *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

- (BOOL) open: (int)mode
{
	return (BOOL) kde_KFilterDev_open((kde_KFilterDev *)[self qt], (int)mode);
}

- close
{
	kde_KFilterDev_close((kde_KFilterDev *)[self qt]);
	return self;
}

- flush
{
	kde_KFilterDev_flush((kde_KFilterDev *)[self qt]);
	return self;
}

- setOrigFileName: (NSString *)fileName
{
static qt_QCString * _qcstring_fileName = 0L;
	kde_KFilterDev_setOrigFileName((kde_KFilterDev *)[self qt], (qt_QCString*) [fileName toQCString: &_qcstring_fileName]);
	return self;
}

- (int) size
{
	return (int) kde_KFilterDev_size((kde_KFilterDev *)[self qt]);
}

- (int) at
{
	return (int) kde_KFilterDev_at((kde_KFilterDev *)[self qt]);
}

- (BOOL) at: (int)arg1
{
	return (BOOL) kde_KFilterDev_at1((kde_KFilterDev *)[self qt], (int)arg1);
}

- (BOOL) atEnd
{
	return (BOOL) kde_KFilterDev_atEnd((kde_KFilterDev *)[self qt]);
}

- (long) readBlock: (NSString *)data maxlen: (long)maxlen
{
	return (long) kde_KFilterDev_readBlock((kde_KFilterDev *)[self qt], (char*) [data cString], (long)maxlen);
}

- (long) writeBlock: (NSString *)data len: (long)len
{
	return (long) kde_KFilterDev_writeBlock((kde_KFilterDev *)[self qt], (char*) [data cString], (long)len);
}

- (int) getch
{
	return (int) kde_KFilterDev_getch((kde_KFilterDev *)[self qt]);
}

- (int) putch: (int)arg1
{
	return (int) kde_KFilterDev_putch((kde_KFilterDev *)[self qt], (int)arg1);
}

- (int) ungetch: (int)arg1
{
	return (int) kde_KFilterDev_ungetch((kde_KFilterDev *)[self qt], (int)arg1);
}

+ (QIODevice*) createFilterDevice: (KFilterBase*)base file: (QFile*)file
{
	return (QIODevice*) [QtSupport objectForQtKey: kde_KFilterDev_createFilterDevice((kde_KFilterBase*) [base qt], (qt_QFile*) [file qt]) withClass: [QIODevice class] allocatedInObjcWorld: YES];
}

+ (QIODevice*) deviceForFile: (NSString *)fileName mimetype: (NSString *)mimetype forceFilter: (BOOL)forceFilter
{
static qt_QString * _qstring_mimetype = 0L;
static qt_QString * _qstring_fileName = 0L;
	return (QIODevice*) [QtSupport objectForQtKey: kde_KFilterDev_deviceForFile((qt_QString *) [fileName toQString: &_qstring_fileName], (qt_QString *) [mimetype toQString: &_qstring_mimetype], (int)forceFilter) withClass: [QIODevice class] allocatedInObjcWorld: YES];
}

+ (QIODevice*) deviceForFile: (NSString *)fileName 
{
static qt_QString * _qstring_fileName = 0L;
	return (QIODevice*) [QtSupport objectForQtKey: kde_KFilterDev_deviceForFile((qt_QString *) [fileName toQString: &_qstring_fileName], qt_QString_null(), 0) withClass: [QIODevice class] allocatedInObjcWorld: YES];
}

@end
