/***************************************************************************
                            QBuffer.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_QBuffer.h>
#include <qtobjc/QBuffer.h>
#include <qtobjc/QByteArray.h>

@implementation  QBuffer


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

- initWithByteArray: (QByteArray*)arg1
{
	if ([self qt] == 0L) {
		[self setQt: qt_new_QBuffer1((qt_QByteArray*) [arg1 qt])];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

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

- (QByteArray*) buffer
{
	return (QByteArray*) [QtSupport objectForQtKey: qt_QBuffer_buffer((qt_QBuffer *)[self qt]) withClass: [QByteArray class] allocatedInObjcWorld: YES];
}

- (BOOL) setBuffer: (QByteArray*)arg1
{
	return (BOOL) qt_QBuffer_setBuffer((qt_QBuffer *)[self qt], (qt_QByteArray*) [arg1 qt]);
}

- (BOOL) open: (int)arg1
{
	return (BOOL) qt_QBuffer_open((qt_QBuffer *)[self qt], (int)arg1);
}

- close
{
	qt_QBuffer_close((qt_QBuffer *)[self qt]);
	return self;
}

- flush
{
	qt_QBuffer_flush((qt_QBuffer *)[self qt]);
	return self;
}

- (int) size
{
	return (int) qt_QBuffer_size((qt_QBuffer *)[self qt]);
}

- (int) at
{
	return (int) qt_QBuffer_at((qt_QBuffer *)[self qt]);
}

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

- (long) readBlock: (NSString *)p long: (long)arg1
{
	return (long) qt_QBuffer_readBlock((qt_QBuffer *)[self qt], (char*) [p cString], (long)arg1);
}

- (long) writeBlock: (NSString *)p long: (long)arg1
{
	return (long) qt_QBuffer_writeBlock((qt_QBuffer *)[self qt], (char*) [p cString], (long)arg1);
}

- (long) writeBlock: (QByteArray*)data
{
	return (long) qt_QBuffer_writeBlock1((qt_QBuffer *)[self qt], (qt_QByteArray*) [data qt]);
}

- (long) readLine: (NSString *)p long: (long)arg1
{
	return (long) qt_QBuffer_readLine((qt_QBuffer *)[self qt], (char*) [p cString], (long)arg1);
}

- (int) getch
{
	return (int) qt_QBuffer_getch((qt_QBuffer *)[self qt]);
}

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

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

@end
